RCE via Insecure JS Sandbox Bypass
A deployment misconfiguration exposed JavaScript source maps, which revealed a custom 'sandboxed' JavaScript evaluator built on new Function and with() plus weak regex filtering. An attacker could submit crafted JavaScript in the platform's workflow builder to escape the sandbox and run OS commands on the server, exposing environment variables and secrets.
Published on medium.com
If you want to find more bugs, focus on applications or features that are less tested. In the bug bounty world, most popular programs are already tested multiple times using standard methodologies.
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 new Function and with() for execution while filtering dangerous strings with regexes, which is trivially bypassed and gives access to the global object and Node.js internals.
Impact
An attacker could run arbitrary commands on the backend server and read all environment variables, including cloud, source-control, AI and payment credentials, enabling lateral movement and further compromise.
What the attacker needed
Access to the workflow builder feature; ability to save custom JavaScript in a flow
The fix
The vendor patched it, but the author later bypassed the fix because only keywords were blacklisted; the recommended fix was to stop in-process evaluation and use a hardened sandbox such as isolated-vm or a separate isolated container without secrets.
How it was found
- Find exposed directory listing and download the JavaScript source map files
- Reconstruct the original source code from the maps and review it
- Locate the sandboxedEval function and identify the weak sanitisation
- Map the feature to the visual flow builder that runs custom JavaScript
- Insert a crafted script that reaches the global object and Node.js require
- Run an OS command and observe the environment variables in the output
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.
The platform let users write small JavaScript snippets inside a visual workflow builder, and it tried to run them safely by blocking a few dangerous words. The blocking was easy to get around, so a user could break out of the pretend 'safe box' and run commands on the company's server itself. That let them read the server's secret settings, such as cloud and payment keys.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.