CVE-2025-11844: Hugging Face Smolagents XPath injection vulnerability in the search_item_ctrl_f function
Hugging Face smolagents 1.20.0 builds an XPath query in search_item_ctrl_f (vision_web_browser.py) by pasting input straight into the expression, so a crafted string can change the query. Attackers can steer what the browsing agent finds on a page. Fixed in smolagents 1.22.0.
Published Oct 22, 2025 · Analysis Nov 1, 2026
What an attacker can do
search_item_ctrl_f in src/smolagents/vision_web_browser.py is a tool the vision web-browsing agent uses to find text on a page. It built the query as //*[contains(text(), '{text}')] with the text inserted raw. A value containing a single quote closes the string literal, and the rest becomes XPath syntax.
The text can come from the model, which in turn may be steered by page content or a user prompt. An attacker who controls a page the agent visits, or the task it is given, can plant text that makes the agent send an injected string. The result is a query that matches elements the author did not intend. The advisory lists these consequences: bypassing search filters, reaching unintended DOM elements, disrupting automation, and, in turn, information disclosure and manipulation of agent interactions.
This is not code execution. XPath here only selects elements in the page the browser already loaded. The CVSS 3.0 vector (user interaction, low confidentiality and integrity impact) matches that limited reach. The damage grows if the agent acts on what the query returns, for example clicking or typing into the wrong element.
Who is affected
smolagents on PyPI before 1.22.0; the advisory names 1.20.0 as containing the flaw. Only code that uses the vision web browser tooling (vision_web_browser.py, with Selenium) is exposed.
pip show smolagentsSearch your project for imports from smolagents.vision_web_browser or use of search_item_ctrl_f.
smolagents
- Ecosystem
- PyPI
- Affected
- < 1.22.0
- Fixed in
- 1.22.0
- Check
pip show smolagents
How to fix it
Upgrade to smolagents 1.22.0:
pip install --upgrade smolagents==1.22.0The fix commit adds a helper, _escape_xpath_string, that returns a valid XPath literal: single quotes if the text has no single quote, double quotes if it has no double quote, and a concat() expression if it has both. search_item_ctrl_f now uses contains(text(), {escaped_text}). The commit also adds tests with injection payloads in tests/test_vision_web_browser.py.
The sources name no workaround. Until you upgrade, restrict the agent to pages you trust.
How to tell if you were hit
Check agent logs and tool-call traces for search_item_ctrl_f arguments that contain quotes, ], or, | or other XPath syntax. Compare what the agent was asked to find with what the query returned. Run pip show smolagents across environments to find 1.20.0 through 1.21.x installs. Unexpected clicks or page interactions after a search call can point to a manipulated query.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Hugging Face Smolagents version 1.20.0 contains an XPath injection vulnerability in the search_item_ctrl_f function located in src/smolagents/vision_web_browser.py. The function constructs an XPath query by directly concatenating user-supplied input into the XPath expression without proper sanitization or escaping. This allows an attacker to inject malicious XPath syntax that can alter the intended query logic. The vulnerability enables attackers to bypass search filters, access unintended DOM elements, and disrupt web automation workflows. This can lead to information disclosure, manipulation of AI agent interactions, and compromise the reliability of automated web tasks. The issue is fixed in version 1.22.0.
Questions
- Does this XPath injection allow code execution?
The advisory does not claim it. It lets an attacker change which page elements the query matches, which can disclose information or mislead the agent. The query runs against the page already loaded in the browser.
- Which smolagents version fixes CVE-2025-11844?
1.22.0. The advisory names 1.20.0 as containing the flaw, and the data lists everything before 1.22.0 as vulnerable.
- Am I affected if I don't use the vision web browser?
The flaw is in search_item_ctrl_f in vision_web_browser.py. If your agents never use that module, the vulnerable function is not called.
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-5120
smolagents has Sandbox Escape Vulnerability in the local_python_executor.py Module
critical9.9Jul 27, 2025
