Miggo Logo

CVE-2025-11844: Hugging Face Smolagents XPath injection vulnerability in the search_item_ctrl_f function

5.4

CVSS Score
3.0

Basic Information

EPSS Score
-
Published
10/22/2025
Updated
10/22/2025
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
smolagentspip< 1.22.01.22.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability analysis identified search_item_ctrl_f in src/smolagents/vision_web_browser.py as the vulnerable function. The root cause is the direct and unsafe concatenation of user-provided input (text) into an XPath query. The evidence from the patch is the removal of the line elements = driver.find_elements(By.XPATH, f"//*[contains(text(), \'{text}\')]"), which clearly shows the insecure construction of the XPath expression. An attacker could supply a crafted string like ') or '1'='1 to manipulate the query. The fix involves adding a sanitization function _escape_xpath_string and using it to clean the input before it is included in the query: escaped_text = _escape_xpath_string(text) and elements = driver.find_elements(By.XPATH, f"//*[contains(text(), {escaped_text})]"). When this vulnerability is triggered, the search_item_ctrl_f function would be present in any runtime profile or stack trace, as it is the entry point for the malicious input and the location of the flawed logic.

Vulnerable functions

search_item_ctrl_f
src/smolagents/vision_web_browser.py
The function `search_item_ctrl_f` is vulnerable to XPath injection. It constructs an XPath query by directly embedding the user-provided `text` parameter into the query string without proper sanitization. An attacker can provide a malicious string for the `text` parameter to alter the XPath query's logic, potentially leading to unauthorized data access or other unintended behaviors.

WAF Protection Rules

WAF Rule

*u**in* **** Smol***nts v*rsion *.**.* *ont*ins *n XP*t* inj**tion vuln*r**ility in t** s**r**_it*m_*trl_* *un*tion lo**t** in sr*/smol***nts/vision_w**_*rows*r.py. T** *un*tion *onstru*ts *n XP*t* qu*ry *y *ir**tly *on**t*n*tin* us*r-suppli** input

Reasoning

T** vuln*r**ility *n*lysis i**nti*i** `s**r**_it*m_*trl_*` in `sr*/smol***nts/vision_w**_*rows*r.py` *s t** vuln*r**l* *un*tion. T** root **us* is t** *ir**t *n* uns*** *on**t*n*tion o* us*r-provi*** input (`t*xt`) into *n XP*t* qu*ry. T** *vi**n** *