Cyber Resilience

CVE-2024-58340

Langchain ≤ 0.3.1

Public PoC
Published
12 January 2026
Modified
14 July 2026
Patch / advisory
CVSS Score v4 8.7
Click a component to see what it means
Raw vectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
EPSS Score 0.0042 35th percentile
Risk Priority 44 floored blend · peak EPSS

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 Endpoint Denial of Service (T1499); ranked at the 35th 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 map to SA-11 (Developer Testing and Evaluation) and SA-15 (Development Process, Standards, and Tools) — see the control section below for these in your framework.

Deeper analysis AI-assisted summary

Synthesised by an AI model from the NVD description and linked references — a reading aid, not an authoritative source.

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

Vulnerability Data

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 Techniques

T1499 Endpoint Denial of Service Impact
Adversaries may perform Endpoint Denial of Service (DoS) attacks to degrade or block the availability of services to users.
T1499.003 Application Exhaustion Flood Impact
Adversaries may target resource intensive features of applications to cause a denial of service (DoS), denying availability to those applications.
Derived from this CVE’s CWE(s) via the direct CWE→ATT&CK cross-walk.

CVEs Like This One

CVE-2024-1455Same product: Langchain Langchain
CVE-2026-44843Same product: Langchain Langchain
CVE-2025-2828Same product: Langchain Langchain
CVE-2024-2965Same product: Langchain Langchain
CVE-2024-5998Same product: Langchain Langchain
CVE-2023-36188Same product: Langchain Langchain
CVE-2024-8309Same product: Langchain Langchain
CVE-2024-3571Same product: Langchain Langchain
CVE-2023-38896Same product: Langchain Langchain
CVE-2024-3095Same product: Langchain Langchain

Affected Assets

langchain
langchain
≤ 0.3.1

Mitigating Controls

Mitigating Controls (NIST 800-53 r5) AI

Developer testing and evaluation can discover inefficient regex patterns via performance or static analysis.

Development standards and tools can require safe regex construction and forbid known exponential patterns.

Denial-of-service protections limit resource exhaustion caused by expensive regex evaluation.

Input validation can constrain data that would otherwise trigger worst-case regex complexity.

Mitigating Controls (NIST CSF 2.0) AI

Derived directly from the weakness types (CWEs) cited in the NVD entry via our AI-authored CWE→CSF cross-walk (authority under review) — links open the control.

PR.PS-06 mostly match
prevents

Secure SDLC practices directly prevent inefficient regex via reviews, static analysis, and safe libraries.

ID.RA-01 partial match
prevents

Vulnerability identification processes can discover ReDoS issues in existing code but do not stop their introduction.

Mitigating Controls (ISO/IEC 27001:2022 Annex A) AI

Derived directly from the weakness types (CWEs) cited in the NVD entry via our AI-authored CWE→ISO cross-walk (authority under review) — links open the control.

finds

Security testing can detect and reject regex patterns with exponential worst-case complexity.

prevents

Secure development lifecycle mandates review of algorithmic efficiency, directly addressing ReDoS-prone regex.

prevents

Application security requirements can specify input-validation rules that limit regex complexity.

prevents

Secure architecture principles encourage avoidance of computationally expensive constructs such as catastrophic backtracking.

prevents

Secure coding standards explicitly prohibit or limit the use of inefficient regular expressions.

References