Skip to contentSkip to conversation

busybox: fix CVE-2026-38752

PATCH In review Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco) 2 participants 5 messages Nov 5 – Nov 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 busybox: fix CVE-2026-38752

From: Darsh Kelaiya <[email protected]>

This patch applies the upstream fix shown in [1]. The advisory identifying the fix is referenced in [2].

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

---
 .../busybox/busybox/CVE-2026-38752.patch      | 84 +++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.38.0.bb   |  1 +
 2 files changed, 85 insertions(+)
 create mode 100644 meta/recipes-core/busybox/busybox/CVE-2026-38752.patch
meta/recipes-core/busybox/busybox/CVE-2026-38752.patch new file +84 -0
new file mode 100644
index 0000000..1906229
@@ -0,0 +1,84 @@
+From a8374915ceb752f08385de1eaf1d8782246047ae Mon Sep 17 00:00:00 2001
+From: Sanghyun Park <[email protected]>
+Date: Tue, 16 Jun 2026 12:16:05 +0900
+Subject: [PATCH] awk: fix stack overflow in evaluate()
+
+Recursive awk functions can keep re-entering evaluate() until the
+process stack is exhausted. Track active function-call depth and report a
+normal awk error once the limit is reached instead of overflowing the
+stack.
+
+CVE: CVE-2026-38752
+Upstream-Status: Submitted [https://lists.busybox.net/pipermail/busybox/2026-June/092351.html]
+
+Signed-off-by: Sanghyun Park <[email protected]>
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ editors/awk.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/editors/awk.c b/editors/awk.c
+index dd8f4ac..f15832b 100644
+--- a/editors/awk.c
++++ b/editors/awk.c
+@@ -633,6 +633,7 @@ struct globals {
+ 	smalluint exitcode;
+ 
+ 	unsigned evaluate__seed;
++	unsigned evaluate__func_depth;
+ 	var *evaluate__fnargs;
+ 	regex_t evaluate__sreg;
+ 
+@@ -703,6 +704,7 @@ static const char EMSG_UNEXP_TOKEN[] ALIGN1 = "Unexpected token";
+ static const char EMSG_DIV_BY_ZERO[] ALIGN1 = "Division by zero";
+ static const char EMSG_INV_FMT[] ALIGN1 = "Invalid format specifier";
+ static const char EMSG_TOO_FEW_ARGS[] ALIGN1 = "Too few arguments";
++static const char EMSG_RECURSION[] ALIGN1 = "Recursion limit exceeded";
+ static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array";
+ static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error";
+ static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function";
+@@ -2988,6 +2990,7 @@ static var *evaluate(node *op, var *res)
+ #define fnargs (G.evaluate__fnargs)
+ /* seed is initialized to 1 */
+ #define seed   (G.evaluate__seed)
++#define func_depth (G.evaluate__func_depth)
+ #define sreg   (G.evaluate__sreg)
+ 
+ 	var *tmpvars;
+@@ -3299,13 +3302,17 @@ static var *evaluate(node *op, var *res)
+ 			var *argvars, *sv_fnargs;
+ 			const char *sv_progname;
+ 			int nargs, i;
++			enum { MAX_AWK_FUNC_DEPTH = 1000 };
+ 
+ 			debug_printf_eval("FUNC\n");
+ 
+ 			if (!op->r.f->defined)
+ 				syntax_error(EMSG_UNDEF_FUNC);
++			if (func_depth >= MAX_AWK_FUNC_DEPTH)
++				syntax_error(EMSG_RECURSION);
+ 
+ 			/* The body might be empty, still has to eval the args */
++			func_depth++;
+ 			nargs = op->r.f->nargs;
+ 			argvars = nvalloc(nargs);
+ 			i = 0;
+@@ -3333,6 +3340,7 @@ static var *evaluate(node *op, var *res)
+ 
+ 			g_progname = sv_progname;
+ 			fnargs = sv_fnargs;
++			func_depth--;
+ 
+ 			break;
+ 		}
+@@ -3690,6 +3698,7 @@ static var *evaluate(node *op, var *res)
+ 	return res;
+ #undef fnargs
+ #undef seed
++#undef func_depth
+ #undef sreg
+ }
+ 
+-- 
+2.35.6
+
meta/recipes-core/busybox/busybox_1.38.0.bb +1 -0
index a75c639..bf78951 100644
@@ -59,6 +59,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
            file://0001-busybox-fix-printf-ptest-failure-with-glibc-2.43.patch \
            file://CVE-2025-60876.patch \
            file://CVE-2024-58251.patch \
+           file://CVE-2026-38752.patch \
            file://CVE-2026-38754.patch \
            "
 SRC_URI:append:libc-musl = " file://musl.cfg"
Signature · 1 line
2.35.6
#1 lore raw

PATCH 2/3 busybox: fix CVE-2026-38753

From: Darsh Kelaiya <[email protected]>

This patch applies the upstream fix shown in [1]. The advisory identifying the fix is referenced in [2].

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

---
 .../busybox/busybox/CVE-2026-38753.patch      | 55 +++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.38.0.bb   |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 meta/recipes-core/busybox/busybox/CVE-2026-38753.patch
