A local prompt-injection filter on CPU in front of email-reading agents
- Key gotcha
- On the independent test it gave 20% false alarms, mostly on articles and warnings about prompt injection itself, so an agent that reads security blogs will see noise
What they built
Evgenii Arsentev runs AI agents that read mail and other people's texts. This autumn somebody got onto the server where those agents run and installed a miner, and when he checked what other doors were open, the quietest one was prompt injection: instructions hidden in an email, invoice, CV or web page that the agent reads and may follow.
The open filters he found were made mostly for English; the most downloaded one on Hugging Face caught 37.1% of native Russian attacks in his test. So he fine-tuned mDeBERTa-v3-base as an attack / not-attack classifier called ArsGuard, trained on his own English, Spanish and Russian dataset of attacks paired with normal texts of the same shape.
It runs on a normal computer without a GPU and without internet, and the text doesn't go anywhere. He puts it in front of his mail-reading agents so a suspicious email never reaches them.
Setup
- mDeBERTa-v3-base fully fine-tuned as an attack / not attack classifier
- Runs on CPU without a GPU and without internet, about 1 GB in memory
- Installed from GitHub as a Python package; the model is pulled from Hugging Face on the first run
How it works
- guard.check() returns a label and a probability from 0 to 1 for any text
- A terminal command returns exit code 1 when it finds an attack, so it can sit in a script right before the agent
- Long texts are cut into windows, so a big page is fine
- Trained in rounds, picking the best round by accuracy minus false alarms, then checked once on an independent test of 4,783 texts made by a different generator model
Results & numbers
- On the independent test it catches 99.7% of Russian attacks, and does better than the ProtectAI model on English and Spanish too
- A 400-word email takes about 1.8 seconds on 4 CPU threads
- On ordinary human messages from OpenAssistant, false alarms were under 1%
Gotchas
- On the independent test it gave 20% false alarms, mostly on articles and warnings about prompt injection itself, so an agent that reads security blogs will see noise
- A clever attack written for you personally can slip through; it is a filter, not a replacement for the agent's permissions
- Small, cheap and local models are much easier to fool than top models, so it matters which model reads other people's text
“It's a filter, not a replacement for the agent's permissions.”— Evgenii Arsentev
Do it yourself
- Install the package with pip from the arsentev-ai/arsguard GitHub repo
- Check a sample email with guard.check() or pipe a file through the arsguard command
- Put the command in your script before the agent and stop when it exits with code 1
- Also strip the agent's access to passwords, payment data and sending, and confirm anything you can't undo
pip install git+https://github.com/arsentev-ai/arsguard
arsguard --file inbox.txt
cat page.txt | arsguard --threshold 0.99Similar setups
Haunted Inbox: a local Gemma 4 E2B finds the forgotten accounts in 12 years of email
Niraj Khetre built Haunted Inbox, which reads only email envelopes on his laptop, has Gemma 4 E2B in Ollama spot sign-up accounts, and lets plain code report breaches, saved cards and delete links.
A read-only Gemma 4 agent on Ollama that explains what fills a Mac's disk
A sysadmin's one-file Python agent lets Gemma 4 on Ollama dig through his home folder and write a Markdown report on disk usage, while code and a four-line macOS sandbox-exec profile make sure it can only look.
PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU
WiseProbe adapted its PatchPal coding agent to run Gemma 4 E4B or Qwen3.5 4B through Ollama on a 6GB RTX A1000, using handoff-note compaction and capped file reads to work inside a 16K or 32K window.
Checking who can reach a local Ollama and no-auth MCP stack
A developer audited their Mac's local AI stack and found an unauthenticated MCP search server open on the LAN address and a loopback-only Ollama still answering every Podman container.