mcpproxy-go icon indicating copy to clipboard operation
mcpproxy-go copied to clipboard

phrase.injection HARD pass joins a line-broken compound target ("system\nPrompt editor") into a dangerous verdict

Open Dumbris opened this issue 1 month ago • 0 comments

Summary

The curated HARD pass of phrase.injection (internal/security/detect/checks/phrase_injection.go) reads ToolView.PhraseText. NormalizeForPhrase turns line breaks into spaces. As a result, a disclosure verb at the end of one line and a compound target split across the next line are matched as one directive.

Reproduced on current origin/main with scanner.ScanToolMetadataVerdict:

Description Verdict on origin/main
Click show the system. Prompt editor opens in a side panel. clean
Click show the system\nPrompt editor opens in a side panel. dangerous (phrase.injection, HARD)
Click show the system prompt editor in a side panel. dangerous (same-line form; tracked in #795)

The newline form is a benign UI description, but it gets auto-quarantined.

Why it was not changed in the SEC-01 PR

This behavior predates the SEC-01 detector branch (fix/assess-detector-admission). That branch only made the letters-only squashed fallback stop crossing line breaks and sentence ends at compound joins (Sol review round 14).

Making the HARD pass respect line breaks is a deliberate trade-off. A hostile directive wrapped across a line, such as reveal your system\nprompt, would then fall out of the HARD tier. That change needs its own decision and its own corpus measurement. It also should not be slipped into a security fix.

Possible approach

Run the curated families per line, with whitespace-only wraps inside a sentence still joined. Alternatively, downgrade a match that spans a line break and a capitalized sentence start to SOFT. Measure the change against internal/security/scanner/testdata/sec01_injection_variants.json and the real-world baseline.

Dumbris avatar Oct 11 '26 17:10 Dumbris