Prompt-Injection Defenses Playbook & Detection Ruleset
by Rob Louw
$39
6 defense layers, 119 machine-readable detection rules, and a working scanner with measured accuracy. The hardening counterpart to a test corpus, for teams who need concrete mitigations and honest numbers.
Prompt injection has no known complete fix. This gives you defense-in-depth: a structured playbook, a ruleset you can run today, and a detector whose recall and false-positive rate we measured and publish, including the parts that are unflattering.
NEW IN THE 2026-10-04 EDITION
Measured for the first time. The original 85 rules, as written, flag 69% of ordinary top-site homepages and catch 39% of held-out attacks. Both numbers are in the box (MEASUREMENTS.md) because you should know them.
Two profiles. Strict runs every rule as written, for tool-call arguments and outbound responses. Content is tuned for web pages, retrieved documents and inbound messages: 0.35% false positives on 1,714 unseen top-site homepages.
34 new extended rules that pair an address to an AI with an imperative, a verb of disclosure with a system prompt, an action with "without telling the user".
Decode-and-rescan. Zero-width splitting, Unicode tag characters, leetspeak, one-character-per-line text, lookalike letters, hex, base64, percent-encoding and ROT13 are undone, then the instruction rules run again. 78% held-out recall on obfuscated attacks.
Hidden-text scanning for HTML comments and alt, title, aria and meta attributes.
Held-out recall: 53% strict, 38% content. Pattern rules are a first filter, not a defense on their own, and the playbook layers are what make a missed injection survivable.
WHAT'S INSIDE
PLAYBOOK.md: threat model + 6-layer defense taxonomy (Input Handling & Provenance, Prompt Hardening & Spotlighting, Tool & Permission Design, Output & Egress Filtering, Monitoring & Canaries, Human-in-the-Loop), each with concrete DO/DON'T guidance and an explicit attack-category mapping.
rules/detection-rules.json: 85 base rules across all 7 attack categories. Every rule discloses its own false-positive notes.
rules/detection-rules-extended.json: 34 extended rules, same schema, same honesty about false positives.
detector/scan.py: Python 3.8+ standard library only. Both profiles, decode-and-rescan and hidden-HTML-text scanning. CLI or importable. Gives the same answers as the hosted scanner at fetchgate.dev/v1/scan (1,912 of 1,912 parity checks).
MEASUREMENTS.md: recall on the 156-case corpus (development and held-out halves), false positives on 4,435 top-site homepages, method and limits.
GUIDE.md: a 4-phase adoption plan, which profile to use where, and tuning guidance.
Try before you buy: the same detector is free to use at fetchgate.dev/tools/injection-scanner, and the full write-up is at fetchgate.dev/blog/prompt-injection-rules-measured. A sample of 10 of the base rules is at github.com/roblouw2nd/fetchgate/samples/injection-defenses.
Grounded in OWASP's LLM/MCP Top 10, Simon Willison's Dual LLM pattern, Google DeepMind's CaMeL architecture, and current canary/egress-filtering practice. Full citations in PLAYBOOK.md.
WHO THIS IS FOR
Teams building or operating an agent/LLM app with tool access, retrieval, or any path for untrusted content to reach the model, who need immediately-actionable hardening.
Pairs with Fetchgate's Prompt-Injection & Tool-Hijack Test Corpus ($29, growthchief5.gumroad.com/l/injection-corpus): 156 labeled attack cases across the same 7 categories, to test these defenses against.
Honest limits: a heuristic first line of defense, not a safety guarantee. Held-out recall is 38 to 53%, lowest on jailbreak framing and system-prompt extraction. The corpus and the rules share an author, so expect lower recall in the wild. Two placeholder values in the tuning guidance must be filled in for your own traffic.
Single-team internal use. Sold by Fetchgate (fetchgate.dev). One-time purchase.