Intermediate·300 points·6 solves
Relay — Insecure Deserialization
Learn insecure deserialization: when a server rebuilds objects from untrusted data using a format like Python pickle, an attacker can make it run arbitrary code during deserialization (RCE).
Relay stores your preferences as base64(pickle(data)) in the `prefs` cookie and calls pickle.loads() on it every request. pickle is not just data — it can reconstruct ANY Python object, and an object's __reduce__ method tells pickle which callable to invoke while rebuilding it. So a crafted cookie whose __reduce__ names, say, subprocess.check_output runs that command inside the server. Relay then renders whatever the cookie deserialized to, so if your payload returns the output of a command, that output (the flag from the environment) is shown straight back. The fix is to never deserialize untrusted input with pickle — use a data-only format like JSON, or sign the cookie and verify it before trusting it.
Your tasks
1
Inspect the cookie
Open the lab; a `prefs` cookie is set. base64-decode it — the bytes start with pickle opcodes (\x80), so it is a Python pickle.
2
Understand the sink
The server calls pickle.loads() on your cookie every request, and renders the result. pickle can run code while rebuilding an object.
3
Build a malicious pickle
Craft an object whose __reduce__ returns a callable + args that run a command — e.g. subprocess.check_output(["sh","-c","echo $FLAG"]).
4
Send it as the cookie
base64-encode your pickle and set it as the `prefs` cookie. On load the command runs and its output is rendered.
5
Capture the flag
The command output on the page contains CLV{...}. Submit it.
Submit the flag
Start the lab, capture the flag from the running machine, and submit it here.