CVE-2024-58340 LangChain <= 0.3.1 MRKLOutputParser ReDoS
Attackers can cause denial of service in LangChain applications by triggering excessive CPU consumption via crafted input to the MRKLOutputParser.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-58340?
CVE-2024-58340 is a high-severity denial of service vulnerability in LangChain, published on 12 Jan 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
LangChain versions up to and including 0.3.1 contain a regular expression denial-of-service (ReDoS) vulnerability in the MRKLOutputParser.parse() method (libs/langchain/langchain/agents/mrkl/output_parser.py). The parser applies a backtracking-prone regular expression when extracting tool actions from model output. An attacker who can supply or influence the parsed text (for example via prompt injection in downstream applications that pass LLM output directly into MRKLOutputParser.parse()) can trigger excessive CPU consumption by providing a crafted payload, causing significant parsing delays and a denial-of-service condition.
Weakness: CWE-1333
Which versions are affected by CVE-2024-58340?
1 open source package ship an affected version, including langchain-exa. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
langchain-exa PyPI | All versions | 1.0.0a1 |
Products include Langchain Langchain.
How do I fix CVE-2024-58340?
Upgrade langchain-exa to 1.0.0a1 or later.
Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.
Is CVE-2024-58340 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-58340 exists.
Other vulnerabilities in LangChain
- CVE-2023-39631 Langchain vulnerable to arbitrary code execution via the evaluate function in the numexpr library
- CVE-2023-36281 langchain vulnerable to arbitrary code execution
- CVE-2023-38860 LangChain vulnerable to arbitrary code execution
- CVE-2023-38896 LangChain vulnerable to arbitrary code execution
- CVE-2023-39659 LangChain vulnerable to arbitrary code execution
Sources
Also known as GHSA-pq2w-3m7x-qx76, PYSEC-2026-75.