fix(langchain): backport patch ReDoS vulnerability in MRKL and ReAct action regex (CVE-2024-58340)#35603
Merged
Eugene Yurtsev (eyurtsev) merged 5 commits intov0.3from Mar 6, 2026
Merged
Conversation
John Kennedy (jkennedyvz)
approved these changes
Mar 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This is a backport of PR #35598 to the v0.3 branch, patching a ReDoS (Regular Expression Denial of Service) vulnerability (CVE-2024-58340) in the MRKL and ReAct agent action regex parsers. The vulnerable pattern (.*?)[\s]*Action allowed catastrophic backtracking on crafted input because (.*?) with re.DOTALL and [\s]* both compete to match whitespace characters, creating exponential ambiguity.
Changes:
- Remove the redundant
[\s]*quantifier between the first capture group and the literalActionkeyword in bothMRKLOutputParser.parse()andReActSingleInputOutputParser.parse(). - Add SIGALRM-based regression tests for both parsers to verify regex completes in bounded time on adversarial input.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
libs/langchain/langchain/agents/mrkl/output_parser.py |
Remove [\s]* from action-parsing regex to fix ReDoS vulnerability |
libs/langchain/langchain/agents/output_parsers/react_single_input.py |
Same regex fix applied to the ReAct single input parser |
libs/langchain/tests/unit_tests/agents/test_mrkl_output_parser.py |
Add ReDoS regression test for MRKLOutputParser |
libs/langchain/tests/unit_tests/agents/output_parsers/test_react_single_input.py |
Add ReDoS regression test for ReActSingleInputOutputParser |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…roups and bumping cassandra-driver
…g lint groups and bumping cassandra-driver" This reverts commit 8523540.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #35598 to the v0.3 branch. Patches the ReDoS vulnerability in MRKL and ReAct agent action regex patterns (CVE-2024-58340).
Created with Deep Agents CLI.