GraphQL RCE: The Kill Chain to Cloud Identity…!
A custom Python function feature executed user-supplied code in a sandbox that failed to remove Python's built-in functions, allowing arbitrary command execution. The attacker then read backend source code and fetched a Google Cloud OIDC identity token from the metadata service, obtaining the production service account identity.
Imagine this: You’re logged into a modern SaaS platform…It’s sleek, it’s fast, and it has one killer feature — Custom Python Functions…To a regular user, it’s a productivity tool…To a hunter, it’s a doorway…!
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
The sandbox executed user code with Python's exec() but did not clear the __builtins__ dictionary, so dangerous built-ins like __import__ remained available.
Impact
An authenticated user could run arbitrary commands, steal backend source code, reach internal cloud services, and obtain the production service account identity token.
What the attacker needed
A logged-in user account; access to a workspace and app; ability to create custom functions
The fix
The sandbox should clear __builtins__ when calling exec(), block the metadata IP from user-code environments, and run user code in isolated micro-VMs.
How it was found
- Enumerate the user's workspaces, folders and apps through a GraphQL query to obtain a workspace ID and app ID.
- Create a user-defined Python function through the createUserDefinedFunction mutation.
- Trigger the function through the evalFormula mutation to execute the Python code.
- Use the subprocess module to read the server's main.py and inspect the sandbox logic.
- Create and trigger a function that requests the Google Cloud metadata service to obtain an OIDC identity token.
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 app let users write small Python scripts to power spreadsheet-like formulas. It tried to run them in a restricted 'sandbox', but forgot to block Python's built-in tools such as importing other modules. That let the author run system commands, read server files, and ask the cloud provider for the server's own identity token.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.