CVE-2026-99843: userns: don't drop the exec securebits
In the Linux kernel, the following vulnerability has been resolved:
userns: don't drop the exec securebits
SECBITEXECRESTRICTFILE and SECBITEXECDENYINTERACTIVE tell script interpreters to only run what ATEXECVECHECK allows and to refuse interactive input. A service manager sets them together with their lock bits so that nothing below it can turn them off again.
But setcreduserns() resets all securebits to SECUREBITSDEFAULT. So any task that can create a user namespace sheds the locked exec bits with a single unshare(CLONENEWUSER) and joining one with setns() does the same. The lock is pointless if anyone who may create a user namespace can drop it, and that is pretty much everyone.
Resetting the other bits is fine. They are about how capabilities are computed and a new user namespace starts out with a full set of capabilities anyway. The exec bits grant nothing though. They are restrictions a task placed on itself, just like nonewprivs which a user namespace doesn't touch either. So keep them and their locks.
Reproducer:
// SPDX-License-Identifier: GPL-2.0 / Lock the exec securebits, then create a user namespace and look at them again. / #define GNUSOURCE #include <sched.h> #include <stdio.h> #include <sys/prctl.h>
#define SECBITEXECRESTRICTFILE (1 << 8) #define SECBITEXECRESTRICTFILELOCKED (1 << 9) #define SECBITEXECDENYINTERACTIVE (1 << 10) #define SECBITEXECDENYINTERACTIVELOCKED (1 << 11)
int main(void) { int bits = SECBITEXECRESTRICTFILE | SECBITEXECRESTRICTFILELOCKED | SECBITEXECDENYINTERACTIVE | SECBITEXECDENYINTERACTIVELOCKED;
if (prctl(PRSETSECUREBITS, bits, 0, 0, 0)) { perror("PRSETSECUREBITS"); return 1; } printf("before: 0x%x\n", prctl(PRGETSECUREBITS, 0, 0, 0, 0)); printf("clear locked bits: %s\n", prctl(PRSETSECUREBITS, 0, 0, 0, 0) ? "refused" : "ALLOWED");
if (unshare(CLONENEWUSER)) { perror("unshare(CLONENEWUSER)"); return 1; } printf("after unshare(CLONENEWUSER): 0x%x\n", prctl(PRGETSECUREBITS, 0, 0, 0, 0)); return 0; }
On v7.1 this prints "before: 0xf00", "clear locked bits: refused" and "after unshare(CLONENEWUSER): 0x0". With this patch the last line reads 0xf00 as well.