Skip to contentSkip to conversation

jq: patch CVE-2026-32316

PATCH New [email protected] 1 participant 9 messages Apr 26

lore
Share & tools
lore
#0 lore raw

PATCH 1/9 jq: patch CVE-2026-32316

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2026-32316

---
 .../jq/jq/CVE-2026-32316.patch                | 55 +++++++++++++++++++
 meta-oe/recipes-devtools/jq/jq_1.7.1.bb       |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/jq/jq/CVE-2026-32316.patch
meta-oe/recipes-devtools/jq/jq/CVE-2026-32316.patch new file +55 -0
new file mode 100644
index 0000000000..2f2ff2145f
@@ -0,0 +1,55 @@
+From 0814c321b08415c18165deac419f0d60a4a7664f Mon Sep 17 00:00:00 2001
+From: itchyny <[email protected]>
+Date: Thu, 12 Mar 2026 20:28:43 +0900
+Subject: [PATCH] Fix heap buffer overflow in `jvp_string_append` and
+ `jvp_string_copy_replace_bad`
+
+In `jvp_string_append`, the allocation size `(currlen + len) * 2` could
+overflow `uint32_t` when `currlen + len` exceeds `INT_MAX`, causing a small
+allocation followed by a large `memcpy`.
+
+In `jvp_string_copy_replace_bad`, the output buffer size calculation
+`length * 3 + 1` could overflow `uint32_t`, again resulting in a small
+allocation followed by a large write.
+
+Add overflow checks to both functions to return an error for strings
+that would exceed `INT_MAX` in length. Fixes CVE-2026-32316.
+
+(cherry picked from commit e47e56d226519635768e6aab2f38f0ab037c09e5)
+
+CVE: CVE-2026-32316
+Upstream-Status: Backport [https://github.com/jqlang/jq/commit/e47e56d226519635768e6aab2f38f0ab037c09e5]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/jv.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/src/jv.c b/src/jv.c
+index 18dbb54..73387d8 100644
+--- a/src/jv.c
++++ b/src/jv.c
+@@ -1091,7 +1091,12 @@ static jv jvp_string_copy_replace_bad(const char* data, uint32_t length) {
+   const char* end = data + length;
+   const char* i = data;
+ 
+-  uint32_t maxlength = length * 3 + 1; // worst case: all bad bytes, each becomes a 3-byte U+FFFD
++  // worst case: all bad bytes, each becomes a 3-byte U+FFFD
++  uint64_t maxlength = (uint64_t)length * 3 + 1;
++  if (maxlength >= INT_MAX) {
++    return jv_invalid_with_msg(jv_string("String too long"));
++  }
++
+   jvp_string* s = jvp_string_alloc(maxlength);
+   char* out = s->data;
+   int c = 0;
+@@ -1151,6 +1156,10 @@ static uint32_t jvp_string_remaining_space(jvp_string* s) {
+ static jv jvp_string_append(jv string, const char* data, uint32_t len) {
+   jvp_string* s = jvp_string_ptr(string);
+   uint32_t currlen = jvp_string_length(s);
++  if ((uint64_t)currlen + len >= INT_MAX) {
++    jv_free(string);
++    return jv_invalid_with_msg(jv_string("String too long"));
++  }
+ 
+   if (jvp_refcnt_unshared(string.u.ptr) &&
+       jvp_string_remaining_space(s) >= len) {
meta-oe/recipes-devtools/jq/jq_1.7.1.bb +1 -0
index dfc8dda7ee..c3b547383d 100644
@@ -15,6 +15,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \
     file://CVE-2024-53427.patch \
     file://CVE-2025-48060.patch \
     file://CVE-2025-9403.patch \
+    file://CVE-2026-32316.patch \
     "
 SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2"
 
#1 lore raw

PATCH 2/9 jq: patch CVE-2026-33947

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2026-33947

---
 .../jq/jq/CVE-2026-33947.patch                | 107 ++++++++++++++++++
 meta-oe/recipes-devtools/jq/jq_1.7.1.bb       |   1 +
 2 files changed, 108 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/jq/jq/CVE-2026-33947.patch
meta-oe/recipes-devtools/jq/jq/CVE-2026-33947.patch new file +107 -0
new file mode 100644
index 0000000000..bf1a506311
@@ -0,0 +1,107 @@
+From d6a36423898f756355c270c4acae335318ac357c Mon Sep 17 00:00:00 2001
+From: itchyny <[email protected]>
+Date: Mon, 13 Apr 2026 11:23:40 +0900
+Subject: [PATCH] Limit path depth to prevent stack overflow
+
+Deeply nested path arrays can cause unbounded recursion in
+`jv_setpath`, `jv_getpath`, and `jv_delpaths`, leading to
+stack overflow. Add a depth limit of 10000 to match the
+existing `tojson` depth limit. This fixes CVE-2026-33947.
+
+(cherry picked from commit fb59f1491058d58bdc3e8dd28f1773d1ac690a1f)
+
+CVE: CVE-2026-33947
+Upstream-Status: Backport [https://github.com/jqlang/jq/commit/fb59f1491058d58bdc3e8dd28f1773d1ac690a1f]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/jv_aux.c  | 21 +++++++++++++++++++++
+ tests/jq.test | 25 +++++++++++++++++++++++++
+ 2 files changed, 46 insertions(+)
+
+diff --git a/src/jv_aux.c b/src/jv_aux.c
+index bbe1c0d..0855053 100644
+--- a/src/jv_aux.c
++++ b/src/jv_aux.c
+@@ -376,6 +376,10 @@ static jv jv_dels(jv t, jv keys) {
+   return t;
+ }
+ 
++#ifndef MAX_PATH_DEPTH
++#define MAX_PATH_DEPTH (10000)
++#endif
++
+ jv jv_setpath(jv root, jv path, jv value) {
+   if (jv_get_kind(path) != JV_KIND_ARRAY) {
+     jv_free(value);
+@@ -383,6 +387,12 @@ jv jv_setpath(jv root, jv path, jv value) {
+     jv_free(path);
+     return jv_invalid_with_msg(jv_string("Path must be specified as an array"));
+   }
++  if (jv_array_length(jv_copy(path)) > MAX_PATH_DEPTH) {
++    jv_free(value);
++    jv_free(root);
++    jv_free(path);
++    return jv_invalid_with_msg(jv_string("Path too deep"));
++  }
+   if (!jv_is_valid(root)){
+     jv_free(value);
+     jv_free(path);
+@@ -434,6 +444,11 @@ jv jv_getpath(jv root, jv path) {
+     jv_free(path);
+     return jv_invalid_with_msg(jv_string("Path must be specified as an array"));
+   }
++  if (jv_array_length(jv_copy(path)) > MAX_PATH_DEPTH) {
++    jv_free(root);
++    jv_free(path);
++    return jv_invalid_with_msg(jv_string("Path too deep"));
++  }
+   if (!jv_is_valid(root)) {
+     jv_free(path);
+     return root;
+@@ -511,6 +526,12 @@ jv jv_delpaths(jv object, jv paths) {
+       jv_free(elem);
+       return err;
+     }
++    if (jv_array_length(jv_copy(elem)) > MAX_PATH_DEPTH) {
++      jv_free(object);
++      jv_free(paths);
++      jv_free(elem);
++      return jv_invalid_with_msg(jv_string("Path too deep"));
++    }
+     jv_free(elem);
+   }
+   if (jv_array_length(jv_copy(paths)) == 0) {
+diff --git a/tests/jq.test b/tests/jq.test
+index ecb9116..4d57301 100644
+--- a/tests/jq.test
++++ b/tests/jq.test
+@@ -2129,3 +2129,28 @@ try ltrimstr("x") catch "x", try rtrimstr("x") catch "x" | "ok"
+ {"hey":[]}
+ "ok"
+ "ok"
++
++# regression test for CVE-2026-33947
++setpath([range(10000) | 0]; 0) | flatten
++null
++[0]
++
++try setpath([range(10001) | 0]; 0) catch .
++null
++"Path too deep"
++
++getpath([range(10000) | 0])
++null
++null
++
++try getpath([range(10001) | 0]) catch .
++null
++"Path too deep"
++
++delpaths([[range(10000) | 0]])
++null
++null
++
++try delpaths([[range(10001) | 0]]) catch .
++null
++"Path too deep"
+\ No newline at end of file
meta-oe/recipes-devtools/jq/jq_1.7.1.bb +1 -0
index c3b547383d..7b7910bc72 100644
@@ -16,6 +16,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \
     file://CVE-2025-48060.patch \
     file://CVE-2025-9403.patch \
     file://CVE-2026-32316.patch \
+    file://CVE-2026-33947.patch \
     "
 SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2"
 
#2 lore raw

PATCH 3/9 jq: patch CVE-2026-33948

In reply to [email protected]

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2026-33948

---
 .../jq/jq/CVE-2026-33948.patch                | 51 +++++++++++++++++++
 meta-oe/recipes-devtools/jq/jq_1.7.1.bb       |  1 +
 2 files changed, 52 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/jq/jq/CVE-2026-33948.patch
meta-oe/recipes-devtools/jq/jq/CVE-2026-33948.patch new file +51 -0
new file mode 100644
index 0000000000..a2aabec059
@@ -0,0 +1,51 @@
+From 4676c3e5675ba6e8422b021375acbd7c0ba450b0 Mon Sep 17 00:00:00 2001
+From: itchyny <[email protected]>
+Date: Mon, 13 Apr 2026 08:46:11 +0900
+Subject: [PATCH] Fix NUL truncation in the JSON parser
+
+This fixes CVE-2026-33948.
+
+(cherry picked from commit 6374ae0bcdfe33a18eb0ae6db28493b1f34a0a5b)
+
+CVE: CVE-2026-33948
+Upstream-Status: Backport [https://github.com/jqlang/jq/commit/6374ae0bcdfe33a18eb0ae6db28493b1f34a0a5b]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/util.c   | 8 +-------
+ tests/shtest | 6 ++++++
+ 2 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/src/util.c b/src/util.c
+index de44fa6..422a8b8 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -311,13 +311,7 @@ static int jq_util_input_read_more(jq_util_input_state *state) {
+       if (p != NULL)
+         state->current_line++;
+ 
+-      if (p == NULL && state->parser != NULL) {
+-        /*
+-         * There should be no NULs in JSON texts (but JSON text
+-         * sequences are another story).
+-         */
+-        state->buf_valid_len = strlen(state->buf);
+-      } else if (p == NULL && feof(state->current_input)) {
++      if (p == NULL && feof(state->current_input)) {
+         size_t i;
+ 
+         /*
+diff --git a/tests/shtest b/tests/shtest
+index a471889..0397ca0 100755
+--- a/tests/shtest
++++ b/tests/shtest
+@@ -609,4 +609,10 @@ $VALGRIND $Q $JQ . <<\NUM
+ -10E-1000000001
+ NUM
+ 
++# CVE-2026-33948: No NUL truncation in the JSON parser
++if printf '{}\x00{}' | $JQ >/dev/null 2> /dev/null; then
++  printf 'Error expected but jq exited successfully\n' 1>&2
++  exit 1
++fi
++
+ exit 0
meta-oe/recipes-devtools/jq/jq_1.7.1.bb +1 -0
index 7b7910bc72..975d7d7007 100644
@@ -17,6 +17,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \
     file://CVE-2025-9403.patch \
     file://CVE-2026-32316.patch \
     file://CVE-2026-33947.patch \
+    file://CVE-2026-33948.patch \
     "
 SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2"
 
#3 lore raw

PATCH 4/9 jq: patch CVE-2026-39979

In reply to [email protected]

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2026-39979

Ptests passed:

root@qemux86:~# ptest-runner jq
START: ptest-runner
2026-04-26T11:09
BEGIN: /usr/lib/jq/ptest
PASS: optionaltest
PASS: mantest
PASS: jqtest
PASS: onigtest
PASS: shtest
PASS: utf8test
PASS: base64test
=== Test Summary ===
TOTAL: 7
PASSED: 7
FAILED: 0
SKIPPED: 0
DURATION: 44
END: /usr/lib/jq/ptest
2026-04-26T11:10
STOP: ptest-runner
TOTAL: 1 FAIL: 0
---
 .../jq/jq/CVE-2026-39979.patch                | 32 +++++++++++++++++++
 meta-oe/recipes-devtools/jq/jq_1.7.1.bb       |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/jq/jq/CVE-2026-39979.patch
meta-oe/recipes-devtools/jq/jq/CVE-2026-39979.patch new file +32 -0
new file mode 100644
index 0000000000..7ab7e6fcdf
@@ -0,0 +1,32 @@
+From 46fac767d5007849b9a63cae2e74c0fc7afaa093 Mon Sep 17 00:00:00 2001
+From: itchyny <[email protected]>
+Date: Mon, 13 Apr 2026 11:04:52 +0900
+Subject: [PATCH] Fix out-of-bounds read in jv_parse_sized()
+
+This fixes CVE-2026-39979.
+
+Co-authored-by: Mattias Wadman <[email protected]>
+(cherry picked from commit 2f09060afab23fe9390cce7cb860b10416e1bf5f)
+
+CVE: CVE-2026-39979
+Upstream-Status: Backport [https://github.com/jqlang/jq/commit/2f09060afab23fe9390cce7cb860b10416e1bf5f]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/jv_parse.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/jv_parse.c b/src/jv_parse.c
+index 9755b8a..84a847f 100644
+--- a/src/jv_parse.c
++++ b/src/jv_parse.c
+@@ -890,8 +890,9 @@ jv jv_parse_sized_custom_flags(const char* string, int length, int flags) {
+ 
+   if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) {
+     jv msg = jv_invalid_get_msg(value);
+-    value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%s')",
++    value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%.*s')",
+                                               jv_string_value(msg),
++                                              length,
+                                               string));
+     jv_free(msg);
+   }
meta-oe/recipes-devtools/jq/jq_1.7.1.bb +1 -0
index 975d7d7007..24f49bcb13 100644
@@ -18,6 +18,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \
     file://CVE-2026-32316.patch \
     file://CVE-2026-33947.patch \
     file://CVE-2026-33948.patch \
+    file://CVE-2026-39979.patch \
     "
 SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2"
 
#4 lore raw

PATCH 5/9 openjpeg: patch CVE-2026-6192

In reply to [email protected]

From: Gyorgy Sarvari <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2026-6192

Backport the patch referenced by the NVD advisory.

(cherry picked from commit 09050325e6e0736beccc40d125e56430054b7cb8)
---
 .../openjpeg/openjpeg/CVE-2026-6192.patch     | 35 +++++++++++++++++++
 .../openjpeg/openjpeg_2.5.4.bb                |  1 +
 2 files changed, 36 insertions(+)
 create mode 100644 meta-oe/recipes-graphics/openjpeg/openjpeg/CVE-2026-6192.patch
meta-oe/recipes-graphics/openjpeg/openjpeg/CVE-2026-6192.patch new file +35 -0
new file mode 100644
index 0000000000..49be9bd0a6
@@ -0,0 +1,35 @@
+From 776b00ff792a3c54b65f3bd92dbe7476a5a54106 Mon Sep 17 00:00:00 2001
+From: Even Rouault <[email protected]>
+Date: Sun, 5 Apr 2026 13:25:27 +0200
+Subject: [PATCH] opj_pi_initialise_encode() (write code path): avoid potential
+ integer overflow leading to insufficient memory allocation
+
+Fixes #1619
+
+CVE: CVE-2026-6192
+Upstream-Status: Backport [https://github.com/uclouvain/openjpeg/commit/839936aa33eb8899bbbd80fda02796bb65068951]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/lib/openjp2/pi.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/src/lib/openjp2/pi.c b/src/lib/openjp2/pi.c
+index 15ac3314..4abb87af 100644
+--- a/src/lib/openjp2/pi.c
++++ b/src/lib/openjp2/pi.c
+@@ -1694,9 +1694,12 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
+     l_current_pi = l_pi;
+ 
+     /* memory allocation for include*/
+-    l_current_pi->include_size = l_tcp->numlayers * l_step_l;
+-    l_current_pi->include = (OPJ_INT16*) opj_calloc(l_current_pi->include_size,
+-                            sizeof(OPJ_INT16));
++    l_current_pi->include = NULL;
++    if (l_step_l <= UINT_MAX / l_tcp->numlayers) {
++        l_current_pi->include_size = l_tcp->numlayers * l_step_l;
++        l_current_pi->include = (OPJ_INT16*) opj_calloc(l_current_pi->include_size,
++                                sizeof(OPJ_INT16));
++    }
+     if (!l_current_pi->include) {
+         opj_free(l_tmp_data);
+         opj_free(l_tmp_ptr);
meta-oe/recipes-graphics/openjpeg/openjpeg_2.5.4.bb +1 -0
index d559cc9f7a..6dd3dd7542 100644
@@ -8,6 +8,7 @@ DEPENDS = "libpng tiff lcms zlib"
 SRC_URI = "git://github.com/uclouvain/openjpeg.git;branch=master;protocol=https \
            file://0001-Do-not-ask-cmake-to-export-binaries-they-don-t-make-.patch \
            file://CVE-2023-39327.patch \
+           file://CVE-2026-6192.patch \
            "
 SRCREV = "6c4a29b00211eb0430fa0e5e890f1ce5c80f409f"
 S = "${WORKDIR}/git"
#5 lore raw

PATCH 6/9 opensc: patch CVE-2025-49010

In reply to [email protected]

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2025-49010

Backport the patch referenced by the wiki[1] mentioned in the nvd.

[1] https://github.com/OpenSC/OpenSC/wiki/CVE-2025-49010

---
 .../opensc/files/CVE-2025-49010.patch         | 72 +++++++++++++++++++
 .../recipes-support/opensc/opensc_0.25.1.bb   |  1 +
 2 files changed, 73 insertions(+)
 create mode 100644 meta-oe/recipes-support/opensc/files/CVE-2025-49010.patch
meta-oe/recipes-support/opensc/files/CVE-2025-49010.patch new file +72 -0
new file mode 100644
index 0000000000..a0ac9fdad9
@@ -0,0 +1,72 @@
+From fd4c54b4571b2e1593a8331906b5f0ca2aa39283 Mon Sep 17 00:00:00 2001
+From: Frank Morgner <[email protected]>
+Date: Thu, 22 May 2025 00:24:32 +0200
+Subject: [PATCH] fixed Stack-buffer-overflow WRITE in GET RESPONSE
+
+The do-while loop in apdu.c requires the output data to be set in any
+case, otherwise non existent data may be copied to the output data.
+
+fixes https://issues.oss-fuzz.com/issues/416351800
+fixes https://issues.oss-fuzz.com/issues/416295951
+
+(cherry picked from commit 953986f65db61871bbbff72788d861d67d5140c6)
+CVE: CVE-2025-49010
+Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/953986f65db61871bbbff72788d861d67d5140c6]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/libopensc/card-nqApplet.c | 11 ++++++-----
+ src/libopensc/iso7816.c       |  5 +++--
+ 2 files changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/src/libopensc/card-nqApplet.c b/src/libopensc/card-nqApplet.c
+index f9075b948..90706f4b1 100644
+--- a/src/libopensc/card-nqApplet.c
++++ b/src/libopensc/card-nqApplet.c
+@@ -190,9 +190,10 @@ static int nqapplet_finish(struct sc_card *card)
+ 	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
+ }
+ 
+-static int nqapplet_get_response(struct sc_card *card, size_t *cb_resp, u8 *resp)
++static int
++nqapplet_get_response(struct sc_card *card, size_t *cb_resp, u8 *resp)
+ {
+-	struct sc_apdu apdu;
++	struct sc_apdu apdu = {0};
+ 	int rv;
+ 	size_t resplen;
+ 
+@@ -204,12 +205,12 @@ static int nqapplet_get_response(struct sc_card *card, size_t *cb_resp, u8 *resp
+ 
+ 	rv = sc_transmit_apdu(card, &apdu);
+ 	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
+-	if (apdu.resplen == 0) {
+-		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
+-	}
+ 
+ 	*cb_resp = apdu.resplen;
+ 
++	if (apdu.resplen == 0) {
++		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
++	}
+ 	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
+ 		rv = SC_SUCCESS;
+ 	} else if (apdu.sw1 == 0x61) {
+diff --git a/src/libopensc/iso7816.c b/src/libopensc/iso7816.c
+index 2fea84078..dc2f03c00 100644
+--- a/src/libopensc/iso7816.c
++++ b/src/libopensc/iso7816.c
+@@ -920,11 +920,12 @@ iso7816_get_response(struct sc_card *card, size_t *count, u8 *buf)
+ 
+ 	r = sc_transmit_apdu(card, &apdu);
+ 	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
+-	if (apdu.resplen == 0)
+-		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
+ 
+ 	*count = apdu.resplen;
+ 
++	if (apdu.resplen == 0) {
++		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
++	}
+ 	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
+ 		r = 0;					/* no more data to read */
+ 	else if (apdu.sw1 == 0x61)
meta-oe/recipes-support/opensc/opensc_0.25.1.bb +1 -0
index e41c457fa8..bcdf5900ea 100644
@@ -17,6 +17,7 @@ SRC_URI = "git://github.com/OpenSC/OpenSC;branch=stable-0.25;protocol=https \
            file://0001-PR-Fixes-for-uninitialized-memory-issues.patch \
            file://CVE-2024-8443-0001.patch \
            file://CVE-2024-8443-0002.patch \
+           file://CVE-2025-49010.patch \
          "
 DEPENDS = "virtual/libiconv openssl"
 
#6 lore raw

PATCH 7/9 opensc: patch CVE-2025-66037

In reply to [email protected]

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2025-66037

Backport the patch referenced by the wiki[1] mentioned in the nvd.

[1] https://github.com/OpenSC/OpenSC/wiki/CVE-2025-66037

---
 .../opensc/files/CVE-2025-66037.patch         | 35 +++++++++++++++++++
 .../recipes-support/opensc/opensc_0.25.1.bb   |  1 +
 2 files changed, 36 insertions(+)
 create mode 100644 meta-oe/recipes-support/opensc/files/CVE-2025-66037.patch
meta-oe/recipes-support/opensc/files/CVE-2025-66037.patch new file +35 -0
new file mode 100644
index 0000000000..91ffe53373
@@ -0,0 +1,35 @@
+From b1a6f86298af7dfbaa1110b86662a9d1393a7678 Mon Sep 17 00:00:00 2001
+From: Jakub Jelen <[email protected]>
+Date: Tue, 25 Nov 2025 15:58:02 +0100
+Subject: [PATCH] pkcs15: Avoid buffer overrun on invalid data
+
+Invalid data can contain zero-length buffer, which after copying
+was dereferenced without length check
+
+Credit: Aldo Ristori
+
+Signed-off-by: Jakub Jelen <[email protected]>
+(cherry picked from commit 65fc211015cfcac27b10d0876054156c97225f50)
+
+CVE: CVE-2025-66037
+Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/65fc211015cfcac27b10d0876054156c97225f50]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/libopensc/pkcs15-pubkey.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/libopensc/pkcs15-pubkey.c b/src/libopensc/pkcs15-pubkey.c
+index a759efa45..48fb08cac 100644
+--- a/src/libopensc/pkcs15-pubkey.c
++++ b/src/libopensc/pkcs15-pubkey.c
+@@ -1328,6 +1328,10 @@ sc_pkcs15_pubkey_from_spki_fields(struct sc_context *ctx, struct sc_pkcs15_pubke
+ 	       "sc_pkcs15_pubkey_from_spki_fields() called: %p:%"SC_FORMAT_LEN_SIZE_T"u\n%s",
+ 	       buf, buflen, sc_dump_hex(buf, buflen));
+ 
++	if (buflen < 1) {
++		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "subjectPublicKeyInfo can not be empty");
++	}
++
+ 	tmp_buf = malloc(buflen);
+ 	if (!tmp_buf) {
+ 		r = SC_ERROR_OUT_OF_MEMORY;
meta-oe/recipes-support/opensc/opensc_0.25.1.bb +1 -0
index bcdf5900ea..999ae34b12 100644
@@ -18,6 +18,7 @@ SRC_URI = "git://github.com/OpenSC/OpenSC;branch=stable-0.25;protocol=https \
            file://CVE-2024-8443-0001.patch \
            file://CVE-2024-8443-0002.patch \
            file://CVE-2025-49010.patch \
+           file://CVE-2025-66037.patch \
          "
 DEPENDS = "virtual/libiconv openssl"
 
#7 lore raw

PATCH 8/9 opensc: patch CVE-2025-66038

In reply to [email protected]

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2025-66038

Backport the patch referenced by the wiki[1] mentioned in the nvd.

[1] https://github.com/OpenSC/OpenSC/wiki/CVE-2025-66038

---
 .../opensc/files/CVE-2025-66038.patch         | 41 +++++++++++++++++++
 .../recipes-support/opensc/opensc_0.25.1.bb   |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta-oe/recipes-support/opensc/files/CVE-2025-66038.patch
meta-oe/recipes-support/opensc/files/CVE-2025-66038.patch new file +41 -0
new file mode 100644
index 0000000000..e5a27deae5
@@ -0,0 +1,41 @@
+From 2f5582340ac3fd2062d0f6561a13aa9b269062dd Mon Sep 17 00:00:00 2001
+From: Jakub Jelen <[email protected]>
+Date: Tue, 18 Nov 2025 14:13:59 +0100
+Subject: [PATCH] compacttlv: Fix possible buffer overrun
+
+Fixes: GHSA-72x5-fwjx-2459
+
+Signed-off-by: Jakub Jelen <[email protected]>
+(cherry picked from commit a20b91adc2fc66785c0df98abc8ef456c0eaab9d)
+
+CVE: CVE-2025-66038
+Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/a20b91adc2fc66785c0df98abc8ef456c0eaab9d]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/libopensc/sc.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/src/libopensc/sc.c b/src/libopensc/sc.c
+index 7c9e0d25e..eb88b9abe 100644
+--- a/src/libopensc/sc.c
++++ b/src/libopensc/sc.c
+@@ -1082,13 +1082,15 @@ const u8 *sc_compacttlv_find_tag(const u8 *buf, size_t len, u8 tag, size_t *outl
+ 		size_t expected_len = tag & 0x0F;
+ 
+ 	        for (idx = 0; idx < len; idx++) {
+-			if ((buf[idx] & 0xF0) == plain_tag && idx + expected_len < len &&
+-			    (expected_len == 0 || expected_len == (buf[idx] & 0x0F))) {
++			u8 ctag = buf[idx] & 0xF0;
++			size_t ctag_len = buf[idx] & 0x0F;
++			if (ctag == plain_tag && idx + ctag_len < len &&
++					(expected_len == 0 || expected_len == ctag_len)) {
+ 				if (outlen != NULL)
+-					*outlen = buf[idx] & 0x0F;
++					*outlen = ctag_len;
+ 				return buf + (idx + 1);
+ 			}
+-			idx += (buf[idx] & 0x0F);
++			idx += ctag_len;
+                 }
+         }
+ 	return NULL;
meta-oe/recipes-support/opensc/opensc_0.25.1.bb +1 -0
index 999ae34b12..6772fe02f7 100644
@@ -19,6 +19,7 @@ SRC_URI = "git://github.com/OpenSC/OpenSC;branch=stable-0.25;protocol=https \
            file://CVE-2024-8443-0002.patch \
            file://CVE-2025-49010.patch \
            file://CVE-2025-66037.patch \
+           file://CVE-2025-66038.patch \
          "
 DEPENDS = "virtual/libiconv openssl"
 
#8 lore raw

PATCH 9/9 opensc: patch CVE-2025-66215

In reply to [email protected]

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2025-66215

Backport the patches referenced by the PR[1] mentioned in the nvd. Dropped the formatting commit from the backport.

[1] https://github.com/OpenSC/OpenSC/pull/3436

---
 .../opensc/files/CVE-2025-66215-1.patch       | 29 +++++++++
 .../opensc/files/CVE-2025-66215-2.patch       | 37 +++++++++++
 .../opensc/files/CVE-2025-66215-3.patch       | 45 ++++++++++++++
 .../opensc/files/CVE-2025-66215-4.patch       | 62 +++++++++++++++++++
 .../recipes-support/opensc/opensc_0.25.1.bb   |  4 ++
 5 files changed, 177 insertions(+)
 create mode 100644 meta-oe/recipes-support/opensc/files/CVE-2025-66215-1.patch
 create mode 100644 meta-oe/recipes-support/opensc/files/CVE-2025-66215-2.patch
 create mode 100644 meta-oe/recipes-support/opensc/files/CVE-2025-66215-3.patch
 create mode 100644 meta-oe/recipes-support/opensc/files/CVE-2025-66215-4.patch
meta-oe/recipes-support/opensc/files/CVE-2025-66215-1.patch new file +29 -0
new file mode 100644
index 0000000000..ac2926b5e6
@@ -0,0 +1,29 @@
+From 74a72d3a82d1f49d55ef822ededec74738a30ec4 Mon Sep 17 00:00:00 2001
+From: Frank Morgner <[email protected]>
+Date: Wed, 4 Jun 2025 00:52:13 +0200
+Subject: [PATCH] fixed  Stack-buffer-overflow WRITE
+
+fixes https://issues.oss-fuzz.com/issues/421520684
+
+(cherry picked from commit eab4d17866bb457dd86d067b304294e9f6671d52)
+
+CVE: CVE-2025-66215
+Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/eab4d17866bb457dd86d067b304294e9f6671d52]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/libopensc/card-oberthur.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c
+index d5445f01a..a8aba7992 100644
+--- a/src/libopensc/card-oberthur.c
++++ b/src/libopensc/card-oberthur.c
+@@ -1135,7 +1135,7 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile
+ 	apdu.lc = ilen;
+ 	apdu.le = olen > 256 ? 256 : olen;
+ 	apdu.resp = resp;
+-	apdu.resplen = olen;
++	apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
+ 
+ 	rv = sc_transmit_apdu(card, &apdu);
+ 	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
meta-oe/recipes-support/opensc/files/CVE-2025-66215-2.patch new file +37 -0
new file mode 100644
index 0000000000..316ac974b2
@@ -0,0 +1,37 @@
+From 5f8c904577cce1a6e21f793ba4aab1c473ff4136 Mon Sep 17 00:00:00 2001
+From: Frank Morgner <[email protected]>
+Date: Wed, 4 Jun 2025 01:07:56 +0200
+Subject: [PATCH] oberthur: fixed potential Stack-buffer-overflow WRITE
+
+(cherry picked from commit 3402a90d8c9be223d4cf6abe009a4707117d7972)
+
+CVE: CVE-2025-66215
+Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/commit/3402a90d8c9be223d4cf6abe009a4707117d7972]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/libopensc/card-oberthur.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c
+index a8aba7992..216640ebd 100644
+--- a/src/libopensc/card-oberthur.c
++++ b/src/libopensc/card-oberthur.c
+@@ -2246,14 +2246,16 @@ auth_read_record(struct sc_card *card, unsigned int nr_rec, unsigned int idx,
+ 	if (flags & SC_RECORD_BY_REC_NR)
+ 		apdu.p2 |= 0x04;
+ 
+-	apdu.le = count;
+-	apdu.resplen = count;
++	apdu.le = count > SC_MAX_APDU_BUFFER_SIZE ? SC_MAX_APDU_BUFFER_SIZE : count;
++	apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
+ 	apdu.resp = recvbuf;
+ 
+ 	rv = sc_transmit_apdu(card, &apdu);
+ 	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
+ 	if (apdu.resplen == 0)
+ 		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
++	if (count < apdu.resplen)
++		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
+ 	memcpy(buf, recvbuf, apdu.resplen);
+ 
+ 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
meta-oe/recipes-support/opensc/files/CVE-2025-66215-3.patch new file +45 -0

45 lines not on this page · raw message

meta-oe/recipes-support/opensc/files/CVE-2025-66215-4.patch new file +62 -0

62 lines not on this page · raw message

meta-oe/recipes-support/opensc/opensc_0.25.1.bb +4 -0
index 6772fe02f7..5f4382642c 100644
@@ -20,6 +20,10 @@ SRC_URI = "git://github.com/OpenSC/OpenSC;branch=stable-0.25;protocol=https \
            file://CVE-2025-49010.patch \
            file://CVE-2025-66037.patch \
            file://CVE-2025-66038.patch \
+           file://CVE-2025-66215-1.patch \
+           file://CVE-2025-66215-2.patch \
+           file://CVE-2025-66215-3.patch \
+           file://CVE-2025-66215-4.patch \
          "
 DEPENDS = "virtual/libiconv openssl"