Prompt injection defence in BleedStop is a stack of checks in front of the model, not one classifier score. The default check is a phrase list. A DeBERTa classifier is a second stage I turn on, and on my held out set it caught 77.5% of injections at a 5% false positive rate.
The layers I put in front of agents
Everything in this post is from the BleedStop case study or from the public repo, usmamalik345/bleedstop, especially the README and classifier/server.py. The spend guard around these checks is in the BleedStop deep dive.
What runs if I change nothing
The phrase list is the default detector. The README says the ONNX sidecar runs only when BLEEDSTOP_DETECTOR is classifier or both. Until that flag is set, the live demo's server check is the phrase list. The model that runs in the browser on the demo page is a demo only. It does not protect the API.
On the phrase list, the honest held out number is weak. The README's agent guard row calls the held out set 22.5%, with 0% false positives, and calls that the honest number. A later note in the same README, phrase list only, cutoff 0.6, normaliser off, is the same rate as a fraction: 9 of 40 on the held out set (N=80, false positive rate 0 of 40). Dev, which the regex was tuned on, is 53 of 55 (N=112, benign 57, false positive rate 0 of 57), which is the 96.4% in the summary table. Lowering the cutoff to 0.3 did not raise dev recall and raised the dev false positive rate to 1 of 57, so the cutoff stayed at 0.6. Turning normalisation on did not raise dev recall. BLEEDSTOP_NORMALIZE stays off.
That is why I do not lead with 96.4%. That figure is the set the phrase list was tuned on.
The second stage, when I turn it on
classifier/server.py serves protectai/deberta-v3-base-prompt-injection-v2 with FastAPI. With CLASSIFIER_URL set, /agent/precheck and the MCP gateway run the regex first, then the classifier. There is also a small ONNX sidecar under services/classifier/, on CPU, the same 8 bit model the browser demo can load. The case study describes that browser build as a DeBERTa classifier quantized to 8 bit.
Mode both runs the phrase list first and sends only text the phrase list allowed on to POST /classify. The timeout is BLEEDSTOP_CLASSIFIER_TIMEOUT_MS, default 800. If the sidecar is down or slow, BLEEDSTOP_CLASSIFIER_FAILMODE=open is the default: keep the phrase list verdict, log a warning, and increment bleedstop_classifier_errors_total. closed turns that outage into a block. That is safer against injection, and it also means a dead sidecar stops those calls.
The README's comparison, which is the table I trust for this post, is:
| Set | Phrase list recall / false positive rate | Classifier recall / false positive rate | Two stage recall / false positive rate |
|---|---|---|---|
| deepset/prompt-injections, all 662 | 4.2% / 0% | 41.4% / 1.0% | 41.4% / 1.0% |
| BleedStop held out, 80 | 22.5% / 0% | 77.5% / 5.0% | 80.0% / 5.0% |
| BleedStop dev (phrase list tuned on it), 112 | 96.4% / 0% | 83.6% / 7.0% | 96.4% / 7.0% |
The 77.5% at a 5% false positive rate on the case study is this classifier row, held out, N=80. It is not the phrase list. Two stage recall on that set is 80.0% at the same 5.0% false positive rate, slightly higher than the classifier alone.
Latency in the README, on 4 CPU threads: phrase list p50 about 9 microseconds; classifier p50 about 46 to 49 ms, p99 55 to 132 ms. The README's caveats, which I share: deepset includes German rows and the model is English only; training overlap with public sets cannot be ruled out; the PINT row in the report is the public 8 row example file, not a PINT score; Llama Prompt Guard 2 is gated and I did not evaluate it.
The browser build is the same DeBERTa v2 model in the visitor's browser with onnxruntime-web, an 8 bit weight only build (256 MB, served from GitHub Pages, loaded only on click). Against the fp32 ONNX it gave identical labels on the held out, dev and deepset test sets. Single threaded inference was p50 245 ms in headless Chrome on the build box. That check is still a demo. Server side enforcement on the live demo remains the phrase list until BLEEDSTOP_DETECTOR is set. The README says free Docker hosting for the sidecar was not available, because Hugging Face Docker Spaces need a PRO plan, which is why the demo can run the model in the browser instead.
The decision is still not the model
A detector score does not spend money. POST /decide still returns ALLOW, LIMIT, CHALLENGE or DENY from the rules, and Redis still enforces the budget. The golden set on the case study is a different measurement from the injection table: 12,140 labeled requests, precision 100%, benign false positive rate 0.0%, recall 48.0%. The golden set and the rules share an author, so I do not call that a field result.
On the MCP path, the README says every tools/call goes through, in order: a definition pin (trust on first use, sha256 over name, description, inputSchema and annotations), a tool description poisoning scan, a per tenant Cedar policy in config/mcp-policy.cedar, the agent injection guard on the arguments, then the normal budget decision. Tool results are scanned for indirect injection. MCP_GATEWAY_MODE=shadow logs without blocking. The threat mapping is in docs/THREAT-MODEL.md.
For npm run evals:mcp, 70 hand written tool definitions, the README reports poisoning scan precision 100%, recall 80% (20 of 25), false positive rate 0% (0 of 45). Rug pull detection caught 180 of 180 mutations, with 0 false alarms on 45 unchanged lists. Added latency per tools/call over HTTP, n=2000, was p50 2.21 ms, p95 2.84 ms, p99 3.89 ms. The misses are the 5 of 25 poisonings the README calls subtle and polite, with no trigger phrase. I wrote that eval set, so I treat the recall as optimistic. The README says the same.
What I will not claim
- I will not quote 96.4% as held out performance. That is the dev set the phrase list was tuned on.
- I will not quote 77.5% as the phrase list. That is the classifier, on the held out set of 80, at a 5% false positive rate.
- I will not say the browser model protects the API. It does not.
- I will not say the server classifier is on in the public demo. It is off until
BLEEDSTOP_DETECTORis set. - Fail open means a dead sidecar keeps the phrase list verdict. If you need a dead sidecar to block, that is the closed mode, and it will also block when the sidecar is simply down.