Files
ruflo/v3/@claude-flow/cli/src
ClaudeandRuFlo 25f26f5e3e fix(security): address review — linear-time regex, drop snippet from automatic-boot stdout
Two findings from ruvnet's review on #4053:

1. The powershell/-EncodedCommand pattern (`\s+.*-e(...)`) backtracks
   quadratically on hostile input -- measured ~1.9s on 64,000 spaces with no
   match; a 1MB hook command would stall session-restore (an unconditional
   boot path) for minutes. Rewritten as a linear token-walk
   (`(?:\S+\s+)*?`), confirmed <5ms on a 1MB hostile input while still
   matching real EncodedCommand payloads. Fixed in both the CJS mirror and
   the shared TS original (settings-risk-scanner.ts), since the TS version
   is already live via init/--upgrade.

2. scanSessionStartSettingsForRisk()'s warnings included up to 120 chars of
   the matched hook-command snippet -- but session-restore's stdout is read
   back into the live Claude Code session as context, unlike init/--upgrade
   where a human reads the terminal directly. Printing attacker-controlled
   settings.json content into that context is a prompt-injection path even
   with control characters stripped. The automatic-boot path now prints
   only the scanner-generated location + reason, never the snippet;
   srFormatRiskFindingsAsWarnings (snippet included) is unchanged for
   init/--upgrade's human-facing output.

New tests: a 1MB ReDoS timing guard, a snippet-leak regression guard, and a
real-payload-still-detected check after the regex rewrite. 75/75 related
tests pass.

Co-Authored-By: RuFlo <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01HW4yuGGcrCy4CcPgQ7Q2dx
2026-10-11 13:38:47 +00:00
..
…
…
…
…