From 207385fbbe1dca0c29bf6fe1acc7aa4006036377 Mon Sep 17 00:00:00 2001 From: Kjell Tore Guttormsen Date: Sat, 18 Jul 2026 10:15:11 +0200 Subject: [PATCH] =?UTF-8?q?fix(llm-security):=20scanner=20robustness=20?= =?UTF-8?q?=E2=80=94=20ReDoS,=20MCP-stdout=20DoS,=20redirect=20loop,=20ato?= =?UTF-8?q?mic=20writes=20(#24,#53,#31,#25,#51)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #24 the HTML-obfuscation injection patterns had overlapping unbounded runs plus a required closing quote, so a non-closing input backtracked O(N^2) (~28.7s at the 512KB cap); quantifiers bounded, pathological input now 4ms. #53 mcp-live-inspect buffered MCP-server stdout via readline with no cap, so a hostile stdio server could exhaust memory / throw an uncaught RangeError; replaced with manual line buffering capped at 4MB that rejects pending RPCs and destroys stdout. #31 vsix-fetch's same-host redirect follower had no depth cap (loop hang); added depth>=5 cap mirroring the sibling fetcher. #25/#51 mcp-description-cache and skill-registry wrote JSON via bare writeFileSync (non-atomic: concurrent load-modify-save loses updates, a torn read silently yields an empty registry); both now write a temp file then renameSync. Suite 1931/0. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01TcQyMTQfyrsAapaCMPxTtQ --- scanners/lib/injection-patterns.mjs | 19 +++--- scanners/lib/mcp-description-cache.mjs | 9 ++- scanners/lib/skill-registry.mjs | 8 ++- scanners/lib/vsix-fetch.mjs | 7 ++- scanners/mcp-live-inspect.mjs | 38 ++++++++++-- tests/lib/injection-patterns.test.mjs | 58 +++++++++++++++++++ tests/lib/mcp-description-cache.test.mjs | 27 ++++++++- tests/lib/skill-registry-atomic.test.mjs | 39 +++++++++++++ .../mcp-live-inspect-stdout-cap.test.mjs | 36 ++++++++++++ tests/scanners/vsix-fetch.test.mjs | 29 ++++++++++ 10 files changed, 251 insertions(+), 19 deletions(-) create mode 100644 tests/lib/skill-registry-atomic.test.mjs create mode 100644 tests/scanners/mcp-live-inspect-stdout-cap.test.mjs diff --git a/scanners/lib/injection-patterns.mjs b/scanners/lib/injection-patterns.mjs index 65dbe3c..6e70365 100644 --- a/scanners/lib/injection-patterns.mjs +++ b/scanners/lib/injection-patterns.mjs @@ -109,13 +109,18 @@ export const HIGH_PATTERNS = [ { pattern: /