DL·SYS
Contact ↗

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.

SHA-256 length extension
EventCSCTF 2026, Operation Dawn (online jeopardy)
CategoryCrypto
Points200
StatusSolved during the event
TargetAssigned 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

FlagCSCTF{EVjCNuebzpSnsTT4P8XYPXfW}

What I took from it