Nano: a 10.9M-parameter detector of indirect prompt injection

Research preview from Hephaestus Lab (Medellín, Colombia), 2026-11-25.

Nano scores the text an AI agent reads from its tools (a web page, an email, a file, a tool result) and flags text that carries instructions aimed at the agent. It is a warning to put in front of an agent's permission system. It is not a security boundary: read "Where it fails" before relying on it.

  • 10,881,024 parameters, a byte-level transformer trained from scratch. No tokenizer.
  • Runs on a CPU. The 8-bit model file is 11 MB. On an 8 GB Apple M2 laptop, scoring takes 60 to 85 ms per kilobyte and about 100 to 115 MB of memory in ONNX Runtime (see "Cost").
  • Reads bytes, with no tokenizer to drop inserted, invisible or look-alike characters. That is a property of the input, not a claim of robustness: in an independent test half of the attacks hidden that way still got through.

Use

pip install onnxruntime numpy
python nano.py "text an agent read from a tool"
python nano.py --file page.txt

nano.py cuts the text into 95-byte windows every 48 bytes, scores each window and takes the highest. The score is the model's logit for "injected" minus its logit for "benign" at the end of the window. It is not a probability. A score above the value in threshold.json is flagged, and the script exits with status 2 when it flags and 0 when it does not. That threshold flagged 1% of 824 benign development documents; it is a measurement on that sample, not a guarantee on your text. nano-int8.onnx is the 8-bit model; nano.onnx is the same weights in float32.

Two consequences of the design to know before using it:

  • No window sees more than 95 bytes. An attack whose parts sit further apart than that cannot be recognised as one attack. Taking the highest window does not join them.
  • Longer documents are flagged more often. Every window is a chance for a false alarm. The script flags this model card itself (116 windows). The window it prints is where the score was highest, not an explanation of why.

How it was trained

  1. Data. Public agent and technical text, with attack lines and benign lines written by language models. One writer model is always held out of training, and its attack lines are a test of whether the detector learned attacks or learned its writers.
  2. One objective, two tasks. A small causal transformer learns to predict every next byte and, at the end of the window, the verdict. Without the next-byte task the verdict does not train at this size.
  3. Ten models, one consensus. Ten copies trained from different seeds disagree with each other; their average is far better than any one of them.
  4. One model taught by the consensus. A new 10.9M model is trained with the average of ten of our own 50.9M models (the same architecture, wider and deeper, trained on the same data) as a soft target beside the labels. It keeps most of the ensemble's gain at the cost of one model. Every model in the chain is ours and trained from scratch. No third-party detector was used as a teacher.

The released file is one of ten seeds of that last step (seed 6). Its own numbers are in the tables below beside the ten-seed means.

Results

These are development results. The scoring sets below have been read by several of our experiments. A final test set that no experiment has touched is not built yet, and the numbers on it may be lower. Means over ten seeds unless noted.

Each detector at its own shipped threshold (ours: 1% false alarms on development text; Prompt Guard 2: the 0.5 of its model card), recall in percent. Read this table with its last two rows: Nano's shipped threshold is looser than Prompt Guard 2's, and part of its higher recall is paid for in false alarms. The table after it holds false alarms equal.

Set Nano 10M, ten-seed mean Nano 10M, the released seed Prompt Guard 2 86M Prompt Guard 2 22M
AgentDojo 69.5 71.0 51.5 1.8
tau-bench 75.8 77.0 50.0 0.0
InjecAgent documents 75.7 79.4 51.0 3.5
LLMail-Inject sample 57.2 56.8 24.2 1.5
Attack lines by a writer held out of training 32.8 30.7 1.2 0.8
False alarms, README sample 2.3 4.2 0.0 0.4
False alarms, pooled held-out benign 0.5 0.5 0.8 0.1

Every detector at 1% false alarms fitted on each set's own benign documents, the stricter comparison of arXiv 2610.03448, recall in percent:

Model AD-Matched AD-Shift tau-bench
Nano 10M, ten-seed mean (standard error) 64.2 (2.1) 62.5 (2.1) 84.7 (0.5)
Nano 10M, the released seed 63.2 61.4 85.3
Prompt Guard 2 22M 59.0 69.0 38.2
Prompt Guard 2 86M 70.4 80.8 77.6

Prompt Guard 2's numbers are our own measurements of Meta's published models on the same sets, not Meta's figures.

Cost

