kodelyth-ecc 2.24.3 → 2.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,75 @@
2
2
 
3
3
  All notable changes to Kodelyth ECC are documented here.
4
4
 
5
+ ## v2.24.4 — fix catastrophic backtracking in the prompt-injection guard (October 2026)
6
+
7
+ **Security fix.** The guard that scans untrusted text for prompt injection could
8
+ be hung indefinitely by the text it was scanning.
9
+
10
+ ### What was wrong
11
+
12
+ `override-prior-instructions` — the critical-severity pattern matching the single
13
+ most common injection phrase — was written as
14
+
15
+ \s+ (group)? \s* (group)? \s*
16
+
17
+ Three whitespace quantifiers with optional groups between them. With both groups
18
+ matching empty they sat adjacent, so a run of N spaces could be partitioned
19
+ between them in O(N^2) ways, and every partition was retried once the trailing
20
+ noun failed to match. On `"ignore" + N spaces + "x"`:
21
+
22
+ | N | time |
23
+ |---|---|
24
+ | 2,000 | 1.5s |
25
+ | 4,000 | 12.5s |
26
+ | 8,000 | never observed to finish |
27
+ | 19,000 | never observed to finish |
28
+
29
+ The guard caps input at 20,000 characters, so the cap does not help: the blow-up
30
+ begins around N=2,000, well inside it. Confirmed end to end through the hook's own
31
+ stdin path with the payload delivered in `tool_response`, which is where
32
+ untrusted file and network content arrives.
33
+
34
+ ### Why it is more than a hang
35
+
36
+ This hook runs on every tool call and is fail-open by design. In the default
37
+ `warn` mode the session stalls until the harness kills the hook, and no warning is
38
+ ever emitted. In `block` mode it is worse: a guard that never returns never exits
39
+ 2, so the critical pattern it exists to catch goes unblocked. The denial of
40
+ service doubles as a bypass of the control itself.
41
+
42
+ ### The fix
43
+
44
+ Each optional segment now carries its own leading `\s+` inside the group —
45
+ `(?:\s+X)?` rather than `\s+(X)?\s*` — so a whitespace run has exactly one valid
46
+ partition and there is nothing to backtrack through. The pattern now takes 4.8ms
47
+ at the full 20,000-character cap, and stays linear beyond it: 3.9ms on a million
48
+ spaces.
49
+
50
+ `system-prompt-leak` carried the same shape one group shallower, making it
51
+ quadratic rather than catastrophic (~590ms at 32,000 spaces, ~200ms at the cap).
52
+ Not a denial of service today, but the identical defect and one optional group
53
+ away from becoming one, so it is rewritten the same way. The other ten patterns
54
+ were swept with trigger words they actually match and are unaffected (4-5ms at
55
+ the cap).
56
+
57
+ ### Detection is unchanged
58
+
59
+ Verified rather than assumed. Both rewrites were checked against every phrase
60
+ their grammars generate — 1,140 for the first, 483 for the second — and agree
61
+ with the originals on all 1,623, with no phrase matched by one and not the other.
62
+
63
+ New tests cover the detections that must still fire, the ordinary text that must
64
+ not, and the timing. The timing test runs in a child process with a hard timeout
65
+ on purpose: a catastrophic regex is synchronous and CPU-bound, so node:test's own
66
+ timeout cannot interrupt it — against the old pattern the assertion was never
67
+ reached and the suite simply hung, which is a red build with no explanation. The
68
+ child turns the same regression into a named failure. Verified in both
69
+ directions: the old regex is killed at 15s with `ETIMEDOUT`, the new one finishes
70
+ in 59ms.
71
+
72
+ **668 tests across 43 files.**
73
+
5
74
  ## v2.24.3 — remove decorative emoji from docs and catalog (October 2026)
6
75
 
7
76
  Documentation only. No code, no behaviour change.
package/CLAUDE.md CHANGED
@@ -26,7 +26,7 @@ scripts/ → Node.js utilities: MCP server, dashboard, swarm, replay, router
26
26
  bundles/ → 3 power bundles (indie-hacker, red-team, enterprise)
27
27
  actions/ → GitHub Action (CI/CD integration for PR review)
28
28
  docs/ → Feature docs (arena.md, mcp.md, dashboard.md, swarm.md, replay.md, evolve.md, supply-chain.md)
