When Benchmarks Lie: Evaluating Malicious Prompt Classifiers Under True Distribution Shift

Max FominAIWILD @ ICLR 2026

TL;DR

Current methods for detecting malicious prompts in LLM agents severely overestimate their real-world performance by relying on benchmarks that don't reflect distribution shifts. This paper introduces a more rigorous evaluation protocol (LODO) and reveals that many classifiers exploit dataset-specific "shortcuts" rather than genuine attack patterns, leading to significant performance drops when encountering unseen data.

What Problem Does This Paper Address?

As LLM-based agents become more integrated into autonomous systems, they increasingly process external data sources like emails, documents, and API responses. This opens them up to security vulnerabilities such as prompt injection and jailbreak attacks, where malicious instructions can hijack agent behavior. While many methods have been developed to detect these attacks, their evaluation often relies on standard cross-validation techniques where training and testing data come from the same sources. This can lead to an overestimation of generalization capabilities, as classifiers might learn to identify the source of the data (e.g., "this email looks like it's from Enron") rather than the attack itself. The authors argue that this "benchmark lie" is a critical issue for deploying LLM agents safely and propose a more robust evaluation method to uncover these hidden failure modes.

Methods

The core of the paper's methodology revolves around two key innovations:

  • Activation-Based Classifiers (Linear Probes): The authors use linear probes, which are simple logistic regression models trained on the internal activations (hidden states) of LLMs. This approach allows them to analyze what the model "learns" from its internal representations. They experiment with both raw activations and sparse autoencoder (SAE) features, which are designed to be more interpretable.
  • Leave-One-Dataset-Out (LODO) Evaluation: This is the central contribution. Instead of standard train-test splits from the same dataset, LODO involves training a classifier on all but one dataset in a benchmark and then testing it on the held-out dataset. This simulates a true out-of-distribution scenario, forcing the classifier to generalize to data it has never seen before. They also introduce a "retention metric" to quantify how much a feature's predictive power drops when its originating dataset is removed, helping to identify dataset-specific shortcuts.

Datasets

The authors compiled a benchmark of 18 diverse datasets, totaling over 105,000 samples. These datasets cover:

  • Harmful Requests: For restricted content.
  • Jailbreaks: To bypass safety mechanisms.
  • Indirect Prompt Injections: Where malicious instructions are embedded in external data (emails, tool outputs).
  • Extraction Attacks: To elicit hidden system information.
  • Benign Sources: For comparison.

They note that single-class datasets (100% malicious or 100% benign) are particularly susceptible to shortcut learning.

Key Insights and Ideas

  • Benchmarks Lie: Standard evaluation protocols severely overestimate the generalization performance of prompt attack classifiers. The gap between standard cross-validation and LODO is substantial, highlighting a critical flaw in current evaluation practices.
  • Dataset-Specific Shortcuts: A significant portion (28-44%) of the features learned by classifiers are "dataset shortcuts." These features exploit patterns specific to a dataset's format or origin, rather than genuinely identifying malicious content. This means a classifier might learn "this email format is bad" instead of "this instruction is malicious."
  • Entangled Signals: The signals that identify a dataset and those that identify a malicious prompt are not entirely separate. This overlap makes it difficult for standard domain-generalization techniques to fully close the performance gap.
  • Production Guardrails Fall Short: Existing production systems like PromptGuard 2 and LlamaGuard, as well as LLM-as-judge approaches, also struggle with indirect and agentic attacks when evaluated under LODO, demonstrating the universality of the problem.
  • LODO for Reliable Explanations: Using LODO-weighted explanations helps filter out dataset artifacts, leading to more trustworthy per-prompt explanations of why a classifier made a certain decision.

Key Results

  • Performance Overestimation: Standard cross-validation overestimates performance by 8.4 percentage points in AUC for one model, with aggregate gaps ranging from 8.0 to 16.5 percentage points across four LLMs. Per-dataset accuracy gaps can be as high as 25 percentage points.
  • Shortcut Prevalence: 28% of top SAE features were identified as dataset shortcuts on Llama-3.1-8B, and 44% on Gemma-3-27B.
  • Dataset Classifier Performance: A classifier trained solely to predict the dataset identity achieved 96.6% accuracy on SAE features, demonstrating how easily datasets are distinguishable.
  • Mitigation Ineffectiveness: Standard domain-generalization techniques (e.g., adversarial training, subspace projection) did not significantly close the LODO gap.
  • Production Baseline Performance: At matched benign false positive rates (FPR), activation probes outperformed production guardrails on indirect and agentic attacks. However, PromptGuard 2 and LlamaGuard were unable to evaluate agentic attacks due to architectural limitations.
  • LODO-Weighted Explanations: These explanations showed feature changes in 98.1% of samples, effectively filtering out dataset artifacts.

Limitations and Future Work

  • White-Box Access: The activation-based approach requires access to model internals, limiting its direct applicability to closed-source APIs. The authors suggest smaller sidecar classifiers or using the method to distill into text-based classifiers.
  • Not Adversarial Robustness: LODO measures static distribution shifts, not robustness to adaptive attackers who might specifically design attacks to evade detection.
  • Computational Cost: Training K classifiers for K datasets can be computationally expensive, especially for fine-tuning.
  • Interpretability Scope: Feature contributions indicate influence on the classifier score but are not causal interventions on the LLM itself. Human evaluation of explanations is needed.
  • No Mitigation Provided: The paper focuses on diagnosing the problem and showing standard fixes don't work, but doesn't present a definitive solution to close the gap. Future work could explore methods to disentangle dataset identity from safety signals.

Summary updated

BibTeX
@inproceedings{fomin2026when,
  author = {Max Fomin},
  title = {{When Benchmarks Lie: Evaluating Malicious Prompt Classifiers Under True Distribution Shift}},
  booktitle = {AIWILD @ ICLR},
  year = {2026},
  url = {https://openreview.net/forum?id=jWIOJOQqne},
}
Figure