smolagents has Sandbox Escape Vulnerability in the local_python_executor.py Module
The local Python executor in smolagents 1.14.0 did not properly restrict code execution, so an attacker could use whitelisted modules and functions to run arbitrary code on the host. This allowed remote code execution and undermined the sandbox boundary.
huggingface/smolagents
Originally disclosed on huntr
A sandbox escape vulnerability was identified in huggingface/smolagents version 1.14.0, allowing attackers to bypass the restricted execution environment and achieve remote code execution (RCE). The vulnerability stems from the local_python_executor.py module, which inadequately restricts Python code execution despite employing static and dynamic checks. Attackers can exploit whitelisted modules and functions to execute arbitrary code, compromising the host system. This flaw undermines the core security boundary intended to isolate untrusted code, posing risks such as unauthorized code execution, data leakage, and potential integration-level compromise. The issue is resolved in version 1.17.0.
From the GitHub Advisory Database (GHSA-6v92-r5mx-h5fx, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the allow-list of modules and functions was too permissive, so combinations of otherwise permitted calls could reach dangerous functionality and escape the sandbox.
Impact
An attacker could execute arbitrary code on the host, leading to data leakage and potential compromise of integrated systems.
What the attacker needed
Ability to run untrusted code in smolagents
The fix
The issue was fixed in version 1.17.0.
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 report has not been written yet. The Original tab links to the source.
A sandbox is meant to run untrusted code safely, like a playpen. Here the playpen had gaps: some allowed Python modules and functions could be combined to run commands outside the playpen. That means someone could take over the machine running the code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.