[packages/busybox] Rel 3. Fix ash out-of-bounds read of the unset MAIL variable

arekm arekm at pld-linux.org
Thu Oct 29 09:41:25 CET 2026


commit 0620ae0ff78e7d6fe598a8c249e22d25dfc3111d
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Oct 29 07:20:30 2026 +0100

    Rel 3. Fix ash out-of-bounds read of the unset MAIL variable

 busybox-ash-MAIL-oob-read.patch | 79 +++++++++++++++++++++++++++++++++++++++++
 busybox.spec                    |  5 ++-
 2 files changed, 83 insertions(+), 1 deletion(-)
---
diff --git a/busybox.spec b/busybox.spec
index bb25ce1..16e132d 100644
--- a/busybox.spec
+++ b/busybox.spec
@@ -35,7 +35,7 @@ Summary(pl.UTF-8):	Zestaw narzędzi uniksowych dla systemów wbudowanych
 Summary(pt_BR.UTF-8):	BusyBox é um conjunto de utilitários UNIX em um único binário
 Name:		busybox
 Version:	1.38.0
-Release:	2
+Release:	3
 License:	GPL v2
 Group:		Applications
 Source0:	https://www.busybox.net/downloads/%{name}-%{version}.tar.bz2
@@ -75,6 +75,8 @@ Patch30:	%{name}-CVE-2026-108119.patch
 # local backports, no upstream or distro fix available
 Patch31:	%{name}-CVE-2026-88833.patch
 Patch32:	%{name}-CVE-2026-88838.patch
+# upstream 5eee8017a8: ash reads past the unset MAIL literal (stats ./MAILPATH before each prompt)
+Patch33:	%{name}-ash-MAIL-oob-read.patch
 # No fix available (upstream, Debian, SUSE, Fedora) for CVE-2026-88829
 # (httpd proxy auth and pipelining) and CVE-2026-90954 (dpkg-deb ar link flush).
 URL:		https://www.busybox.net/
@@ -244,6 +246,7 @@ Statycznie skonsolidowany busybox dla initrd.
 %patch -P30 -p1
 %patch -P31 -p1
 %patch -P32 -p1
+%patch -P33 -p1
 
 %build
 install -d built
diff --git a/busybox-ash-MAIL-oob-read.patch b/busybox-ash-MAIL-oob-read.patch
new file mode 100644
index 0000000..4edca26
--- /dev/null
+++ b/busybox-ash-MAIL-oob-read.patch
@@ -0,0 +1,79 @@
+From 5eee8017a827659b6fb9e29ab1241eb4227c56f7 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux at googlemail.com>
+Date: Thu, 22 Oct 2026 07:31:22 +0200
+Subject: [PATCH] ash: do not read past the text of an unset MAIL
+
+Patch by Florian Schmaus <florian.schmaus at codasip.com>:
+
+ash stores each variable as a single "NAME=value" string in var_text,
+and accessor macros like mailval() simply skip over the "NAME=" prefix
+(var_text + 5). Per the comment above them, they return the null
+string for unset variables. That only works if an unset variable's
+text still has a NUL where the value would start.
+
+MAIL and MAILPATH are unset by default, and their initial texts are
+"MAIL" and "MAILPATH". For "MAIL" (5 bytes including the NUL)
+mailval() therefore points one byte past the end of the string. When
+MAILPATH is not set, chkmail() falls back to mailval() and hands that
+pointer to padvance_magic(), which parses the memory following "MAIL"
+as a colon-separated list of mail files. This happens before every
+interactive prompt, unless the user sets MAIL or MAILPATH.
+
+What gets read there depends on the binary layout. In an x86_64
+defconfig build "MAIL" is directly followed by "MAILPATH", so ash
+stat()s ./MAILPATH before every prompt and prints "you have mail"
+when a file of that name in the current directory changes. This
+stat() of ./MAILPATH was already noticed in 2016 [1], and the
+overread itself was recently reported after fuzzing ash with
+AddressSanitizer [2].
+
+The texts used to be "MAIL\0" and "MAILPATH\0", as they still are in
+dash. Commit 8837c5dec402 ("ash: remove one redundant function,
+improve string sharing, better field names") dropped the extra NUL
+from all unset-by-default variables, so the literals become plain
+strings the compiler can put in mergeable string sections. That is
+fine for RANDOM, LC_ALL, LC_CTYPE and HISTFILE, whose values are only
+read through lookupvar(), which checks VUNSET. But mailval() is
+used without such a check.
+
+Fix the out-of-bounds read by restoring the trailing NULs for MAIL
+and MAILPATH, so that mailval() and mpathval() again yield "" for an
+unset variable. This matches setvar(), which already allocates a
+zeroed buffer of name length + 2 when unsetting a variable at
+runtime. MAILPATH is not strictly affected, since mpathval() is only
+used after mpathset(), but this keeps both accessors consistent.
+Neither literal is shared with any other string, so the cost is two
+bytes of .rodata:
+
+function                                             old     new   delta
+.rodata                                           102098  102100      +2
+
+We ran into this on a CHERI [3, 4] system. CHERI's architectural
+capabilities bound each memory region precisely, so it catches
+out-of-bounds accesses that MMU-based protection misses. Here the
+one-byte overread of the "MAIL" string literal is a capability length
+violation, and every interactive ash dies with SIGSEGV on start-up.
+
+1: https://github.com/gliderlabs/docker-alpine/issues/163
+2: https://github.com/vda-linux/busybox_mirror/issues/47
+3: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
+4: https://codasip.com/solutions/riscv-processor-safety-security/cheri/
+
+Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
+Rebased on PLD busybox-ash-export-PATH.patch; comment-only hunks dropped.
+---
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -2302,8 +2302,10 @@
+ 	 */
+ 	{ VSTRFIXED|VTEXTFIXED       , defifsvar   , NULL            },
+ #if ENABLE_ASH_MAIL
+-	{ VSTRFIXED|VTEXTFIXED|VUNSET, "MAIL"      , changemail      },
+-	{ VSTRFIXED|VTEXTFIXED|VUNSET, "MAILPATH"  , changemail      },
++	// Two NULs are necessary since mailval()/mpathval() use var_text+5/+9
++	// to skip over var name and '=' sign (if variable is set).
++	{ VSTRFIXED|VTEXTFIXED|VUNSET, "MAIL\0"    , changemail      },
++	{ VSTRFIXED|VTEXTFIXED|VUNSET, "MAILPATH\0", changemail      },
+ #endif
+ 	{ VSTRFIXED|VTEXTFIXED|VEXPORT, bb_PATH_root_path, changepath },
+ 	{ VSTRFIXED|VTEXTFIXED       , "PS1=$ "    , NULL            },
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/busybox.git/commitdiff/0620ae0ff78e7d6fe598a8c249e22d25dfc3111d



More information about the pld-cvs-commit mailing list