CVE-2024-58340: LangChain <= 0.3.1 MRKLOutputParser ReDoS

Published Jan 12, 2026
·
Updated

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/outputparser.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.

Affected Software

2 affected components
pypi/langchain<=0.3.1
Langchain Langchain<=0.3.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade LangChain (MRKLOutputParser / output_parser.py) to a version that resolves this vulnerability.

    Fixed in 0.3.1
  2. Compensating control

    Protect the service that calls MRKLOutputParser.parse() by limiting the maximum size/complexity of model output that can be parsed (e.g., cap output length and/or enforce timeouts) to prevent CPU-exhaustion parsing DoS from crafted payloads.

Event History

Jan 12, 2026
CVE Published
via MITRE·11:05 PM
Data Sourced
via MITRE·11:05 PM
DescriptionWeakness
Data Sourced
via NVD·11:15 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-58340?

CVE-2024-58340 is categorized as a medium severity vulnerability due to its potential for exploitation through regular expression denial of service.

2

How do I fix CVE-2024-58340?

To mitigate CVE-2024-58340, you should upgrade LangChain to version 0.3.2 or later, where the vulnerability has been addressed.

3

What software is affected by CVE-2024-58340?

CVE-2024-58340 affects all versions of LangChain up to and including 0.3.1.

4

What type of vulnerability is CVE-2024-58340?

CVE-2024-58340 is a regular expression denial-of-service (ReDoS) vulnerability.

5

Where can I find more information about CVE-2024-58340?

You can find additional details about CVE-2024-58340 in LangChain documentation and security advisories.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203