summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-support/opensc/files/CVE-2025-66215-1.patch29
-rw-r--r--meta-oe/recipes-support/opensc/files/CVE-2025-66215-2.patch37
-rw-r--r--meta-oe/recipes-support/opensc/files/CVE-2025-66215-3.patch45
-rw-r--r--meta-oe/recipes-support/opensc/files/CVE-2025-66215-4.patch62
-rw-r--r--meta-oe/recipes-support/opensc/opensc_0.25.1.bb4
5 files changed, 177 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/opensc/files/CVE-2025-66215-1.patch b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-1.patch
new file mode 100644
index 0000000000..ac2926b5e6
--- /dev/null
+++ b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-1.patch
@@ -0,0 +1,29 @@
1From 74a72d3a82d1f49d55ef822ededec74738a30ec4 Mon Sep 17 00:00:00 2001
2From: Frank Morgner <frankmorgner@gmail.com>
3Date: Wed, 4 Jun 2025 00:52:13 +0200
4Subject: [PATCH] fixed Stack-buffer-overflow WRITE
5
6fixes https://issues.oss-fuzz.com/issues/421520684
7
8(cherry picked from commit eab4d17866bb457dd86d067b304294e9f6671d52)
9
10CVE: CVE-2025-66215
11Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/eab4d17866bb457dd86d067b304294e9f6671d52]
12Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
13---
14 src/libopensc/card-oberthur.c | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c
18index d5445f01a..a8aba7992 100644
19--- a/src/libopensc/card-oberthur.c
20+++ b/src/libopensc/card-oberthur.c
21@@ -1135,7 +1135,7 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile
22 apdu.lc = ilen;
23 apdu.le = olen > 256 ? 256 : olen;
24 apdu.resp = resp;
25- apdu.resplen = olen;
26+ apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
27
28 rv = sc_transmit_apdu(card, &apdu);
29 LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
diff --git a/meta-oe/recipes-support/opensc/files/CVE-2025-66215-2.patch b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-2.patch
new file mode 100644
index 0000000000..316ac974b2
--- /dev/null
+++ b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-2.patch
@@ -0,0 +1,37 @@
1From 5f8c904577cce1a6e21f793ba4aab1c473ff4136 Mon Sep 17 00:00:00 2001
2From: Frank Morgner <frankmorgner@gmail.com>
3Date: Wed, 4 Jun 2025 01:07:56 +0200
4Subject: [PATCH] oberthur: fixed potential Stack-buffer-overflow WRITE
5
6(cherry picked from commit 3402a90d8c9be223d4cf6abe009a4707117d7972)
7
8CVE: CVE-2025-66215
9Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/3402a90d8c9be223d4cf6abe009a4707117d7972]
10Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
11---
12 src/libopensc/card-oberthur.c | 6 ++++--
13 1 file changed, 4 insertions(+), 2 deletions(-)
14
15diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c
16index a8aba7992..216640ebd 100644
17--- a/src/libopensc/card-oberthur.c
18+++ b/src/libopensc/card-oberthur.c
19@@ -2246,14 +2246,16 @@ auth_read_record(struct sc_card *card, unsigned int nr_rec, unsigned int idx,
20 if (flags & SC_RECORD_BY_REC_NR)
21 apdu.p2 |= 0x04;
22
23- apdu.le = count;
24- apdu.resplen = count;
25+ apdu.le = count > SC_MAX_APDU_BUFFER_SIZE ? SC_MAX_APDU_BUFFER_SIZE : count;
26+ apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
27 apdu.resp = recvbuf;
28
29 rv = sc_transmit_apdu(card, &apdu);
30 LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
31 if (apdu.resplen == 0)
32 LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
33+ if (count < apdu.resplen)
34+ LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
35 memcpy(buf, recvbuf, apdu.resplen);
36
37 rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
diff --git a/meta-oe/recipes-support/opensc/files/CVE-2025-66215-3.patch b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-3.patch
new file mode 100644
index 0000000000..5857abe07f
--- /dev/null
+++ b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-3.patch
@@ -0,0 +1,45 @@
1From 4db6d034c9566e903e4c1094beccaf05efc4e7e5 Mon Sep 17 00:00:00 2001
2From: Frank Morgner <frankmorgner@gmail.com>
3Date: Thu, 5 Jun 2025 13:18:15 +0200
4Subject: [PATCH] oberthur: use MIN where possible
5
6(cherry picked from commit a4bbf8a631537a4c0083b264095ed1cd36d307ab)
7
8CVE: CVE-2025-66215
9Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/a4bbf8a631537a4c0083b264095ed1cd36d307ab]
10Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
11---
12 src/libopensc/card-oberthur.c | 6 +++---
13 1 file changed, 3 insertions(+), 3 deletions(-)
14
15diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c
16index 216640ebd..3e7a7b6b9 100644
17--- a/src/libopensc/card-oberthur.c
18+++ b/src/libopensc/card-oberthur.c
19@@ -606,7 +606,7 @@ auth_list_files(struct sc_card *card, unsigned char *buf, size_t buflen)
20 if (apdu.resplen == 0x100 && rbuf[0]==0 && rbuf[1]==0)
21 LOG_FUNC_RETURN(card->ctx, 0);
22
23- buflen = buflen < apdu.resplen ? buflen : apdu.resplen;
24+ buflen = MIN(buflen, apdu.resplen);
25 memcpy(buf, rbuf, buflen);
26
27 LOG_FUNC_RETURN(card->ctx, (int)buflen);
28@@ -1133,7 +1133,7 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile
29 apdu.datalen = ilen;
30 apdu.data = in;
31 apdu.lc = ilen;
32- apdu.le = olen > 256 ? 256 : olen;
33+ apdu.le = MIN(olen, 256);
34 apdu.resp = resp;
35 apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
36
37@@ -2246,7 +2246,7 @@ auth_read_record(struct sc_card *card, unsigned int nr_rec, unsigned int idx,
38 if (flags & SC_RECORD_BY_REC_NR)
39 apdu.p2 |= 0x04;
40
41- apdu.le = count > SC_MAX_APDU_BUFFER_SIZE ? SC_MAX_APDU_BUFFER_SIZE : count;
42+ apdu.le = MIN(count, SC_MAX_APDU_BUFFER_SIZE);
43 apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
44 apdu.resp = recvbuf;
45
diff --git a/meta-oe/recipes-support/opensc/files/CVE-2025-66215-4.patch b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-4.patch
new file mode 100644
index 0000000000..80816aa57b
--- /dev/null
+++ b/meta-oe/recipes-support/opensc/files/CVE-2025-66215-4.patch
@@ -0,0 +1,62 @@
1From 665871f38aee0d52eba923783d4606becc7628d0 Mon Sep 17 00:00:00 2001
2From: Frank Morgner <frankmorgner@gmail.com>
3Date: Thu, 5 Jun 2025 14:04:35 +0200
4Subject: [PATCH] oberthur: use SC_MAX_APDU_RESP_SIZE where possible
5
6(cherry picked from commit 56bc5e9575965461d99a274be45d71c18ab6eae0)
7
8CVE: CVE-2025-66215
9Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/56bc5e9575965461d99a274be45d71c18ab6eae0]
10Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
11---
12 src/libopensc/card-oberthur.c | 10 +++++-----
13 1 file changed, 5 insertions(+), 5 deletions(-)
14
15diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c
16index 3e7a7b6b9..159b84aed 100644
17--- a/src/libopensc/card-oberthur.c
18+++ b/src/libopensc/card-oberthur.c
19@@ -1133,7 +1133,7 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile
20 apdu.datalen = ilen;
21 apdu.data = in;
22 apdu.lc = ilen;
23- apdu.le = MIN(olen, 256);
24+ apdu.le = MIN(olen, SC_MAX_APDU_RESP_SIZE);
25 apdu.resp = resp;
26 apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
27
28@@ -1180,14 +1180,14 @@ auth_decipher(struct sc_card *card, const unsigned char *in, size_t inlen,
29 }
30
31 _inlen = inlen;
32- if (_inlen == 256) {
33+ if (_inlen == SC_MAX_APDU_RESP_SIZE) {
34 apdu.cla |= 0x10;
35 apdu.data = in;
36 apdu.datalen = 8;
37 apdu.resp = resp;
38 apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
39 apdu.lc = 8;
40- apdu.le = 256;
41+ apdu.le = SC_MAX_APDU_RESP_SIZE;
42
43 rv = sc_transmit_apdu(card, &apdu);
44 sc_log(card->ctx, "rv %i", rv);
45@@ -1504,7 +1504,7 @@ auth_read_component(struct sc_card *card, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type
46 {
47 struct sc_apdu apdu;
48 int rv;
49- unsigned char resp[256];
50+ unsigned char resp[SC_MAX_APDU_RESP_SIZE];
51
52 LOG_FUNC_CALLED(card->ctx);
53 sc_log(card->ctx, "num %i, outlen %"SC_FORMAT_LEN_SIZE_T"u, type %i",
54@@ -2160,7 +2160,7 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
55 if (auth_current_ef->magic==SC_FILE_MAGIC &&
56 auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
57 int jj;
58- unsigned char resp[256];
59+ unsigned char resp[SC_MAX_APDU_RESP_SIZE];
60 size_t resp_len, out_len;
61 struct sc_pkcs15_pubkey_rsa key;
62
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 6772fe02f7..5f4382642c 100644
--- a/meta-oe/recipes-support/opensc/opensc_0.25.1.bb
+++ b/meta-oe/recipes-support/opensc/opensc_0.25.1.bb
@@ -20,6 +20,10 @@ SRC_URI = "git://github.com/OpenSC/OpenSC;branch=stable-0.25;protocol=https \
20 file://CVE-2025-49010.patch \ 20 file://CVE-2025-49010.patch \
21 file://CVE-2025-66037.patch \ 21 file://CVE-2025-66037.patch \
22 file://CVE-2025-66038.patch \ 22 file://CVE-2025-66038.patch \
23 file://CVE-2025-66215-1.patch \
24 file://CVE-2025-66215-2.patch \
25 file://CVE-2025-66215-3.patch \
26 file://CVE-2025-66215-4.patch \
23 " 27 "
24DEPENDS = "virtual/libiconv openssl" 28DEPENDS = "virtual/libiconv openssl"
25 29