The vulnerability lies in the LocalPythonExecutor component of the smolagents library, which is designed to execute Python code in a sandboxed environment. The core issue is a Server-Side Request Forgery (SSRF) weakness, identified as CVE-2026-2654. The vulnerability is not due to a flaw in a single line of code but rather a design weakness in the sandboxing mechanism.
The LocalPythonExecutor allows developers to specify additional Python libraries that the sandboxed code can import via the additional_authorized_imports parameter. If a developer authorizes the requests library, the sandbox does not enforce any egress filtering or validation on the URLs that can be accessed by requests.get or requests.post. This allows an attacker to craft Python code that, when executed by the LocalPythonExecutor, can make arbitrary HTTP requests from the server.
The primary vulnerable function is LocalPythonExecutor.__call__, which is the entry point for executing the user-provided code. This method, in turn, relies on evaluate_python_code and evaluate_call to parse and execute the code. When the code contains a call to requests.get or requests.post, evaluate_call is responsible for invoking the function, but it does so without any security checks on the target URL.
An attacker can exploit this vulnerability to:
- Probe the internal network and access services that are not exposed to the public internet.
- Access cloud provider metadata services (e.g., AWS EC2 metadata endpoint at
169.254.169.254) to steal temporary credentials and potentially gain control over the cloud environment.
- Exfiltrate sensitive data to an attacker-controlled server.
The provided proof-of-concept clearly demonstrates how to use this vulnerability to make a request to an internal IP address and exfiltrate data. Since there is no patched version available, any application using smolagents version 1.24.0 or older is vulnerable if it configures the LocalPythonExecutor to allow the requests library.