CSCTF 2026 · Crypto · 200 pts
Countersign.
A naive `SHA256(key || message)` MAC lets you append your own command to someone else's signed message without ever knowing the key.
| Event | CSCTF 2026, Operation Dawn (online jeopardy) |
|---|---|
| Category | Crypto |
| Points | 200 |
| Status | Solved during the event |
| Target | Assigned live container |
TL;DR. The grid dispatch console authenticates messages with `tag = SHA256(key || message)` — a textbook-insecure MAC construction. Given one valid signed STATUS message, a length-extension attack appends an attacker-chosen `&cmd=DISPATCH` parameter (the field the server treats as 'last value wins') and produces a valid tag for the extended message, without ever recovering the key.
Challenge
Forge a privileged DISPATCH command from a signed STATUS message, over a message-authentication scheme of unknown construction.
Solution
The signed message has the form station=CORRIDOR-3&cmd=STATUS&ts=...&nonce=..., authenticated with a tag. Testing it against the classic insecure construction, tag = SHA256(key || message), confirms the console is vulnerable to SHA-256's length-extension property: because SHA-256 processes data in fixed-size blocks and its internal state after hashing any prefix is exactly the state the next block continues from, you can compute a valid hash for key || message || padding || extension without ever knowing key, as long as you know the message and its (unknown) length.
Brute-forcing the unknown key length (tried 8 through 32 bytes) and appending &cmd=DISPATCH — the server treats a duplicated query parameter as "last value wins", so the appended copy overrides the original cmd=STATUS — produces a forged message plus a valid tag for it at the correct key length, using the hashpumpy library for the length-extension computation itself (a hand-rolled implementation had a bug; the vetted library didn't).
Flag
CSCTF{EVjCNuebzpSnsTT4P8XYPXfW}What I took from it
- SHA-256 (and any other Merkle–Damgård hash) must never be used as `H(key || message)` for authentication — its length-extension property lets an attacker append arbitrary data to a signed message and compute a valid tag for the extended version without ever learning the key.