Breaking the Sandbox : Uncovering a Remote Code Execution Vulnerability in Apigee’s PythonScript Policy
The PythonScript policy in Apigee used Jython and Java permissions to sandbox custom Python code, but the flow object exposed an execution context with a submitTask method that accepted a Runnable. An attacker could submit a Runnable that executed arbitrary OS commands, bypassing the sandbox and achieving remote code execution.
Published on infosecwriteups.com
One of Apigee’s strengths lies in its flexibility, allowing developers to extend API functionality beyond the out-of-the-box features through custom scripts and code. Among the tools available for customization are the JavaCallout, JavaScript, and PythonScript policies, each offering different capabilities depending…
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 PythonScript policy exposed internal Apigee objects (MessageContextImpl and ExecutionContextImpl) whose submitTask method accepted a Runnable, allowing code to run outside the Java sandbox.
Impact
An attacker could execute arbitrary operating system commands on the server hosting the Apigee instance, potentially leading to full compromise.
What the attacker needed
Ability to deploy a PythonScript policy
How it was found
- In a PythonScript policy, inspect the flow object to find its type and available methods.
- Call flow.getExecutionContext() to obtain the execution context object.
- Use Java reflection to list the methods of the execution context and find submitTask.
- Determine that submitTask has an overload accepting a Runnable.
- Create a Runnable that executes a curl command and submit it via submitTask.
- Observe the Canarytoken being triggered, confirming command execution.
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.
Apigee lets developers run small Python scripts inside their API proxies. To keep these scripts safe, it uses Java's security system to block dangerous actions like running system commands. The researcher found that a special object available to the script had a method that could run code outside those restrictions, letting an attacker run any command on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.