CVE-2024-58340
Published: 12 January 2026
Summary
CVE-2024-58340 is a high-severity Inefficient Regular Expression Complexity (CWE-1333) vulnerability in Langchain Langchain. Its CVSS base score is 8.7 (High).
Operationally, exploitation aligns with the MITRE ATT&CK technique Application or System Exploitation (T1499.004); ranked at the 32.6th percentile by exploit likelihood (below the median); it is not currently listed in the CISA KEV catalog; a public proof-of-concept is referenced.
This vulnerability is AI-related — categorised as NLP and Transformers; in the LLM/Generative AI Risks risk domain.
The strongest mitigations our analysis identified are NIST 800-53 SC-5 (Denial-of-service Protection) and SI-2 (Flaw Remediation).
Deeper analysis
CVE-2024-58340 is a regular expression denial-of-service (ReDoS) vulnerability in LangChain versions up to and including 0.3.1. The flaw affects the MRKLOutputParser.parse() method in the file libs/langchain/langchain/agents/mrkl/output_parser.py, where a backtracking-prone regular expression is used to extract tool actions from model output. This can result in excessive CPU consumption when processing malicious input.
The vulnerability can be exploited by an attacker who can supply or influence the text parsed by MRKLOutputParser.parse(), for instance through prompt injection in downstream applications that pass LLM output directly to the parser. Successful exploitation triggers significant parsing delays and a denial-of-service condition due to high resource usage. It carries a CVSS v3.1 score of 7.5 (AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H) and is associated with CWE-1333.
Advisories and references, including the LangChain GitHub repository (https://github.com/langchain-ai/langchain), Huntr (https://huntr.com/bounties/e7ece02c-d4bb-4166-8e08-6baf4f8845bb), LangChain website (https://www.langchain.com/), and VulnCheck (https://www.vulncheck.com/advisories/langchain-mrkloutputparser-redos), provide further details on the issue.
This vulnerability is relevant to AI/ML applications built with LangChain, particularly those involving agent tooling and LLM output parsing.
EU & UK References
- 🇪🇺 ENISA EUVD: EUVD-2026-2399
Vulnerability details
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…
more
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.
- CWE(s)
AI Security AnalysisAI
- AI Category
- NLP and Transformers
- Risk Domain
- LLM/Generative AI Risks
- OWASP Top 10 for LLMs 2025
- None mapped
- Classification Reason
- Matched keywords: langchain, llm, prompt injection
Related Threats
MITRE ATT&CK Enterprise TechniquesAI
Why these techniques?
ReDoS flaw directly enables application exhaustion via crafted input to the vulnerable parser, matching T1499.004 (Application or System Exploitation).
CVEs Like This One
Affected Assets
Mitigating Controls
Mitigating Controls (NIST 800-53 r5) AI
Flaw remediation requires timely installation of vendor patches for the known ReDoS vulnerability in LangChain's MRKLOutputParser, directly eliminating the backtracking-prone regex issue.
Denial-of-service protection implements mechanisms like resource limits and timeouts to counter CPU exhaustion from crafted regex inputs targeting the parser.
Information input validation sanitizes or rejects malicious LLM outputs before parsing to block prompt injection payloads that trigger the ReDoS condition.