diff options
| -rw-r--r-- | meta-oe/recipes-support/opensc/files/CVE-2025-49010.patch | 72 | ||||
| -rw-r--r-- | meta-oe/recipes-support/opensc/opensc_0.25.1.bb | 1 |
2 files changed, 73 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/opensc/files/CVE-2025-49010.patch b/meta-oe/recipes-support/opensc/files/CVE-2025-49010.patch new file mode 100644 index 0000000000..a0ac9fdad9 --- /dev/null +++ b/meta-oe/recipes-support/opensc/files/CVE-2025-49010.patch | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | From fd4c54b4571b2e1593a8331906b5f0ca2aa39283 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Frank Morgner <frankmorgner@gmail.com> | ||
| 3 | Date: Thu, 22 May 2025 00:24:32 +0200 | ||
| 4 | Subject: [PATCH] fixed Stack-buffer-overflow WRITE in GET RESPONSE | ||
| 5 | |||
| 6 | The do-while loop in apdu.c requires the output data to be set in any | ||
| 7 | case, otherwise non existent data may be copied to the output data. | ||
| 8 | |||
| 9 | fixes https://issues.oss-fuzz.com/issues/416351800 | ||
| 10 | fixes https://issues.oss-fuzz.com/issues/416295951 | ||
| 11 | |||
| 12 | (cherry picked from commit 953986f65db61871bbbff72788d861d67d5140c6) | ||
| 13 | CVE: CVE-2025-49010 | ||
| 14 | Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/953986f65db61871bbbff72788d861d67d5140c6] | ||
| 15 | Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com> | ||
| 16 | --- | ||
| 17 | src/libopensc/card-nqApplet.c | 11 ++++++----- | ||
| 18 | src/libopensc/iso7816.c | 5 +++-- | ||
| 19 | 2 files changed, 9 insertions(+), 7 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/src/libopensc/card-nqApplet.c b/src/libopensc/card-nqApplet.c | ||
| 22 | index f9075b948..90706f4b1 100644 | ||
| 23 | --- a/src/libopensc/card-nqApplet.c | ||
| 24 | +++ b/src/libopensc/card-nqApplet.c | ||
| 25 | @@ -190,9 +190,10 @@ static int nqapplet_finish(struct sc_card *card) | ||
| 26 | LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); | ||
| 27 | } | ||
| 28 | |||
| 29 | -static int nqapplet_get_response(struct sc_card *card, size_t *cb_resp, u8 *resp) | ||
| 30 | +static int | ||
| 31 | +nqapplet_get_response(struct sc_card *card, size_t *cb_resp, u8 *resp) | ||
| 32 | { | ||
| 33 | - struct sc_apdu apdu; | ||
| 34 | + struct sc_apdu apdu = {0}; | ||
| 35 | int rv; | ||
| 36 | size_t resplen; | ||
| 37 | |||
| 38 | @@ -204,12 +205,12 @@ static int nqapplet_get_response(struct sc_card *card, size_t *cb_resp, u8 *resp | ||
| 39 | |||
| 40 | rv = sc_transmit_apdu(card, &apdu); | ||
| 41 | LOG_TEST_RET(card->ctx, rv, "APDU transmit failed"); | ||
| 42 | - if (apdu.resplen == 0) { | ||
| 43 | - LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2)); | ||
| 44 | - } | ||
| 45 | |||
| 46 | *cb_resp = apdu.resplen; | ||
| 47 | |||
| 48 | + if (apdu.resplen == 0) { | ||
| 49 | + LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2)); | ||
| 50 | + } | ||
| 51 | if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) { | ||
| 52 | rv = SC_SUCCESS; | ||
| 53 | } else if (apdu.sw1 == 0x61) { | ||
| 54 | diff --git a/src/libopensc/iso7816.c b/src/libopensc/iso7816.c | ||
| 55 | index 2fea84078..dc2f03c00 100644 | ||
| 56 | --- a/src/libopensc/iso7816.c | ||
| 57 | +++ b/src/libopensc/iso7816.c | ||
| 58 | @@ -920,11 +920,12 @@ iso7816_get_response(struct sc_card *card, size_t *count, u8 *buf) | ||
| 59 | |||
| 60 | r = sc_transmit_apdu(card, &apdu); | ||
| 61 | LOG_TEST_RET(card->ctx, r, "APDU transmit failed"); | ||
| 62 | - if (apdu.resplen == 0) | ||
| 63 | - LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2)); | ||
| 64 | |||
| 65 | *count = apdu.resplen; | ||
| 66 | |||
| 67 | + if (apdu.resplen == 0) { | ||
| 68 | + LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2)); | ||
| 69 | + } | ||
| 70 | if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) | ||
| 71 | r = 0; /* no more data to read */ | ||
| 72 | else if (apdu.sw1 == 0x61) | ||
diff --git a/meta-oe/recipes-support/opensc/opensc_0.25.1.bb b/meta-oe/recipes-support/opensc/opensc_0.25.1.bb index e41c457fa8..bcdf5900ea 100644 --- a/meta-oe/recipes-support/opensc/opensc_0.25.1.bb +++ b/meta-oe/recipes-support/opensc/opensc_0.25.1.bb | |||
| @@ -17,6 +17,7 @@ SRC_URI = "git://github.com/OpenSC/OpenSC;branch=stable-0.25;protocol=https \ | |||
| 17 | file://0001-PR-Fixes-for-uninitialized-memory-issues.patch \ | 17 | file://0001-PR-Fixes-for-uninitialized-memory-issues.patch \ |
| 18 | file://CVE-2024-8443-0001.patch \ | 18 | file://CVE-2024-8443-0001.patch \ |
| 19 | file://CVE-2024-8443-0002.patch \ | 19 | file://CVE-2024-8443-0002.patch \ |
| 20 | file://CVE-2025-49010.patch \ | ||
| 20 | " | 21 | " |
| 21 | DEPENDS = "virtual/libiconv openssl" | 22 | DEPENDS = "virtual/libiconv openssl" |
| 22 | 23 | ||
