CVE-2025-5120: smolagents has Sandbox Escape Vulnerability in the local_python_executor.py Module
The LocalPythonExecutor in Hugging Face smolagents 1.14.0 can be escaped by agent-generated code, giving arbitrary code execution on the host. The flaw lets code reach restricted modules through whitelisted functions. The package data lists all versions below 1.17.0 as vulnerable. Upgrade to smolagents 1.17.0.
Published Jul 27, 2025 · Updated Aug 7, 2025 · Analysis Nov 1, 2026
What an attacker can do
smolagents agents write Python and run it in LocalPythonExecutor (local_python_executor.py), which tries to confine that code with static checks and an allowlist of imports and functions. The advisory says these checks are not enough. Attackers can use whitelisted modules and functions to reach code the sandbox should block and execute arbitrary commands on the host.
The fix commit shows one route. Modules reached indirectly were not caught, for example by passing getattr to map or filter. The fix adds a check on return values that rejects module objects whose names are not authorized. The commit's new test uses list(map(getattr, [warnings], ['sys'])) as an example that must now raise 'Forbidden access to module: sys.'
The attacker does not need to touch the host. They only need to influence the code the agent writes, usually by a prompt, a web page, a document or tool output the agent processes. The CVSS vector says no login or user interaction, and changed scope. Once the sandbox is escaped, the attacker runs with the agent process's rights and can read environment variables, API keys and files, and move on to the rest of the system.
Who is affected
The advisory names smolagents 1.14.0, and the package data lists all versions below 1.17.0. The risk applies to agents that run model-written code with the default local executor, especially when the agent reads untrusted input from the web, files or users.
pip show smolagentssmolagents
- Ecosystem
- PyPI
- Affected
- < 1.17.0
- Fixed in
- 1.17.0
- Check
pip show smolagents
How to fix it
Upgrade to smolagents 1.17.0.
pip install --upgrade "smolagents>=1.17.0"The fix commit, 33a942e, adds check_safer_result and safer_func and wraps static tools so their return values are validated. The sources give no other workaround. A local executor is a best-effort filter, not a security boundary, so for untrusted input run agent code in an isolated environment such as a container or a remote sandbox, with minimal credentials.
How to tell if you were hit
Review agent logs for generated code that uses getattr, __import__, __spec__, map or filter to reach modules such as os, sys or subprocess, or for the error text 'Forbidden access to module' on a patched version. On the host, look for child processes spawned by the Python agent process, outbound connections to unfamiliar hosts, and new files written by the agent user. Check which untrusted content the agent read before the suspicious run. If the agent is also driven from a coding assistant, Beam can record shell commands and file access for review.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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.
Questions
- Is smolagents 1.17.0 safe from CVE-2025-5120?
It is the version where the advisory says the issue is resolved. Newer sandbox escapes may be found in future, so treat LocalPythonExecutor as a filter and isolate agents that process untrusted input.
- Does the attacker need to log in?
No. The CVSS vector shows no privileges and no user interaction. The attacker needs to influence the code the agent generates, such as through content the agent reads.
- Is CVE-2025-5120 exploited in the wild?
The sources we read do not say so, and it is not in the CISA catalog data we hold. The EPSS score is high, near the 98th percentile.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More smolagents vulnerabilities
All smolagents entriesCVE-2026-4963
Hugging Face Smolagents has an Injection issue
low6.3No fixMar 27, 2026CVE-2026-2654
Hugging Face Smolagents has a Server-Side Request Forgery issue
low6.3No fixFeb 18, 2026CVE-2025-14931
Hugging Face smolagents: Unsafe deserialization in Remote Python Executor leads to RCE
critical10.0No fixDec 23, 2025CVE-2025-11844
Hugging Face Smolagents XPath injection vulnerability in the search_item_ctrl_f function
medium5.4Oct 22, 2025
