LangChain's XMLOutputParser vulnerable to XML Entity Expansion
The XMLOutputParser in LangChain uses Python's standard XML parser, which is vulnerable to XML entity expansion. An attacker could manipulate an LLM to produce a malicious payload that compromises the availability of a web service.
langchain-ai/langchain
Originally disclosed on huntr
The XMLOutputParser in LangChain uses the etree module from the XML parser in the standard python library which has some XML vulnerabilities; see: https://docs.python.org/3/library/xml.html
This primarily affects users that combine an LLM (or agent) with the XMLOutputParser and expose the component via an endpoint on a web-service.
This would allow a malicious party to attempt to manipulate the LLM to produce a malicious payload for the parser that would compromise the availability of the service.
A successful attack is predicated on:
- Usage of XMLOutputParser
- Passing of malicious input into the XMLOutputParser either directly or by trying to manipulate an LLM to do so on the users behalf
- Exposing the component via a web-service
From the GitHub Advisory Database (GHSA-q84m-rmw3-4382, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the XMLOutputParser relies on Python's standard etree XML parser without disabling entity expansion or otherwise hardening it against malicious XML.
What the attacker needed
Usage of XMLOutputParser; Malicious input reaches the parser; Component exposed via a web service
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
XML entity expansion is a way to make an XML parser use up a lot of memory or processing time by defining entities that refer to each other many times. If a web service parses XML from an untrusted source, an attacker can send a small input that expands into a huge amount of data, slowing or crashing the service. Here, the XML comes from an LLM that an attacker might trick into producing the malicious payload.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.