
Python proof-of-concept for CVE-2026-3888, exploiting a snap-confine and systemd-tmpfiles race to escalate from a local unprivileged account to root on Linux.
This repository contains a proof of concept for the SUID snap-confine variant of CVE-2026-3888. The project studies how cleanup of snap's private temporary directory can interact with privileged sandbox construction and a filesystem race. It is intended for controlled, disposable Linux test systems where the operator has explicit authorization.
The flaw is local: an attacker needs an unprivileged account on a vulnerable host. Ubuntu describes the issue as snapd mishandling operations in a snap's private /tmp; when systemd-tmpfiles removes that directory, a local user may recreate it and influence later privileged setup. The exploit depends on the affected snapd implementation and the host's cleanup policy, so timing and applicability vary by system. Ubuntu CVE record · Ubuntu security notice USN-8102-1 · Qualys technical analysis
Snap confinement builds a mount namespace before launching an application or hook. Some paths needed by a snap are represented through a writable “mimic” tree under the snap's private temporary directory. In the affected flow, the relevant paths typically resemble /tmp/snap-private-tmp/<snap-instance>/tmp/.snap on the host and /tmp/.snap from inside the snap namespace; exact layout varies. snap-confine uses that tree while constructing bind mounts. systemd-tmpfiles can remove an old .snap tree while the containing sandbox namespace remains relevant. If a user recreates the removed path, filesystem ownership and the privileged setup can become inconsistent.
The race is between the privileged bind-mount setup and replacement of the mimic directory. If the replacement lands at the right point, a later mount can expose user-controlled content at a location used by the snap's runtime. In this variant, the content includes a small ELF program placed at the dynamic-loader path. A subsequent privileged snap-confine execution can then reach that program. This is a check/use race across cleanup, directory recreation, and privileged namespace setup; it is not a network-service exploit.
cve-2026-3888-poc.py implements the stages below in one Python file using only the standard library. The target still needs its own snapd, systemd tools, and compatible installed snap.
snap-confine ownership and setuid mode, file capabilities, the snap's base and library compatibility, the tmpfiles cleanup rule and timer, and the current user's systemd manager. It stops if the host does not match the supported SUID variant or appears patched.snap-confine process keeps the snap's private /tmp namespace available while the cleanup condition is reached. The polling logic checks the parent directory rather than repeatedly accessing .snap, since touching the target can refresh its age and delay cleanup./tmp cleanup age and waits until .snap is absent from the live namespace. The default maximum wait is the configured age plus 15 minutes; --max-wait changes only this timeout, not the host cleanup schedule.renameat2 with RENAME_EXCHANGE to atomically exchange the expected directory with the prepared tree. A post-swap ownership check confirms that the path now resolves to this user's content./bin/bash to the snap's writable common directory and sets the setuid bit. The script verifies that the resulting helper is root-owned and setuid before claiming success.--shell, the temporary helper starts /bin/bash -p; exiting that shell returns to the script, which removes the helper, its marked mimic tree, tracked processes, and cached namespace. Cleanup is best-effort if the process is forcibly killed or the host changes state during the run, so inspect the final output before treating a test as clean./usr/lib/snapd/snap-confine installed as a root-owned setuid executable, without file capabilities./var/snap/<snap-name>/common directory.systemd-run, systemctl, an active systemd-tmpfiles-clean.timer, and an active systemd user manager for the current account.This implementation is deliberately narrow. It rejects root execution, non-x86-64 systems, capability-based snap-confine, incompatible loader/library combinations, missing user scopes, and configurations where the observed vulnerable cleanup condition is absent. The cleanup interval comes from the target's active tmpfiles configuration. The 30-day and 10-day intervals described in the original research are examples of Ubuntu defaults at disclosure time, not assumptions this PoC makes about every host. Qualys analysis
Run as an ordinary account on the test machine. Begin with checks that do not perform the exploit:
python3 cve-2026-3888-poc.py --self-test
python3 cve-2026-3888-poc.py --check --snap <installed-snap-name>
--self-test exercises the generated ELF copier in a temporary directory. --check performs prerequisite checks only. To run the full demonstration, use a disposable snapshot-backed VM that matches the requirements:
python3 cve-2026-3888-poc.py --snap <installed-snap-name>
To request an interactive root shell after the PoC verifies the temporary helper:
python3 cve-2026-3888-poc.py --snap <installed-snap-name> --shell
The script does not shorten the system cleanup interval. A shorter interval for repeatable experiments should be configured only inside a disposable test VM and restored after testing. Do not run the exploit on production systems or systems outside your authorization.
Install the fixed snapd package recommended by the operating-system vendor and follow its restart or reboot instructions. Ubuntu's initial notice lists fixed package versions by release; a follow-up notice records a Noble regression fix, so use the current notice for the exact release rather than copying a version from this README. USN-8102-1 · USN-8102-2