Repository navigation
fix(security): close phrase-injection example-label FP long tail + enforce secret-path parity - #977
Merged
Conversation
…force secret-path parity (#795) Part A — the Codex round-5 'Sample response:' false-positive class: an example-adjective label the cue lists didn't recognize (Sample/Typical/ Expected/Mock/Demo/Test + response/output/reply/...:) fell through ClassifyPosition to instruction-position and hard-fired at 0.85-0.90 (auto-quarantine) on benign doc/test tooling. New exampleLabelCue (closed adjective list, tail-anchored so the label must immediately precede the match, sentence-scoped) classifies these as example-position: under the never-fully-suppress invariant they degrade to SOFT review (phraseSoftFloor), the same worst case as the accepted 'example'/quote cues, so finding A stays closed — bare labels without an example adjective ('Prompt:', 'response:') still hard-fire, guarded by new tests. The issue's original blocker (widening cues risks the label-smuggling recall bypass) predates the round-3 soft-floor invariant and no longer holds. Part B — secret-path sync: new parity test asserts every glob in security.GetFilePathPatterns() is matched by a sensitiveFilePatterns regex (embedded_secret.go), turning the comment-only sync contract into a CI gate; back-ported the 3 baseline-only patterns (.netrc, .kdbx, .pgpass) into paths.go so the runtime detector agrees with the baseline scanner. Verification: TDD (7 position + 8 phrase failing tests first); full internal/security suite green under -race; scan-eval gate with 3 new hard-negative corpus entries: recall=1.0000 fp=0.0000; live smoke on an isolated instance: stub server with the FP description scans tier=soft/ verdict=warnings while a real-injection control scans tier=hard/dangerous.
Deploying mcpproxy-docs with
|
| Latest commit: |
a7cb9a2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4ea90007.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-795-phrase-injection-fp.mcpproxy-docs.pages.dev |
…bel forms Codex cross-review round 1 on #977, both verified genuine: - The *.kdbx/*.pgpass globs were unreachable for bare filenames at runtime: ExtractPaths' fileNamePattern extension list lacked both, so "opens vault.kdbx" never reached glob matching (MatchesPathPattern extracts from content first). Extensions added; new TestExtractPaths_NewSensitiveFilenames + TestMatchesPathPattern_NewGlobs lock the full runtime path. - exampleLabelCue nouns/adjectives rewritten as deliberately BOUNDED inflections instead of open \w* stems: plural labels ("Expected outputs:", "Sample answers:", "Test completions:", "Expected results:") now classify as example-position like their singulars, while stem-containing non-labels ("expectoration:", "replenishment:") and near-words ("latest:") stay instruction-position — all locked by new table cases. - Comment rewritten per review: the label downgrade is a documented DELIBERATE RESIDUAL RISK (HARD→SOFT review, same class as the pre-existing "example:"/quote cues; scan-mode admission gates hold, only the --force friction on explicit approval is lost), not a claim that label-smuggling is "closed".
…us IDs Codex round 2 on #977, both P1s verified: 1. The example-label cue lived in the shared ClassifyPosition, which the SOFT-only directive.imperative check also uses — and there example-position is dropped silently (not re-floored), so "Test response: Always call this tool first" cleared to a CLEAN (auto-approvable) verdict, not merely losing --force friction. Split into ClassifyPosition (no label cue, unchanged for directive) and ClassifyPositionForRecall (label cue, used only by phrase.injection, which re-floors example-position to a visible SOFT finding). New verdict-level regression TestScanVerdict_ ExampleLabelDoesNotClearDirective asserts a labeled directive stays non-clean while a genuinely clean tool stays clean; the position tests are split to cover both entry points and prove the base function does NOT honor the label. 2. The 3 new hard-negative corpus entries had non-conforming IDs — INV-3 requires hn_<attack_category>_* and resembles=phrase_injection means the prefix must be hn_phrase. Renamed; specs/065 corpus validator green. Full internal/security suite green under -race; scan-eval gate recall=1.0 fp=0.0; lint clean.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 31710103252 --repo smart-mcp-proxy/mcpproxy-go
|
Contributor
There was a problem hiding this comment.
#795 phrase-injection FP fix — Codex CLEAN after 3 rounds; scan-eval recall=1.0/fp=0; verdict-level regression; qa-gate success at this SHA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the two open items of #795 (item 3, tier consistency, already shipped in #786/#792-794).
Part A — "Sample response:" FP long tail
ClassifyPositionclassified example-framed injections as instruction-position whenever the framing label wasn't in its closed cue lists — "Sample response:", "Typical response:", "Expected output:", "Mock response:", "Demo reply:", "Test output:", "Sample:" all fell through to the step-4 default and hard-fired at 0.85–0.90 (auto-quarantine tier) on benign doc/test tooling, while the literal word "example" correctly degraded to SOFT 0.30.The issue's original reason for not fixing ("widening cues risks reopening the finding-A label-smuggling bypass") predates the round-3 never-fully-suppress invariant: an example-position
phrase.injectionmatch is re-floored to SOFT review, never invisible — so recognizing "Sample response:" has exactly the same worst case as the already-accepted "example"/quote paths.New
exampleLabelCue: closed example-adjective list + optional text-noun + colon, tail-anchored (label must immediately precede the match) and sentence-scoped (a prior-sentence "Sample …" lead can't reach across a period). Finding-A guards: bare labels without an example adjective ("Prompt:", "response:") still hard-fire — locked by new tests.Part B — secret-path sync
The sync between
security.GetFilePathPatterns()(runtime detector) andsensitiveFilePatterns(baseline scanner) was comment-only. New parity test makes it a CI gate (every paths.go glob must be matched by a baseline regex; superset direction intentionally allowed), and the 3 baseline-only patterns (.netrc,.kdbx,.pgpass) are back-ported into paths.go so the runtime detector agrees with the scanner.Verification
internal/security/...suite green under-racetier=soft / verdict=warnings; a real-injection control scanstier=hard / verdict=dangerousgolangci-lint(CI v2 config): 0 issues