feat(sable-h6r): consolidate prompt-injection detector — Node + Python parity, hidden behind --experimental flag#118
Merged
Conversation
…n parity, hidden behind --experimental flag Pattern-based PromptInjectionDetector with parity in Node and Python. Hidden behind experimental flags pending APPROVE bead rf-i17 — do not merge to main. Consolidated from drafts PR #60 (feat/prompt-injection-detector) and PR #82 (polecat/granite-mokqoiob); both PRs point at the same head commit, so baseline #82 was used and #60 contained no additional content. Surfaces: - rafter scan injection <path> (hidden subcommand) for spot checks - rafter hook posttool --experimental-prompt-injection flags injection markers in tool responses to stderr (does NOT modify the response) Detector categories: role-override (jailbreak phrases, "ignore previous instructions", DAN, role-confusion), tool/exfil (remote-pipe-shell, "send api keys to ...", "delete all files"), hidden Unicode (tag chars U+E0000–U+E007F, bidi override, zero-width-in-word), HTML/markdown comment imperatives, and base64-decoded payload re-scan (indirect/RAG-fetch injection). Output: structured finding with category (pattern name), severity (low|medium|high|critical → confidence), evidence and remediation hint; aggregate score 0-100 and verdict ∈ {clean,suspicious,likely_injection}. Default behavior: warn only (stderr). Block behavior requires explicit opt-in via .rafter.yml; no default surface changes for non-opted users. Documented threat model, prior-art survey, FP/FN tradeoffs, and known bypasses in docs/research/prompt-injection-detector.md. Tests include positive corpus, clean-baseline guards, and explicit known-bypass fixtures so future improvements have a target. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
Author
Security review notes (rafter-code-review, CLI category)Walked CWE-Top-25 cross-language + JS/TS + Python + investigation-playbook input-shape questions. No merge-blocking findings. Checked:
Low-severity observation (non-blocking):
Approved for merge to maylist. The PR #82 "DO NOT MERGE pending rf-i17" gate still applies at the maylist→main promotion boundary — that's the right place to enforce it. |
Rome-1
added a commit
that referenced
this pull request
May 19, 2026
Audit pass deferred from sable-bum / PR #122. Adds concrete mechanical checks for the realistic install-time risks of third-party SKILL.md, MCP manifest, Cursor rule, or agent config: - prompt-injection in the skill body - hidden tool invocations in install steps (curl|sh, npm postinstall) - exfiltration patterns (curl to attacker host, base64 phone-home) - overbroad allowed-tools grants - typo-squat / stale package names - skills that sabotage / disable peer skills - sensitive-path reads (~/.ssh, ~/.aws/credentials, keychain) - MCP manifests granting servers/tools silently SKILL.md changes: - new "Watch-items at a glance" table pairing each risk with a grep/jq/CLI check and the sub-doc that covers it - step 0 now points at `rafter scan injection` as a complementary mechanical pass alongside `rafter skill review` - canonical-command note clarifies `rafter agent audit-skill` is the deprecated alias (matches sable-bum edits to sibling rafter SKILL.md) - fast path is now a runnable three-step script - decision rule is now four items (adds the injection-scan gate) Sub-doc edits (additive, no restructure): - prompt-injection.md: new §0 mechanical-first-pass with `rafter scan injection` (cross-link to PR #118 / sable-h6r detector) - data-practices.md §5: explicit allowed-tools reconciliation check; calls out the "markdown formatter asking for Bash" red flag - authorship-provenance.md §4: concrete `npm view ... time.created` typo-squat command plus three in-the-wild examples - malware-indicators.md §6–7: consolidated grep commands for privileged writes and intelligence-gathering primitives Files: 5 Node + 5 Python mirror. `diff -rq` empty. Punted (future bead candidates): - supply-chain-risks.md sub-doc consolidating §4 (typo-squat) + changelog-review §6 (dependency drift) + malware §3 (postinstall) — currently scattered across three docs - agent-config-specific.md sub-doc for MCP manifest / Cursor rule / Continue rule schemas (currently MCP is one row in the table only) - post-install detection: this skill is pre-install only; a sibling "post-install audit" skill could cover installed-skill drift Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Consolidates the in-flight prompt-injection detector (drafts #60 and #82 — same head commit `6d9b91b`, so #82 is baselined) onto `maylist`. Hidden behind `--experimental` flags; default behavior unchanged for non-opted users.
Detector
Pattern-based, English-only, deliberately zero-dependency. Five categories:
Defenses against pathological input: 1 MB cap on scan input (truncated before regex), base64 re-scan gated on chunk length, no catastrophic-backtracking regex shapes.
CLI surface (all opt-in)
JSON output shape (documented in `shared-docs/CLI_SPEC.md` "Experimental Commands")
```json
{
"findings": [{ "pattern", "category", "severity", "offset", "evidence", "remediation" }],
"score": 0–100,
"verdict": "clean" | "suspicious" | "likely_injection"
}
```
Files
No new deps.
Status note re: existing drafts
This PR supersedes drafts #60 and #82 (both point at the same head commit `6d9b91b`; nothing #60-unique to salvage). Once this merges to maylist, close #60 and #82 with a "superseded by sable-h6r / PR #118" note.
PR #82 noted "DRAFT — DO NOT MERGE pending rf-i17". That gate still applies at the maylist → main promotion boundary. This PR is mergeable to maylist (it's hidden behind flags), but rf-i17 should be granted before this work crosses to main.
Target: `maylist`.
Closes sable-h6r (A4 from maylist).
Test plan
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com