Apple M2, 8 GB, ONNX Runtime 1.32 on the CPU with its default threads, 8-bit weights, batches of 8 windows. Two measurements, and they differ:

  • Ours: 62 ms per kilobyte and 114 MB of peak memory, over 817 KB of documents scored in one warm session, median of three passes.
  • An independent reviewer's, through nano.py: 81.5 to 84 ms per kilobyte on inputs of 100 bytes to 10 KB, and 101 MB for the whole process. The script's timer leaves out starting Python and loading the model; a whole run of the script took 128 ms for 100 bytes and 933 ms for 10 KB.

Prompt Guard 2 in PyTorch on the same laptop, our measurement: 43 ms per kilobyte and 2.7 GB (22M), 111 ms and 4.0 GB (86M).

An independent test of this release

A model from another vendor, which took no part in training or in writing this card, wrote 40 test texts of its own and ran them through nano.py on the day of release:

  • 7 of its 20 attacks were flagged (35%). By family: direct orders 1 of 4, fake system notes 1 of 3, polite task-aligned requests 1 of 3, conditional triggers 1 of 3, instructions split more than 500 bytes apart 1 of 3, zero-width or look-alike characters 2 of 4.
  • 0 of its 5 attacks in Spanish, French, German and Portuguese were flagged.
  • 0 of its 20 benign look-alikes were flagged.
  • The script flagged this model card.

A second model from a third vendor wrote 60 texts of its own, 150 to 3,000 bytes, and ran them through Nano and both Prompt Guard 2 models at their shipped thresholds:

Nano Prompt Guard 2 86M Prompt Guard 2 22M
Its 30 attacks flagged 10 (33%) 5 (17%) 0
Its 30 benign look-alikes flagged 8 (27%) 3 (10%) 0
Direct orders, of 6 5 5 0
Split payloads, of 5 2 0 0
Conditional triggers, of 5 2 0 0
Fake system notes, of 5 0 0 0
Polite task-aligned requests, of 5 0 0 0
Zero-width or look-alike characters, of 4 1 0 0
Non-English attacks, of 8 2 2 0
  • All three detectors missed 20 of the 30 attacks, among them every fake system note and every polite request that used no trigger word.
  • Nano flagged 8 of 30 benign texts written to look like attacks: two ordinary business emails, two sets of install steps, two instructions meant for a human, an agent notice and a security document. Prompt Guard 2 86M flagged three, all security documents. This is far above the false-alarm rates in our tables, and the first reviewer's 0 of 20 did not see it. On look-alike tool output Nano is the noisier detector.

A hundred texts by two writers are not a benchmark. They are the least favourable evidence we have, and they are lower than our own tables: about a third of fresh attacks caught, where our development sets read 57% to 76%. Read the tables with that in mind.

Where it fails

  • AgentDojo at equal false alarms. Prompt Guard 2 86M is ahead by 6 and 18 points, and the 22M by 6 on AD-Shift.
  • False alarms. About 2% of README files are flagged in our sample, more than Prompt Guard 2 at its shipped threshold, and the released seed reads higher than the mean. On benign text deliberately written to resemble attacks, an independent reviewer saw 8 of 30 flagged, ordinary emails among them. Expect more false alarms than our tables suggest on text unlike our development sets.
  • Languages other than English. The independent test's five non-English attacks all got through. Almost all of the training text is English. Do not rely on it for other languages.
  • Coverage. A survey of 2025 and 2026 attack techniques found 96; our training lines cover 13 in full. Split payloads, tool descriptions and markdown image exfiltration are thin or absent. The training text is short single lines, not the long structured documents agents read.
  • Split attacks. Beyond thin training data, the 95-byte window makes these out of reach by construction.
  • Shortcuts. In the training lines a URL appears far more often in attacks than in benign text. Part of what the model flags may be that.
  • Adaptive attacks. Measured against fixed attack sets only. An attacker who knows the detector can evade it, as with every published detector we know of.
  • tau-bench is partly lexical. A plain byte n-gram model reaches 68.5% on it under the stricter rule, so our lead there says less than the AgentDojo lines do.
  • No small-board measurement yet. Speed and memory are from a laptop.
  • Not reproducible from this repository alone. It holds the model and the script. The training data, the splits, the evaluation code and the per-seed results are not released yet, so the tables cannot be audited from here.
  • A clean verdict is not evidence that a text is safe.

How the work was done

One person, one 8 GB laptop and about 26 USD of rented GPU time. Every experiment has its pass rule written before the run, a control arm and ten seeds; a difference counts when it exceeds twice its standard error. Results that went against us are kept: weight patches proposed by large models, recurrent and gated-convolution mixers and longer training schedules did not beat the simple model.

The detector is part of Hydra, an open-source agent harness: github.com/FrankMdza/hydra-harness

Contact: Fr4nk@hephaestuslab.co

Licence

Apache 2.0.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support