When Benchmarks Lie: Evaluating Malicious Prompt Classifiers Under True Distribution Shift
Being Serious about Agentic Security
| If you develop or buy a security system for AI agents, you should ask yourself the following: |
|
Building in The Open |
| Not only we address the above questions in this post (maybe it will become a series), but we also release everything we did in this research: |
|
The Flow |
| Business case: given an input from a user (whether a single prompt or a multi turn conversation), classify it as malicious or benign. This allows alerting or blocking the conversation based on customer severity definitions. “Malicious” is any input that tries to manipulate the agent, extract secret information, harmful requests of any kind or inappropriate usage. |
| Below is a description of the system we built, the data we use, how we test it for out-of-distribution classification, and a glimpse on interpretability (why was the input tagged as malicious/benign) |
| An overview of the whole system. We’ll unpack it step by step in the next sections |
System |
|
Data |
| We use 18 publicly available datasets across different categories: benign business cases, harmful requests, jailbreaks, indirect prompt injections, secret knowledge extraction attacks. See a few examples below: |
Unlike prior works on activation probes that operate on proprietary data or train and test on a single dataset, we believe that: (1) diversity of data sources is key for a robust security system and (2) using open datasets allows other practitioners to reproduce and improve upon our methods. |
Out-of-Distribution Evaluation |
| This is by far the most important part of this research—not the model, not the data, but how to evaluate it for a novel, unseen test data. You can have the most amazing model with plenty of training data, but just lie to yourself and get great evaluation metrics, while completely failing in production. |
| The idea is surprisingly simple, yet most people who do AI security don’t bother to do it. Instead they take the common ML approach: |
| Split the data into training, validation and test sets: train on the training set, calibrate parameters on the validation set, and finally test on the test. |
| What we do instead is hold an entire dataset out of the training. Say we have 18 datasets: |
|
| The test set is never seen by the training. Not a glimpse, not a subset, nothing. It’s a true out-of-distribution evaluation. And it’s hard! It really tests whether the model generalizes to the unseen test sets and doesn’t rely on a hidden similarity between the splits from the same data (as is done in common the train-val-test split). |
If someone were to show you a system with a test accuracy like the “Test Acc” above—you would buy it probably. But the “LODO Acc”? No way. |
Comparison to Opensource Alternatives |
| We have compared our classifier to 3 open alternatives: |
|
| For this comparison we divided the 18 datasets above into categories: |
|
| The metric in the table below is recall (% of malicious prompts correctly detected as such), and the last row is FPR (% of benign prompts incorrectly detected as malicious) on benign data. |
| Category | Prompt-Guard | Llama-Guard | Llama-Judge | Ours—Low threshold | Ours—High threshold |
|---|---|---|---|---|---|
| Harmful | 36.7 | 97.4 | 85.2 | 69.7 | 64.7 |
| Jailbreak | 48.5 | 28.9 | 60.0 | 71.2 | 59.5 |
| Indirect | 37.3 | 27.4 | 7.1 | 66.7 | 53.1 |
| Agentic | N/A | N/A | 21.5 | 99.2 | 91.5 |
| Extraction | 100.0 | 15.2 | 31.8 | 79.2 | 68.7 |
| Mixed | 54.5 | 38.8 | 73.8 | 83.3 | 74.9 |
| Benign FPR | 0.4 | 3.0 | 4.4 | 6.8 | 3.7 |
| A few things jump to mind here: |
|
We have also compared it to one of our proprietary detection systems, with some models there being many times the capacity of Llama 8B, and found this solution to be competitive with the larger system, exceeding it on several categories. |
Understanding the Decision |
| Now we have this system working, it monitors user interactions with their agents, and suddenly it fires, classifying the interaction as malicious. Why did it reach this decision? Could you explain it to the user that was blocked? |
| You could get the full convo transcript, read and analyze it (or feed it to another expensive LLM judge). This will work but has 2 downsides: |
|
| Instead we decided to do the following: here’s a simple made up prompt that uses roleplay to elicit the model to help build a bomb. |
| This is of course classified as malicious by our system, but could we say why if we couldn’t see the prompt itself? Turns out that we could! Remember the Sparse Autoencoder (SAE) features we mentioned earlier? These are extracted from the raw model activations and are supposed to represent meaningful semantic concepts. |
| We build another classifier (that can work in tandem with the main one, at a negligible compute cost), that is based on these SAE features. Look what it raised on the prompt above (an example of a few features, there are many there): |
|
| By leveraging the SAE features interpretability, we can provide an explanation of why the interaction was classified as malicious, without the need to process or store it. This approach has limitations—there are many features that fire, some aren’t so interpretable or related to the topic. Yet it still provides a fast and relatively clear diagnostic for malicious decisions. |
A Call for Different Security Paradigms |
| If you’re a researcher, practitioner or customer of agentic security systems, we strongly suggest you give a thorough consideration for the following aspects: |
|
Interested to deep-dive? Read the full paper The original post was published here |
It’s a great post! I would add that, we need to look beyond user’s inputs for malicious intents, we also need to look at when the model at its reasoning layer builds an increasingly accurate picture of the user’s psychological weaknesses, and acts in real manipulation mode (sycophancy).
Thank you! I agree that reasoning tokens can be a potential probing location, and there are several works that demonstrate probes on them (for instance to detect hallucinations).
However there’s a distinction here about what we’re trying to detect—in this work we assume there’s a groundtruth, i.e either the input is malicious or it’s benign, regardless of what the model does with it (how its generation goes). We’re interested in recovering this groundtruth and the model serves as a feature extractor for that. So for this specific purpose it doesn’t really matter how the model reasons about the request or if it even verbalizes the presence of an attack, as long as the activations encode it