CVE-2025-46726: Langroid Langroid Allows XXE Injection Vulnerability

HIGH
Advisory Identifier: GHSA-pw95-88fg-3j6f
CWE-611
Published
Advisory Summary

CVE-2025-46726 is a HIGH langroid allows xxe injection vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting Langroid libraries in the PyPI ecosystem. The issue involves langroid allows xxe injection via xmltoolmessage. Remediation is available by upgrading affected packages to version 0.53.4.

CVE-2025-46726 at a Glance

CVE Identifier CVE-2025-46726
GHSA Identifier GHSA-pw95-88fg-3j6f
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product Langroid
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2025-46726

To remediate this vulnerability, upgrade all affected Langroid dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

langroid fixed: 0.53.4
pip install langroid>=0.53.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show langroid

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-46726, inspect your installed packages using pip:

pip show langroid

Analyze the terminal output to locate any version of Langroid in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.53.4), your application is affected.

Note: The pip show langroid command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-611: Improper Restriction of XML External Entity Reference, where the product processes an xml document that can contain xml entities with uris that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. In Langroid, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A LLM application leveraging `XMLToolMessage` class may be exposed to untrusted XML input that could result in DoS and/or exposing local files with sensitive information. ### Details `XMLToolMessage` uses `lxml` without safeguards: https://github.com/langroid/langroid/blob/df6227e6c079ec22bb2768498423148d6685acff/langroid/agent/xml_tool_message.py#L51-L52 `lxml` is vulnerable to quadratic blowup attacks and processes external entity declarations for local files by default. Check here: https://pypi.org/project/defusedxml/#python-xml-libraries ### PoC A typical Quadratic blowup XML payload looks like this: ```xml <!DOCTYPE bomb [ <!ENTITY a "aaaaaaaaaa"> <!ENTITY b "&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;"> <!ENTITY c "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;"> ]> <bomb>&c;</bomb> ``` Here, &a; expands to 10 characters, &b; expands to 100, and &c; expands to 1000, causing exponential memory usage and potentially crashing the application. ### Fix Langroid 0.53.4 initializes `XMLParser` with flags to prevent XML External Entity (XXE), billion laughs, and external DTD attacks by disabling entity resolution, DTD loading, and network access. https://github.com/langroid/langroid/commit/36e7e7db4dd1636de225c2c66c84052b1e9ac3c3

CVE-2025-46726 Affected Langroid Versions

1 component(s)
Fixed Versions:
0.53.4
Product / Package Ecosystem Affected Versions Fixed Version
langroid
PyPI
< 0.53.4
0.53.4

References

Frequently Asked Questions

What is CVE-2025-46726?
CVE-2025-46726 is a security vulnerability in Langroid involving Langroid Allows XXE Injection via XMLToolMessage under CWE-611: Improper Restriction of XML External Entity Reference.
Which Langroid versions are affected?
Affected versions include releases prior to 0.53.4 across affected packages: langroid.
What version fixes CVE-2025-46726?
Upgrading to 0.53.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is langroid affected?
Yes, langroid is affected in releases prior to 0.53.4. Upgrade your dependency to 0.53.4 or later.
What CWE is associated with CVE-2025-46726?
CVE-2025-46726 is classified under CWE-611: Improper Restriction of XML External Entity Reference (The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.).
How can I check PyPI dependencies for CVE-2025-46726?
Run the dependency tree command: 'pip show langroid'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-pw95-88fg-3j6f",
  "modified" : "2025-05-05T22:07:30Z",
  "published" : "2025-05-05T20:40:44Z",
  "aliases" : [ "CVE-2025-46726" ],
  "summary" : "Langroid Allows XXE Injection via XMLToolMessage",
  "details" : "### Summary\nA LLM application leveraging `XMLToolMessage` class may be exposed to untrusted XML input that could result in DoS and/or exposing local files with sensitive information.\n\n### Details\n`XMLToolMessage` uses `lxml` without safeguards:\nhttps://github.com/langroid/langroid/blob/df6227e6c079ec22bb2768498423148d6685acff/langroid/agent/xml_tool_message.py#L51-L52\n`lxml` is vulnerable to quadratic blowup attacks and processes external entity declarations for local files by default. \nCheck here: https://pypi.org/project/defusedxml/#python-xml-libraries\n\n### PoC\nA typical Quadratic blowup XML payload looks like this:\n```xml\n<!DOCTYPE bomb [\n<!ENTITY a \"aaaaaaaaaa\">\n<!ENTITY b \"&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;\">\n<!ENTITY c \"&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;\">\n]>\n<bomb>&c;</bomb>\n```\nHere, &a; expands to 10 characters, &b; expands to 100, and &c; expands to 1000, causing exponential memory usage and potentially crashing the application.\n \n### Fix\nLangroid 0.53.4 initializes `XMLParser` with flags to prevent XML External Entity (XXE), billion laughs, and external DTD attacks by disabling entity resolution, DTD loading, and network access.\nhttps://github.com/langroid/langroid/commit/36e7e7db4dd1636de225c2c66c84052b1e9ac3c3",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:H/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "langroid"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.53.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/langroid/langroid/security/advisories/GHSA-pw95-88fg-3j6f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-46726"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/langroid/langroid/commit/36e7e7db4dd1636de225c2c66c84052b1e9ac3c3"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/langroid/langroid"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/langroid/langroid/blob/df6227e6c079ec22bb2768498423148d6685acff/langroid/agent/xml_tool_message.py#L51-L52"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-05-05T20:40:44Z",
    "nvd_published_at" : "2025-05-05T20:15:21Z"
  }
}