Skip to content

fix(security): phrase.injection credential-transfer recall and line-break false positive - #1630

Merged
Dumbris merged 14 commits into
mainfrom
fix/1601-1589-phrase-injection
Oct 17, 2026
Merged

Dumbris merged 14 commits into
mainfrom
fix/1601-1589-phrase-injection

Conversation

@Dumbris

@Dumbris Dumbris commented Oct 16, 2026

Copy link
Copy Markdown
Member

Summary

Detector changes in internal/security/detect/checks/phrase_injection.go.

#1601 (credential-transfer recall gaps)

  • store|save|write|copy are now placement verbs in the pronoun and explicit-payload families (credentialPlacementVerbs).
  • New inverted-placement families (fill|populate <field> with <payload>) for key files, config-file secrets, whole config file via pronoun, and a named secret via pronoun.
  • A noun-phrase re-reference (the key itself, the value itself) now counts as the pronoun of a named secret. the length itself does not.
  • Pre-existing bug found while testing: a word that starts the next sentence (... the API key. Type: object, as the scanner appends the input schema) was read as a metadata qualifier of the secret noun and masked it. The metadata look-ahead now stops at the sentence end.

#1589 (line-break false positive)

  • Chosen approach: a system-prompt disclosure match whose words straddle a line break, with the next line starting a capitalized sentence, is capped to SOFT. A lowercase wrap (reveal your system\nprompt) stays HARD. Line breaks are recovered from the raw text (CR/LF, Unicode separators and JSON-escaped breaks in the schema), because PhraseText collapses them.
  • Scoped to the system-prompt disclosure family only (lineBreakSoft). Override families are not downgraded, so Ignore all previous\nInstructions ... stays HARD.
  • Trade-off: a hostile Reveal your system\nPrompt (capitalized second line) now lands in SOFT, which still holds the change under trust_mode=scan but does not auto-quarantine.

Tests

  • 23 new entries in internal/security/scanner/testdata/sec01_injection_variants.json (13 malicious expect=dangerous, 10 benign controls expect=not_dangerous), plus unit tests TestPhraseInjection_LineBreakSentenceStart and TestPhraseInjection_CredentialTransferRecall1601.
  • go test -race ./internal/security/... passes, including TestSEC01_VariantCorpus_ScanGateOutcomes and TestSEC01_RealWorldBenignCorpora_NoNewHolds. go test -tags server ./internal/security/detect/... passes.
  • golangci-lint (CI config), bare and --build-tags server, on ./internal/security/... and ./cmd/scan-eval/...: 0 issues.

scan-eval gate on the variants corpus (English entries; malicious = expect:dangerous, benign = hard negatives)

malicious detected recall hard-negative FPs FP rate
before (new corpus, old detector) 24 / 35 0.686 1 / 100 0.010
after 35 / 35 1.000 0 / 100 0.000

scan-eval --gate --min-recall 1 --max-fp 0 passes after the change.

Closes #1601
Closes #1589

…eak joins in phrase.injection

#1601: store/save/write/copy placement verbs, inverted 'fill <field> with it', 'the key itself' re-reference, and metadata look-ahead no longer reads the next sentence.
#1589: a system-prompt disclosure match joining a line end to a capitalized new sentence is SOFT, lowercase wraps stay HARD.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/1601-1589-phrase-injection

Available Artifacts

  • archive-darwin-amd64 (31 MB)
  • archive-darwin-arm64 (28 MB)
  • archive-linux-amd64 (19 MB)
  • archive-linux-arm64 (17 MB)
  • archive-windows-amd64 (31 MB)
  • archive-windows-arm64 (28 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (27 MB)
  • installer-dmg-darwin-arm64 (25 MB)
  • smart-mcp-proxymcpproxy-goOSYZXX.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 38931719308 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

codecov-commenter commented Oct 16, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 98.57143% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...nternal/security/detect/checks/phrase_injection.go 98.57% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Dumbris
Dumbris merged commit 52e4559 into main Oct 17, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants