Skip to main content
SkillTotal

Is smolagents safe?

What smolagents does

smolagents is a Python library from Hugging Face for building AI agents. It includes CodeAgent, which writes its actions as Python code. The PyPI author field lists Aymeric Roucher, and the code lives in huggingface/smolagents. Its agents work with local or hosted models, use tools from MCP servers, LangChain or Hub Spaces, and can push and pull tools and agents on the Hugging Face Hub. The README says the built-in LocalPythonExecutor is not a security sandbox. Before installing, set up one of the supported sandboxes for agent code: E2B, Blaxel, Modal or Docker.

Low risk - review the findings before installing
Notable — review in context (a capability is not a malicious indicator):
  • Unsafe deserialization
  • Python shell/command execution
  • Python dynamic code execution

What to do: Nothing here argues against installing it. Grant the capabilities it lists only if you expect the tool to need them.

smolagents is a PyPI package analyzed by SkillTotal's deterministic static scanner. The scan found no malicious indicators, though 1 risky construct is reported for review. It can: dynamic code execution, filesystem read, filesystem write, mcp tools detected, network egress and shell execution — capabilities are what the code can do, not a verdict on intent. Risk score 20/100 (low).

smolagents 1.26.0

PyPI package · pypi:smolagents
LOW
20
/ 100 risk score
Snapshot · scanned Nov 21, 2026 · smolagents@1.26.0 · engine 1.8.0 / ruleset 107

Get notified when this component changes

Change alerts aren't live yet. Leave your email and we'll let you know when they launch. We use it only for this and delete it on request.

Automated static-analysis result. It can contain false positives and false negatives, and is not a claim about the intent of smolagents's authors. Report a false positive.

Capabilities — what this component can do (not a risk score):
dynamic code executionfilesystem readfilesystem writemcp tools detectednetwork egressshell execution

Behavioral traits

How this component maps to the CSA agentic threat model. Descriptive — it never affects the risk score.

Tool surface
Tool Usage
Execution authority
Tool Access Control / Direct Tool Access
Filesystem reach
Tool Execution Context
Network egress
Interaction & Communication / Direct Communication
Unsafe deserialization
General Protections / Input Validation

Findings (7)

HIGHUnsafe deserializationST-DESERIALIZE-PY

It loads data with a format that can rebuild arbitrary objects (e.g. pickle, or unsafe YAML).

return pickle.loads(base64.b64decode(encoded_value[7:]))
return pickle.loads(base64.b64decode(data[7:]))
return pickle.loads(base64.b64decode(data))

Why it matters: Feeding such a loader untrusted data can execute code hidden inside that data.

Fix: Deserialize untrusted data with a safe format/loader: JSON, or yaml.safe_load / Loader=SafeLoader. Reserve pickle/marshal for data you fully control.

CapabilityPython dynamic code executionnot scored · severity highST-DYN-PY

The code turns strings into live code at runtime (eval / new Function / exec).

exec(tool_code, module.__dict__)

Why it matters: If those strings aren't fixed and trusted, they become a way to run arbitrary code.

Fix: Avoid evaluating dynamically constructed code; if unavoidable, ensure the input is a trusted constant and never derived from external data.

CapabilityPython shell/command executionnot scored · severity highST-SHELL-PY

The component can run operating-system commands or spawn processes.

subprocess.run([deno_path, "--version"], capture_output=True, check=True)
self.server_process = subprocess.Popen(
            cmd,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            text=True,
        )

Why it matters: Powerful and often legitimate — confirm the commands aren't built from untrusted input.

Fix: Confirm the command and its arguments are fully controlled and not derived from untrusted input; avoid shell=True.

CapabilityPython filesystem readnot scored · severity mediumST-FS-PY-READ

The component reads files from disk.

agent_dict = json.loads((folder / "agent.json").read_text())
tool_code = (folder / "tools" / f"{tool_name}.py").read_text()
importlib.resources.files("smolagents.prompts").joinpath("toolcalling_agent.yaml").read_text()
importlib.resources.files("smolagents.prompts").joinpath("structured_code_agent.yaml").read_text()
importlib.resources.files("smolagents.prompts").joinpath("code_agent.yaml").read_text()
tool_code = Path(tool_file).read_text()

Why it matters: Usually legitimate, but worth confirming it can't be steered into reading sensitive files.

Fix: Confirm which files are read and that paths cannot be influenced by untrusted input to reach sensitive locations.

CapabilityPython filesystem write/deletenot scored · severity mediumST-FS-PY-WRITE

The component writes or deletes files on disk.

with open(os.path.join(output_dir, "prompts.yaml"), "w", encoding="utf-8") as f:
with open(os.path.join(output_dir, "agent.json"), "w", encoding="utf-8") as f:
with open(os.path.join(output_dir, "requirements.txt"), "w", encoding="utf-8") as f:
with open(os.path.join(output_dir, "app.py"), "w", encoding="utf-8") as f:
shutil.copy(file_path, dest_path)
with open(self.runner_path, "w") as f:
file_path.write_text(content, encoding="utf-8")
with open(os.path.join(folder, "__init__.py"), "w"):

Why it matters: Usually legitimate, but worth confirming the paths can't be controlled by untrusted input.

Fix: Confirm which files are written/deleted and that paths cannot be influenced by untrusted input.

CapabilityPython network egressnot scored · severity mediumST-NET-PY

The component makes outbound network requests.

response = requests.get(self._path)
response = requests.get(base_url, params=params)
response = requests.get(self.endpoint, headers=self.headers, params=params)
response = requests.get(
            "https://lite.duckduckgo.com/lite/",
            params={"q": query},
            headers={"User-Agent": "Mozilla/5.0"},
        )
response = requests.get(
            "https://www.bing.com/search",
            params={"q": query, "format": "rss"},
        )
response = requests.post(
            "https://api.exa.ai/search",
            headers={
                "x-api-key": api_key,
                "Content-Type": "application/json",
                "x-exa-integration": "smolagents", …
from requests.exceptions import RequestException
response = requests.get(url, timeout=20)
response = requests.get(self.server_url)
response = requests.post(self.server_url, json=payload, timeout=self.timeout)
from requests.exceptions import RequestException
r = requests.post(crate_kernel_endpoint, headers=headers)
if requests.get(f"{self.base_url}/api/kernelspecs?token={token}", timeout=2).status_code == 200:
resp = requests.get(f"https://{host}/api/kernelspecs?token={token}")

Why it matters: Usually legitimate, but confirm the destinations are expected and no sensitive data leaves.

Fix: Confirm the destination hosts are expected and that no sensitive data is sent off-host.

CapabilityMCP tool surface detectednot scored · severity lowST-MCP-DETECTED

An MCP tool surface (manifest or tool definitions) was found.

Why it matters: Just context — review which tools it offers and their permissions.

Fix: Review the declared MCP tools and their permissions.

How attackers abuse these capabilities

Interactive labs on the attack class behind the rules above. They show the technique, not anything found in smolagents.

Maintain smolagents?

Check the next package before your agent installs it

The free Claude Code plugin scans each npm, PyPI or MCP package with this report's open-source engine before the install command runs. It runs on your machine and needs no account.

Check your own component

Run the same evidence-backed scan on any MCP server, agent skill, or package.

Scan your own component

How we determine this: deterministic static analysis (regex + AST), evidence-anchored, no code execution. Methodology →