How I Found a Critical RCE Flaw in a Popular JS Sandbox
Exposed JavaScript source maps revealed a custom sandbox that used regex blacklisting and the Function constructor, allowing an attacker to escape the sandbox and execute arbitrary system commands. This led to the exposure of over 230 environment variables including cloud keys and database credentials.
Findingsecurity flaws in popular bug bounty programs can feel impossible sometimes.
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 sandbox relied on regex blacklisting and the Function constructor with a with statement, which can be bypassed to access the global object and require arbitrary modules.
Impact
An attacker could read sensitive data, execute arbitrary system commands, move to other systems, and deploy malicious software; the text claims full RCE was achieved.
What the attacker needed
Access to the workflow builder; exposed source maps; directory listing enabled
The fix
The issues were patched within days, but the fix was incomplete as it only blacklisted keywords from the original payload, and the sandbox escape remained possible with slight modifications.
How it was found
- Find exposed .js.map files via directory listing.
- Use sourcemapper to reconstruct the original TypeScript code.
- Identify the sandboxedEval function using regex blacklist and new Function with with statement.
- Craft a payload to access the global object and the require function.
- Use require to load child_process and execute a command to read environment variables.
- Observe over 230 environment variables including secrets.
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 sandbox is a security mechanism that tries to run untrusted code safely, but here it was built with weak checks. The attacker found the original code through exposed source maps, then used JavaScript tricks to break out and run commands on the server, stealing secrets like passwords and API keys.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.