Repository navigation
fix(agents): prevent ReDoS in MCP glob-to-regex wildcard matching - #100330
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 4:50 PM ET / 20:50 UTC. Summary PR surface: Source +15, Tests +62. Total +77 across 5 files. Reproducibility: yes. Source inspection shows current Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the shared regex-free MCP filter matcher after current-head terminal/log proof shows adversarial and normal Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current Is this the best way to solve the issue? Yes. The current PR head is the best narrow fix shape because it removes regex matching from both affected MCP filter paths and shares one segment matcher; the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 77575d74f68c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +15, Tests +62. Total +77 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
Collapse consecutive '*' wildcards into a single '*' before building the regex in globMatches(). Without this, a glob like '**********-x' tested against a non-matching string causes catastrophic backtracking (238s for a single call with 10 stars vs 0.4ms after fix). Affected functions: - src/agents/agent-bundle-mcp-runtime.ts: globMatches (MCP tool name filter) - src/agents/agent-bundle-mcp-materialize.ts: globMatches (MCP operation filter) Co-Authored-By: Claude <[email protected]>
|
Land-ready proof for exact head
|
|
Merged via squash.
|
…enclaw#100330) * fix(agents): prevent ReDoS in MCP glob-to-regex wildcard matching Collapse consecutive '*' wildcards into a single '*' before building the regex in globMatches(). Without this, a glob like '**********-x' tested against a non-matching string causes catastrophic backtracking (238s for a single call with 10 stars vs 0.4ms after fix). Affected functions: - src/agents/agent-bundle-mcp-runtime.ts: globMatches (MCP tool name filter) - src/agents/agent-bundle-mcp-materialize.ts: globMatches (MCP operation filter) Co-Authored-By: Claude <[email protected]> * fix(agents): make MCP filter matching linear * style(mcp): satisfy filter lint --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
globMatches()inagent-bundle-mcp-runtime.tsandagent-bundle-mcp-materialize.tsconverts glob patterns to regular expressions by splitting on*and joining with.*. A glob with consecutive wildcards (e.g.,**********-x) produces a regex with many consecutive.*segments (e.g.,^.*.*.*.*.*.*.*.*.*.*-x$), which causes catastrophic backtracking (ReDoS) when tested against non-matching strings.Why This Change Was Made
Consecutive
.*segments are semantically equivalent to a single.*— collapsing them before regex construction eliminates the backtracking vector with zero functional change.Changes
src/agents/agent-bundle-mcp-runtime.ts— collapse consecutive*inglobMatches()(MCP tool name filter)src/agents/agent-bundle-mcp-materialize.ts— identical fix inglobMatches()(MCP operation filter)Evidence
Functional correctness
ReDoS benchmark (10-star glob vs 100-char non-match)
CI
Existing
agent-bundle-mcp-materialize.test.tsandagent-bundle-mcp-runtime.test.tscontinue to pass — the fix has zero functional impact.Related
session-visibilityglob matching🤖 Generated with Claude Code