CVE-2024-58340 LangChain <= 0.3.1 MRKLOutputParser ReDoS

High 8.7 Published Updated

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.

PackageAffectedFixed in
langchain-exa PyPIAll versions1.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.

Sources

Also known as GHSA-pq2w-3m7x-qx76, PYSEC-2026-75.

Is CVE-2024-58340 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free