The 42,000 Credit Heist: Finding Zero-Day at 42 Schools
A custom SUID binary passed unsanitised environment variables to a root-privileged Python script, allowing local privilege escalation via PYTHONPATH injection. After gaining root, the author found an admin portal with no authorisation and used it to grant themselves credits.
Recently found a 0day vulnerability in 42 schools network and performed local privilege escalation. Then discovered an unauthorized admin portal and become the richest man in the 42schools.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An unprivileged student could gain root on campus Linux machines, and the exposed admin portal allowed modification of the credit system, though the author states they avoided sensitive data.
What the attacker needed
Local user account on a 42 school Linux machine; ability to run the SUID binary; network access to the admin portal
How it was found
- Enumerate SUID binaries and find /usr/bin/pkgtool.
- Run strace on the binary to observe it execs /opt/pkgtool/pkgtool with inherited environment variables.
- Notice Python 3.10 loads sitecustomize.py and that PYTHONPATH can redirect module loading.
- Create a malicious sitecustomize.py in /tmp that sets UID/GID to 0 and spawns a shell.
- Run the SUID binary with PYTHONPATH=/tmp to obtain a root shell.
- Scan the network, find an admin portal without authorisation, and use it to add credits.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A SUID program runs with the permissions of its owner (here root), so a normal user can briefly act as root. This custom program passed the user's environment variables (settings like PYTHONPATH) to a Python script running as root, letting the user make Python load their own code. Separately, an admin web page had no login check, so anyone who found it could change data.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.