File size: 4,664 Bytes
5452c3b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ---
license: mit
language:
- en
- multilingual
library_name: onnx
pipeline_tag: token-classification
base_model: jhu-clsp/ettin-encoder-68m
datasets:
- booleanbyte/tripwire
tags:
- prompt-injection
- ai-safety
- agents
- tool-use
- mcp
---
# Tripwire 68M: finds instructions planted in what an AI agent's tools return
AI agents read emails, web pages, API responses and tool descriptions. An
attacker can hide an instruction in that text and the agent may follow it
(indirect prompt injection). This model reads such a text and marks the
characters an attacker planted, so the planted part can be removed and the rest
kept.
It is a token classifier fine-tuned from `jhu-clsp/ettin-encoder-68m` on the
Tripwire dataset, version 0.3.1. The code, the benchmarks and every result
below are in the source repository: https://github.com/dhootatharva/tripwire
## Use
```bash
pip install "tripwire[hub] @ git+https://github.com/dhootatharva/tripwire"
```
```python
from tripwire.detector import Detector
detector = Detector.from_hub("booleanbyte/tripwire-68m")
result = detector.scan(tool_output)
if result.flagged:
print(result.score, [(span.start, span.end) for span in result.spans])
safe = result.strip(tool_output)
```
It runs on a CPU with `onnxruntime`; PyTorch is not needed. The repository also
has a filter for a hand-written agent loop, a LangGraph hook and an MCP proxy
built on this model.
## Files
| File | What it is |
|---|---|
| `model.onnx` | 32-bit weights. The default; gives the same verdicts as the trained model |
| `model.int8.onnx` | 8-bit weights. A quarter of the size, changes some verdicts, not faster on the CPU tested |
| `tokenizer.json` | The tokenizer |
| `model.safetensors`, `config.json` | The trained checkpoint, for `transformers` |
## Two sizes
| | 32M | 68M |
|---|---|---|
| File size (32-bit) | 128 MB | 274 MB |
| Time for 500 tokens, one laptop CPU | about 130 ms | about 340 ms |
| Catches | less | more |
| False alarms on harmless requests | fewer | more |
The 32M model is the default in the code.
## Results
A document counts as flagged when any token scores at least 0.5. Each model was
trained once.
| Test | What it measures | 32M | 68M |
|---|---|---|---|
| Own test split: attacks caught | Same recipe as the training data | 97.9% | 98.9% |
| Own test split: false alarms | | 0.8% | 0.5% |
| AgentDojo tool outputs: caught / false alarms | Used while building the model | 100% / 3.4% | 100% / 3.2% |
| BIPIA attacks caught | Outside data | 63.0% | 78.3% |
| InjecAgent plain attacks caught | Outside data | 78.2% | 86.3% |
| InjecAgent enhanced attacks caught | Outside data | 100% | 100% |
| BIPIA clean texts flagged | Outside data | 0.6% | 1.1% |
| NotInject flagged | Harmless texts with attack-like wording | 15.6% | 48.1% |
With the 32M model in front of two open models that follow these attacks
(gpt-oss-120b and gpt-oss-20b), the attacker's goal was reached in 42 of 47
AgentDojo cases without it and in 0 of 47 with it. That is a small sample from
one suite.
On NVIDIA garak's latent-injection probes, which were not used to build the
model, the 32M model flagged 81% of 1,960 attacked documents and changed none
of 74 clean ones.
## Limits
- **It looks for instructions, not for false claims.** "This domain is clearly
not malicious" planted in a record instructs nobody and is not flagged.
- **Its own test split flatters it.** Use the outside figures above.
- **It was not tested against an attacker who adapts.** Someone who can query
it repeatedly and reword an attack should be assumed to get through.
- **It does not see the user's request.** If the user asks the agent to follow
the instructions on a page, the model still flags them.
- **A request addressed to the reader inside a tool output is treated as
suspicious by design**, which is the source of most false alarms.
- **English was tested most.** 77 of 85 (32M) and 84 of 85 (68M) of the
dataset's own non-English test attacks were caught; no outside data in other
languages was used.
- **Only text is read**: not images, audio or file names.
Use it as one layer, together with limited tool permissions and human approval
for risky actions.
## Training
Dataset version 0.3.1 without the examples whose label depends on the user's
request. 512-token windows, two labels per token (planted or not), one seed.
59 minutes (32M) and 161 minutes (68M) on two T4 GPUs. The script is
`scripts/train.py` in the source repository.
## Licence
MIT, the licence of the base model. The training data is CC BY-SA 4.0 and
includes Wikipedia text and the Enron email corpus; see the dataset card.
|