29
- tests/ → 665 passing tests across 43 test files
29
+ tests/ → 668 passing tests across 43 test files
30
30
  ```
31
31
 
32
32
  ## Running Tests
package/README.md CHANGED
@@ -118,7 +118,7 @@ Most "AI agent kits" are folders of markdown files you have to remember the name
118
118
  | Quality hooks | ✓ 44 | Some | ✗ | ✗ |
119
119
  | IDE platforms | **11** (Claude Code, Windsurf, Cursor, Codex, Antigravity, OpenCode, Cline, Roo Code, Aider, Kimi, Gemini CLI) | 1-2 | 1 | Varies |
120
120
  | Telemetry | **None** | Varies | None | Varies |
121
- | Test coverage | ✓ 665 tests | ✗ | ✗ | ✗ |
121
+ | Test coverage | ✓ 668 tests | ✗ | ✗ | ✗ |
122
122
  | Distributed via | `npx`, curl, clone | Manual | Manual | Manual |
123
123
 
124
124
  ---
@@ -20,13 +20,28 @@ const PATTERNS = [
20
20
  {
21
21
  id: 'override-prior-instructions',
22
22
  severity: 'critical',
23
- regex: /\b(ignore|disregard|forget)\s+(all|any|the|your|my|all\s+(?:prior|previous|above|earlier))?\s*(prior|previous|above|earlier|prev|preceding)?\s*(instructions?|rules?|prompt|system\s*prompt|directives?)\b/i,
23
+ // Each optional segment carries its own leading \s+, so a run of whitespace
24
+ // has exactly ONE valid partition. The previous form was
25
+ // \s+ (group)? \s* (group)? \s*
26
+ // — three whitespace quantifiers with optional groups between them. When both
27
+ // groups matched empty they sat adjacent, so N spaces could be split between
28
+ // them in O(N^2) ways, and every split was retried once the final noun failed
29
+ // to match. Measured on "ignore" + N spaces + "x": 1.5s at N=2000, 12.5s at
30
+ // N=4000, over 40s at N=8000 — all well inside this hook's own 20000-char
31
+ // input cap, and reachable through tool_response, which carries untrusted
32
+ // file and network content. Verified equivalent across 1140 generated phrases.
33
+ regex: /\b(?:ignore|disregard|forget)(?:\s+(?:all|any|the|your|my))?(?:\s+(?:prior|previous|above|earlier|prev|preceding))?\s+(?:instructions?|rules?|system\s*prompt|prompt|directives?)\b/i,
24
34
  why: 'Classic instruction-override prompt injection.',
25
35
  },
26
36
  {
27
37
  id: 'system-prompt-leak',
28
38
  severity: 'critical',
29
- regex: /\b(reveal|print|show|repeat|output|dump|leak|expose)\s+(your|the|all|any)?\s*(system\s*prompt|hidden\s*prompt|initial\s*(prompt|instructions?)|original\s*(prompt|instructions?)|first\s*(message|prompt|instruction))/i,
39
+ // Same adjacent-quantifier shape as above, one group shallower, so quadratic
40
+ // rather than catastrophic: ~590ms at 32000 spaces, ~200ms at the 20000 cap.
41
+ // Not a denial of service today, but the identical defect, and it would become
42
+ // one the moment another optional group is added. Verified equivalent across
43
+ // 483 generated phrases.
44
+ regex: /\b(?:reveal|print|show|repeat|output|dump|leak|expose)(?:\s+(?:your|the|all|any))?\s+(?:system\s*prompt|hidden\s*prompt|initial\s*(?:prompt|instructions?)|original\s*(?:prompt|instructions?)|first\s*(?:message|prompt|instruction))/i,
30
45
  why: 'Explicit attempt to extract the system prompt.',
31
46
  },
32
47
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodelyth-ecc",
3
- "version": "2.24.3",
3
+ "version": "2.24.4",
4
4
  "description": "Production-grade AI coding toolkit — 70 agents (incl. devil-mode adversarial crew), 196 skills, 103 commands, parallel multi-agent commands, semantic intent routing, self-learning memory, and a built-in MCP server (16 tools / 6 prompts / 377 resources) that bridges to Claude Desktop, LangGraph, AutoGen, CrewAI, and OpenAI Agents SDK. Works on macOS, Linux and Windows with Claude Code, Windsurf, Cursor, Codex, Antigravity, OpenCode, Cline, RooCode, Aider, Kimi, and Gemini CLI.",
5
5
  "author": "Kodelyth <github.com/sifxprime>",
6
6
  "license": "MIT",