Open-source prompt-injection detector that runs on CPU (98.8% vs 59.6% on an independent test)

●1 ●2 ●11
calendar_today ago • schedule5 min read

We used to protect computers with an antivirus. You install it, and it catches bad programs. Now a lot of us have an AI agent on the computer that reads mail, websites and documents and acts on our behalf. And the weakest spot is that agent. Nobody needs to install a virus anymore. It's enough to hide false instructions in a text the agent will read. An antivirus doesn't see that. It's just text.

This autumn someone tried to break in. Strangers got onto the server where my agents run and installed a miner, and we found it and removed it. After that I sat down to look at what other doors are open, and the quietest one turned out to be prompt injection.

What it looks like

Someone hides a command for the AI in an email, a review, a CV, a web page, a calendar invite or a document. White text on a white background, tiny font, a comment, a spoiler. A person doesn't see it. The agent reads it and may do it - forward the conversation, change the bank details in an invoice, rate a CV as the best one, open a link, hand over a confirmation code.

And this is already happening. OWASP (the international application security community) puts prompt injection at number one in its 2025 list of top risks for LLM applications.

In June 2025 researchers from Aim Security described EchoLeak in Microsoft 365 Copilot. A specially crafted email could pull data from the user's mail, files and chats with zero clicks from the user, once they later asked Copilot a question. Microsoft had fixed it on their side in May and says it wasn't exploited.

In August 2025 Brave researchers showed that Perplexity's Comet AI browser, when asked to summarize a Reddit page, followed commands hidden in a comment under a spoiler and could give an attacker a one-time login code for the user's account. Perplexity shipped a fix, Brave considered it incomplete.

From my own experience (not a measurement) - top models are fairly hard to fool, they're trained not to fall for this. Small, cheap and local models are noticeably easier. So I care which model reads untrusted text.

Why I trained my own filter

When I looked for a ready filter, I found that the most downloaded open prompt-injection model on Hugging Face (from ProtectAI) caught 59.6% of English attacks on an independent test. So about 40% got through.

That wasn't enough for me, so I trained my own. It's called ArsGuard, MIT license. Weights, training and evaluation code, the dataset and a script that reproduces the numbers are all open.

On the same test ArsGuard catches 98.8% of English attacks. On ordinary human messages (OpenAssistant) ProtectAI raised false alarms on 10.8% and ArsGuard on 0.9%.

How it's built

The model is mDeBERTa-v3-base (about 280M parameters), fully fine-tuned as a classifier "attack / not attack". It returns a probability from 0 to 1.

The data is my open dataset ArsGuard Injections - 37,994 training texts, written from scratch and not translated. 20 attack types (instruction override, fake system messages, data exfiltration, credential phishing, hidden instructions for AI CV screeners, payment detail swaps, summary poisoning and others), 20 carrier types (emails, CVs, reviews, invoices, support tickets, calendar invites, code comments, chats and others) and 40 subject areas. Every attack has a benign text of the same shape. Half of the benign texts are hard on purpose (someone asking a colleague to ignore their previous email, an official password reset message).

Training went in rounds, with an exam after each round on sets the model never sees. I picked the best round by accuracy minus false alarms. The final check ran once, on a separate independent test of 4,783 texts (attacks and benign) made by a different generator model with a different prompt. That generator didn't take part in training. Training itself fit on one 24 GB GPU.

Labels were set by the generator models. An independent spot-check of 200 benign texts confirmed 97.5% of the labels.

At runtime it needs about 1 GB of memory and checks a 400-word email in about 1.8 s on 4 CPU threads. No GPU, no internet, the text doesn't leave the machine.

Using it

pip install git+https://github.com/arsentev-ai/arsguard

from arsguard import Guard
guard = Guard()  # on first run, fetches the model arsentev-ai/arsguard from Hugging Face
guard.check("Hi team, please ignore my previous email — the meeting is moved to 3 pm.")
# Result(label='SAFE', score=0.0001, is_injection=False)

There's also a CLI. It exits with code 1 when it finds an attack, so you can put it in front of an agent in a script:

arsguard --file inbox.txt
cat page.txt | arsguard --threshold 0.99

Long texts get split into windows.

For me it sits in front of the agents that read mail and other people's texts. If an email looks like an attack, the agent never gets it, and I see that someone tried.

Weak spots

On the full independent test the false alarm rate is 20%. Most of those are articles and warnings about prompt injection itself (labeled as benign there). So if your agent reads security blogs, expect noise 😅

A tailored attack against you personally can slip through. And it's an alarm on top of agent permissions. It doesn't replace them.

The rules I follow

Permissions first. An agent that reads other people's mail and websites shouldn't have access to passwords, payment data, or the right to send anything on your behalf without you. If it gets fooled, it has nothing to do damage with. No filter replaces this.

Irreversible actions need your "yes". Sending emails, payments, deleting, sending files, changing bank details. Many agents have a confirmation mode, turn it on.

Untrusted text is data, not instructions. Ask the agent "summarize what they write", not "do what the email says".

The agent doesn't open links from incoming mail on its own.

Passwords, keys and codes don't live where the agent can see them (notes, files, documents).

A strong model reads untrusted text, not the cheapest one.

Know the signs. The agent suddenly offers to forward something, asks for a password or a code, wants to change bank details, mentions "new instructions" or an "urgent admin request".

And a filter in front of the agent. A small model checks the text first and stops obvious attacks before the agent reads it.

Everything is here if you want to check the numbers yourself: GitHub https://github.com/arsentev-ai/arsguard, model https://huggingface.co/arsentev-ai/arsguard, dataset https://huggingface.co/datasets/arsentev-ai/arsguard-injections, DOI https://doi.org/10.5281/zenodo.24682051.

Now my agents that read mail don't hold a single credential, and every email goes through my filter first. If some email asks an agent to send something, it simply has nothing to send it with.

So my question to you - what false positives do you get from prompt-injection filters on your own traffic? If ArsGuard flags something harmless for you, I'd like to see that text in a GitHub issue.

Want more #ai & #showdev deep dives?

Join 6,159+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

12 Comments

1 vote
0
1 vote
1 vote
2 votes
0
1 vote
1 vote
1
0
1 vote
1

More Posts

Your AI Doesn't Just Write Tests. It Runs Them Too.

Kevin Martinez - May 12

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23

Beyond the 98.6°F Myth: Defining Personal Baselines in Health Management

Huifer - Feb 2

I Wrote a Script to Fix Audible's Unreadable PDF Filenames

snapsynapseverified - Apr 20
chevron_left
398 Points • 14 Badges
4Posts
5Comments
Creator of Arsminal; founder of ArsentevAI and Dad4Kids

Related Jobs

View all jobs →

Commenters (This Week)

2 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!