Judge0 Sandbox Escape
Judge0's sandbox could be escaped because the application wrote files outside the sandbox and allowed command injection through newline characters in command-line arguments. An attacker with access to the API could overwrite files on the host and execute commands as root.
Published on tantosec.com
Judge0 is an open source service used to run arbitrary code inside a secure sandbox. The Judge0 website lists 23 clients using the service, with more than 300 self-hosted instances available on the public internet and potentially many more within internal networks.
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
Root cause
Likely the application wrote to a file path inside the sandbox without checking for symbolic links, and it also failed to sanitise newline characters in command-line arguments, allowing shell command injection.
Impact
An attacker could execute arbitrary commands as root on the host, leading to full compromise of the Judge0 instance and potentially the underlying system.
What the attacker needed
Access to Judge0 API; ability to set command_line_arguments; ability to set compiler_options
The fix
The vulnerabilities were fixed in version v1.13.1, which changed the user the application runs as and later addressed the arbitrary file write, though the root cause may still allow other paths.
How it was found
- Submit code with a newline in command_line_arguments to inject a command that creates a symlink named run inside the sandbox directory.
- The symlink points to a target file on the host, such as /usr/local/bin/isolate.
- When Judge0 writes the run script, it follows the symlink and overwrites the target file with attacker-controlled content.
- The overwritten file is executed, running the attacker's payload outside the sandbox.
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.
Judge0 runs untrusted code in a sandbox, a restricted environment. The bug let an attacker trick the service into writing files outside that sandbox, and then overwrite a program that runs with high privileges. This gave the attacker control of the whole machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.