diff mbox series

[scarthgap,2/3] busybox: fix CVE-2026-38753

Message ID 20261201155656.839273-3-joaomarcos.costa@bootlin.com
State New
Headers show
Series busybox: fix multiple High scored CVEs | expand

Commit Message

João Marcos Costa (Schneider Electric) Dec. 1, 2026, 3:56 p.m. UTC
A patch [1] to fix this vulnerability, marked as High [2], was submitted to
Busybox's mailing list, but not yet merged.

Backport the fix to busybox 1.36.1, and mark it as 'Pending'.

[1] https://lists.busybox.net/pipermail/busybox/2026-June/092352.html
[2] https://nvd.nist.gov/vuln/detail/cve-2026-38753

Signed-off-by: João Marcos Costa (Schneider Electric) <joaomarcos.costa@bootlin.com>
---
 .../busybox/busybox/CVE-2026-38753.patch      | 57 +++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.36.1.bb   |  1 +
 2 files changed, 58 insertions(+)
 create mode 100644 meta/recipes-core/busybox/busybox/CVE-2026-38753.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/busybox/busybox/CVE-2026-38753.patch b/meta/recipes-core/busybox/busybox/CVE-2026-38753.patch
new file mode 100644
index 0000000000..2a4d25cbed
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/CVE-2026-38753.patch
@@ -0,0 +1,57 @@ 
+From bab483171876d2e46630519df7d6bec4327f073d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jo=C3=A3o=20Marcos=20Costa?= <joaomarcos.costa@bootlin.com>
+Date: Tue, 1 Dec 2026 16:12:42 +0100
+Subject: [PATCH] awk: fix use-after-free in awk_sub()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+awk_sub() receives the replacement text as a pointer into awk variable
+storage. Evaluating the regular expression argument can change that
+storage through as_regex(), leaving the replacement pointer dangling
+before strlen() and the replacement loop use it.
+
+Copy the replacement string before calling as_regex() so substitution
+uses stable storage for the duration of the operation.
+
+Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com>
+
+CVE: CVE-2026-38753
+Upstream-Status: Pending [https://lists.busybox.net/pipermail/busybox/2026-June/092352.html]
+
+Signed-off-by: João Marcos Costa (Schneider Electric) <joaomarcos.costa@bootlin.com>
+---
+ editors/awk.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/editors/awk.c b/editors/awk.c
+index 137e9d194..1b60c9288 100644
+--- a/editors/awk.c
++++ b/editors/awk.c
+@@ -2498,6 +2498,7 @@ static char *awk_printf(node *n, size_t *len)
+ static int awk_sub(node *rn, const char *repl, int nm, var *src, var *dest, int subexp)
+ {
+ 	char *resbuf;
++	char *repl_copy;
+ 	const char *sp;
+ 	int match_no, residx, replen, resbufsize;
+ 	int regexec_flags;
+@@ -2507,8 +2508,10 @@ static int awk_sub(node *rn, const char *repl, int nm, var *src, var *dest, int
+ 	resbuf = NULL;
+ 	residx = 0;
+ 	match_no = 0;
++	repl_copy = xstrdup(repl);
+ 	regexec_flags = 0;
+ 	regex = as_regex(rn, &sreg);
++	repl = repl_copy;
+ 	sp = getvar_s(src ? src : intvar[F0]);
+ 	replen = strlen(repl);
+ 	while (regexec(regex, sp, 10, pmatch, regexec_flags) == 0) {
+@@ -2583,6 +2586,7 @@ static int awk_sub(node *rn, const char *repl, int nm, var *src, var *dest, int
+ 	setvar_p(dest ? dest : intvar[F0], resbuf);
+ 	if (regex == &sreg)
+ 		regfree(regex);
++	free(repl_copy);
+ 	return match_no;
+ }
+ 
diff --git a/meta/recipes-core/busybox/busybox_1.36.1.bb b/meta/recipes-core/busybox/busybox_1.36.1.bb
index 629fe758f6..68dea62557 100644
--- a/meta/recipes-core/busybox/busybox_1.36.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.36.1.bb
@@ -69,6 +69,7 @@  SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
            file://CVE-2026-38754.patch \
            file://CVE-2024-58251.patch \
            file://CVE-2026-38752.patch \
+           file://CVE-2026-38753.patch \
            "
 SRC_URI:append:libc-musl = " file://musl.cfg "
 # TODO http://lists.busybox.net/pipermail/busybox/2023-January/090078.html