Skip to content

Fix potential ReDoS in local-command metadata stripping#729

Open
jsgrrchg wants to merge 2 commits into
agentclientprotocol:mainfrom
jsgrrchg:fix/727-linear-local-command-stripper
Open

Fix potential ReDoS in local-command metadata stripping#729
jsgrrchg wants to merge 2 commits into
agentclientprotocol:mainfrom
jsgrrchg:fix/727-linear-local-command-stripper

Conversation

@jsgrrchg
Copy link
Copy Markdown

Closes #727.

This replaces the local-command metadata stripping regex with a deterministic scanner over the known SDK local-command marker tags.

The previous implementation used a regex over transcript content to remove marker blocks such as <command-name>...</command-name> and <local-command-stdout>...</local-command-stdout>. CodeQL flags that pattern as a potential polynomial-time regex on uncontrolled input.

The new implementation avoids matching arbitrary content with a regex. It scans only for the five known local-command marker tags and strips complete, well-formed marker blocks while preserving malformed or literal marker-like text.

Covered behavior:

  • strips valid SDK local-command metadata blocks
  • preserves real prose around stripped marker blocks
  • preserves unknown marker-like tags
  • preserves incomplete or mismatched marker-like tags
  • avoids pairing an incomplete opening tag with a later valid block
  • handles long malformed marker-like input and unterminated fragments without dropping text

This is intended as a defensive hardening change for the CodeQL finding rather than a claim of a confirmed exploit.

Tests:

  • npm run test:run -- src/tests/acp-agent.test.ts

@jsgrrchg jsgrrchg force-pushed the fix/727-linear-local-command-stripper branch from d0b6cd7 to e3a7c88 Compare May 29, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential ReDoS in local-command metadata stripping regex

1 participant