Skip to content

fix(guardrails): tighten system_prompt_leak heuristic to stop agent-traffic false-positives (#4041) - #4414

Merged
diegosouzapw merged 1 commit into
release/v3.8.32from
fix/4041-injection-heuristic
Jun 20, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.32from
fix/4041-injection-heuristic

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Refs #4041 (one slice of the multi-pronged heap-OOM report)

Context

#4041 reports a heap-OOM crash-loop under concurrent coding-agent load. It is multi-pronged; the two highest-leverage levers — bounding the injection-guard regex scan to a 16 KB prefix (#3932/#4041, MAX_INJECTION_SCAN_BYTES) and the heap-pressure guard (#4371) — already shipped. This PR lands the remaining self-contained piece the owner called out: the system_prompt_leak heuristic false-positives high on essentially all agent traffic.

Problem

The pattern matched a bare instructions after reveal/show/display/print/output/repeat, so normal agent text ("show the instructions", "display your instructions") tripped a high-severity detection on the hot path — noise that buries real signals.

Fix

Require a system|initial|hidden|original qualifier before prompt|instructions (src/shared/utils/inputSanitizer.ts). Real leak attempts still match ("reveal your system prompt", "print the initial prompt"), qualified instruction leaks now match too ("display your system instructions"), and generic agent "instructions" text no longer trips. No nested quantifiers → no ReDoS risk.

Validation (TDD)

New tests/unit/injection-system-prompt-leak-heuristic-4041.test.ts — fails on the unfixed pattern (generic "show the instructions" flagged), passes after (2/2). Injection/security regression suites green (44/0): security-fase01, prompt-injection-guard, injection-guard-scan-bound-3932, guardrails/injection-route-coverage. typecheck:core + lint clean.

The remaining #4041 levers (parse-once / double-parse → see the #4380 PR; honoring REDIS_URL; body streaming; backpressure cap) are tracked separately; this issue stays open.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.31 to release/v3.8.32 June 20, 2026 18:30
@diegosouzapw
diegosouzapw force-pushed the fix/4041-injection-heuristic branch from 60f8460 to c2d306a Compare June 20, 2026 19:49
@diegosouzapw
diegosouzapw merged commit 4287a12 into release/v3.8.32 Jun 20, 2026
1 check passed
@diegosouzapw
diegosouzapw deleted the fix/4041-injection-heuristic branch June 21, 2026 12:33
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
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.

1 participant