meta/recipes-core/busybox/busybox/CVE-2026-38753.patch new file +55 -0
new file mode 100644
index 0000000..5e4cb94
@@ -0,0 +1,55 @@
+From 2365a1c6ef6054df297f90887f9ed305041c3675 Mon Sep 17 00:00:00 2001
+From: Sanghyun Park <[email protected]>
+Date: Tue, 16 Jun 2026 12:18:43 +0900
+Subject: [PATCH] awk: fix use-after-free in awk_sub()
+
+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.
+
+CVE: CVE-2026-38753
+Upstream-Status: Submitted [https://lists.busybox.net/pipermail/busybox/2026-June/092352.html]
+
+Signed-off-by: Sanghyun Park <[email protected]>
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ editors/awk.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/editors/awk.c b/editors/awk.c
+index f15832b..8a51827 100644
+--- a/editors/awk.c
++++ b/editors/awk.c
+@@ -2555,6 +2555,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;
+@@ -2572,7 +2573,9 @@ static int awk_sub(node *rn, const char *repl, int nm, var *src, var *dest /*,in
+ 	resbuf = NULL;
+ 	residx = 0;
+ 	match_no = 0;
++	repl_copy = xstrdup(repl);
+ 	regex = as_regex(rn, &sreg);
++	repl = repl_copy;
+ 	sp = getvar_s(src ? src : intvar[F0]);
+ #if defined(REG_STARTEND)
+ 	src_string = sp;
+@@ -2662,6 +2665,7 @@ static int awk_sub(node *rn, const char *repl, int nm, var *src, var *dest /*,in
+ 	setvar_p(dest ? dest : intvar[F0], resbuf);
+ 	if (regex == &sreg)
+ 		regfree(regex);
++	free(repl_copy);
+ 	return match_no;
+ }
+ 
+-- 
+2.35.6
+
meta/recipes-core/busybox/busybox_1.38.0.bb +1 -0
index bf78951..108839e 100644
@@ -60,6 +60,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
            file://CVE-2025-60876.patch \
            file://CVE-2024-58251.patch \
            file://CVE-2026-38752.patch \
+           file://CVE-2026-38753.patch \
            file://CVE-2026-38754.patch \
            "
 SRC_URI:append:libc-musl = " file://musl.cfg"
Signature · 1 line
2.35.6
#2 lore raw

PATCH 3/3 busybox: fix CVE-2026-38755

In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Darsh Kelaiya <[email protected]>

This patch applies the upstream fix shown in [1]. The advisory identifying the fix is referenced in [2].

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

---
 .../busybox/busybox/CVE-2026-38755.patch      | 71 +++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.38.0.bb   |  1 +
 2 files changed, 72 insertions(+)
 create mode 100644 meta/recipes-core/busybox/busybox/CVE-2026-38755.patch
meta/recipes-core/busybox/busybox/CVE-2026-38755.patch new file +71 -0
new file mode 100644
index 0000000..d999a0c
@@ -0,0 +1,71 @@
+From 819a0f9ba510c4d9efce0021a0357faa6257b44d Mon Sep 17 00:00:00 2001
+From: Sanghyun Park <[email protected]>
+Date: Tue, 16 Jun 2026 12:19:27 +0900
+Subject: [PATCH] ash: fix stack overflow in evalfun()
+
+Recursive shell functions can repeatedly enter evalfun() until the
+process stack is exhausted. Track active shell function calls and raise a
+normal shell error when the recursion limit is reached.
+
+The counter is decremented through the existing funcdone cleanup path so
+errors raised from inside the function body unwind it correctly.
+
+CVE: CVE-2026-38755
+Upstream-Status: Submitted [https://lists.busybox.net/pipermail/busybox/2026-June/092354.html]
+
+Signed-off-by: Sanghyun Park <[email protected]>
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ shell/ash.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/shell/ash.c b/shell/ash.c
+index b8ff67b..4c7c778 100644
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -481,6 +481,7 @@ struct globals_misc {
+ 	int shlvl;
+ #define rootshell (!shlvl)
+ 	int errlinno;
++	unsigned func_depth;
+ 
+ 	char *minusc;  /* argument to -c option */
+ 
+@@ -588,6 +589,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
+ #define rootpid     (G_misc.rootpid    )
+ #define shlvl       (G_misc.shlvl      )
+ #define errlinno    (G_misc.errlinno   )
++#define func_depth  (G_misc.func_depth )
+ #define minusc      (G_misc.minusc     )
+ #define curdir      (G_misc.curdir     )
+ #define physdir     (G_misc.physdir    )
+@@ -10309,6 +10311,10 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
+ 	int savefuncline;
+ 	char *savefuncname;
+ 	char *savetrap = NULL;
++	enum { MAX_ASH_FUNC_DEPTH = 1000 };
++
++	if (func_depth >= MAX_ASH_FUNC_DEPTH)
++		ash_msg_and_raise_error("function recursion limit exceeded");
+ 
+ 	if (!Eflag) {
+ 		savetrap = trap[NTRAP_ERR];
+@@ -10327,6 +10333,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
+ 	exception_handler = &jmploc;
+ 	shellparam.malloced = 0;
+ 	func->count++;
++	func_depth++;
+ 	funcname = func->n.ndefun.text;
+ 	funcline = func->n.ndefun.linno;
+ 	INTON;
+@@ -10348,6 +10355,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
+ 	}
+ 	funcline = savefuncline;
+ 	lineno = savelineno;
++	func_depth--;
+ 	freefunc(func);
+ 	freeparam(&shellparam);
+ 	shellparam = saveparam;
+-- 
+2.35.6
+
meta/recipes-core/busybox/busybox_1.38.0.bb +1 -0
index 108839e..2c0b415 100644
@@ -62,6 +62,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
            file://CVE-2026-38752.patch \
            file://CVE-2026-38753.patch \
            file://CVE-2026-38754.patch \
+           file://CVE-2026-38755.patch \
            "
 SRC_URI:append:libc-musl = " file://musl.cfg"
 SRC_URI:append:x86-64 = " file://sha_accel.cfg"
Signature · 1 line
2.35.6
#3 lore raw
In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)
Quoted 9 lines · On Thu Nov 5, 2026 at 7:34 AM GMT, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…

From: Darsh Kelaiya <[email protected]>

This patch applies the upstream fix shown in [1]. The advisory identifying the fix is referenced in [2].

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

Hi Darsh,

The patches here have been submitted to busybox but have not received any upstream review. Can you point to any evidence that these are good, e.g. other distros taking these patches?

TBH I wonder how this is even a CVE issue. As busybox isn't a CNA, and their patch review process is known to be slow, it's very easy for someone to just file nonsense CVE reports.

A stack overflow in the evaluate() function (editors/awk.c) of BusyBox commit 371fe9 allows attackers to cause a Denial of Service (DoS) via supplying a crafted AWK script.

If you can supply your own AWK script, you could just run:

    BEGIN { while (1) print "looping..." }

Or some other misbehaviour. Bug, yes. Security bug? I don't see how.

Please step back and do some analysis, I don't think trying to play whack-a-mole on every CVE report is sustainable.

Best regards,

Signature · 1 line
Paul Barker
#4 lore raw

Hi Paul,

Thanks for the feedback. I checked the downstream package sources. All three June patches are carried by:

* Debian BusyBox 1:1.38.0-3 [1].
* Ubuntu 26.10 BusyBox 1:1.38.0-3ubuntu4 , inherited from Debian [2].
* openSUSE Factory, where they were added on 26 August [3].

For CVE-2026-38752, the researcher also published a reproducer and selected ASan/GDB results [4].

Your point about the threat model is fair. For the AWK and shell recursion cases, I have not established a security impact beyond the capabilities already available to an attacker supplying executable scripts.

There is also a completeness concern with CVE-2026-38753. During the upstream discussion, the author acknowledged that the original patch was too narrow and planned a broader fix [5]. The downstream packages still carry that original implementation.

I’ll reassess the security impact and completeness of these fixes before following up on the series.

[1] https://sources.debian.org/data/main/b/busybox/1%3A1.38.0-3/debian/patches/series ( https://sources.debian.org/data/main/b/busybox/1%3A1.38.0-3/debian/patches/series )
[2] [ubuntu/stonking-proposed] busybox 1:1.38.0-3ubuntu1 (Accepted) ( https://lists.ubuntu.com/archives/stonking-changes/2026-August/005912.html )
[3] https://api.opensuse.org/public/source/openSUSE:Factory/busybox/busybox.spec?rev=99 ( https://api.opensuse.org/public/source/openSUSE:Factory/busybox/busybox.spec?rev=99 )
[4] https://hy38.github.io/cves/cve-2026-38752-busybox-awk-recursion-stack-overflow/ ( https://hy38.github.io/cves/cve-2026-38752-busybox-awk-recursion-stack-overflow/ )
[5] https://lists.busybox.net/pipermail/busybox/2026-July/092395.html ( https://lists.busybox.net/pipermail/busybox/2026-July/092395.html )

Regards,
Darsh

Quoted 41 lines · Paul Barker
Quoted 9 lines · On Thu Nov 5, 2026 at 7:34 AM GMT, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…

From: Darsh Kelaiya <[email protected]>

This patch applies the upstream fix shown in [1]. The advisory identifying the fix is referenced in [2].

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

Hi Darsh,

The patches here have been submitted to busybox but have not received any upstream review. Can you point to any evidence that these are good, e.g. other distros taking these patches?

TBH I wonder how this is even a CVE issue. As busybox isn't a CNA, and their patch review process is known to be slow, it's very easy for someone to just file nonsense CVE reports.

A stack overflow in the evaluate() function (editors/awk.c) of BusyBox commit 371fe9 allows attackers to cause a Denial of Service (DoS) via supplying a crafted AWK script.

If you can supply your own AWK script, you could just run:

BEGIN { while (1) print "looping..." }

Or some other misbehaviour. Bug, yes. Security bug? I don't see how.

Please step back and do some analysis, I don't think trying to play whack-a-mole on every CVE report is sustainable.

Best regards,

--
Paul Barker