CSCTF 2026 · Misc · 342 pts
warden.
An audit hook blocks every import, exec and file open — but reading an attribute, calling a function, and writing to a file descriptor directly never raise an audited event at all.
| Event | CSCTF 2026, Operation Dawn (online jeopardy) |
|---|---|
| Category | Misc |
| Points | 342 |
| Status | Solved during the event |
| Target | Live TCP service |
TL;DR. The jail's audit hook kills the process on any audited event except a plain attribute read and the jail's own single permitted `exec` call — but ordinary attribute access, dict lookups, list comprehensions, and plain function calls don't raise *any* audit event in CPython at all. Walking `object.__subclasses__()` to find an already-imported stdlib class gives access to `sys.modules['os']` without ever triggering an `import` event, and `os.write()` dumps the environment without triggering an `open` event either.
Challenge
Read a secret from a live Python one-liner jail whose audit hook kills the process on almost every suspicious action.
First look
Reading the jail's source (never executing it locally against anything but a local simulation) shows its sys.addaudithook callback allows exactly two things: object.__getattr__ events (attribute reads), and one single exec event — the jail's own call that runs the submitted line in an empty-builtins namespace. Every other audited event — import, open, a second exec, subprocess, and so on — triggers an immediate os._exit.
Solution
The key realization, confirmed first in a local simulation of the jail's own check logic with a fake FLAG environment variable: plain attribute access, dictionary item access and in, list comprehensions, and ordinary function calls (like .items(), .encode(), .join(), or os.write()) don't raise any audit event in CPython at all — the hook was only ever going to catch a narrow, named list of dangerous operations, not general code execution.
Starting from the empty tuple literal () (always available even with empty builtins), ().__class__.__base__.__subclasses__() walks every currently-loaded subclass of object — entirely via attribute reads and a method call, triggering no audited event. One of those subclasses, _wrap_close, is defined inside the standard library's os module, which is always already imported by the Python runtime itself. Its __init__.__globals__ dictionary — again, a pure attribute and dict read — contains a live reference to the already-imported sys module, and sys.modules['os'] then hands over the real, cached os module, with none of this ever triggering an import event (nothing was ever actually imported; everything was already loaded).
os.write(1, ...) writes bytes directly to file descriptor 1 without triggering the open audit event the hook does watch for. The final one-line payload:
O=[x for x in ().__class__.__base__.__subclasses__() if x.__name__=='_wrap_close'][0].__init__.__globals__['sys'].modules['os'];O.write(1,b''.join([(k+'='+v).encode()+b'\n' for k,v in O.environ.items()]))dumps the full environment, including the flag, directly over the socket.
Flag
CSCTF{qm60GvJjw8DuNMdISxkYe3kv}What I took from it
- An audit hook built as a list of specifically forbidden events is only as complete as that list — plain attribute reads, dict access, comprehensions and ordinary function calls raise no audit event in CPython at all, and the full subclass graph of already-loaded modules is reachable through nothing but those operations.