TL;DR
LLMs are surprisingly bad at tracking "who said what" in a conversation, making them vulnerable to role spoofing—an attack where malicious tool outputs (like a webpage or email) impersonate a user. This paper demonstrates that even frontier models like GPT-5 and Claude 3 Opus are highly susceptible to these attacks and proposes a robust defense using linear probes to detect internal "role confusion" within the model's activations.
What Problem Does This Paper Address?
As LLMs transition into autonomous agents that read external data and call tools, they face a critical security threat: prompt injection. A specific, dangerous variant is role spoofing, where an adversary tricks the model into believing a malicious instruction came from the authorized user rather than an untrusted tool output.
While modern LLMs use "special tokens" (e.g., <|im_start|>user) to define message boundaries, they often rely on unreliable cues like writing style or semantics to identify the speaker. If an attacker mimics the user's style or injects "fake" structural markers, the model may suffer from role confusion and execute unauthorized actions, such as wiring money or deleting data. The authors investigate why this happens and how to stop it.
Methods
The authors employ a multi-pronged approach to dissect role tracking:
- "Who Said What" Setting: A simplified diagnostic task where models are pre-filled with a conversation and then asked to identify the sender of a specific text snippet. This isolates role attribution from other agentic capabilities.
- Toy Model Analysis: They train a two-layer transformer on synthetic data to simulate the training pipeline (pretraining $\rightarrow$ instruction tuning $\rightarrow$ adversarial training). This allows them to visualize attention patterns and see exactly how models switch between "content-based" and "structure-based" role tracking.
- Linear Probing: They develop a defense by training simple linear classifiers on the internal activations of the LLM. These probes are trained to predict the model's "internal belief" about the role of a token (e.g., "is this a tool output?").
- Adversarial Evaluation: They test models against "fake structure" (forged special tokens) and "misleading content" (style mimicry) to see which cues different models prioritize.
Datasets
- AgentDojo (Workspace Family): A benchmark for evaluating prompt injections in agentic workflows.
- Simple Tool-Use Testbed: A new, controlled environment created by the authors featuring five domains (banking, email, etc.) designed to isolate role spoofing by sampling user and adversarial tasks from the same pool.
- Nemotron-SFT-Agentic-v2 & Nemotron-CC: Used for realistic agentic conversation data and "style-free" random internet data, respectively.
Key Insights and Ideas
- The Mixture of Cues: Models don't just use one method to track roles. They use a "mixture" of content and structure. Interestingly, different models have different biases: Gemini 3.6 Flash is rarely fooled by content but fails on fake structure, while GPT-5.4 is more frequently swayed by misleading content.
- The Robustness Trap: Training a model to ignore content-based injections (like "ignore previous instructions") often forces it to rely more heavily on structural cues. This makes the model more vulnerable to sophisticated attacks that use forged special tokens.
- Internal "Belief" vs. Output: Even when a model is fooled and follows a malicious instruction, its internal activations often still distinguish the roles correctly. The "belief" is there; it's just not being used correctly for the final prediction.
- Defense via Randomness: One of the most surprising findings is that linear probes trained on conversations filled with completely random tokens are incredibly effective at detecting role spoofing in real, coherent conversations.
Key Results
The paper reveals a sobering reality: role spoofing is highly effective against every model tested.
- Attack Success: In the AgentDojo benchmark, role spoofing attacks achieved injection-to-control ratios near 100% for models like GPT-5.4 and Claude Opus 5, meaning the models followed malicious instructions almost as often as legitimate user requests.
- Testbed Performance: In the authors' "Simple Tool-Use Testbed," the attack success rate exceeded 95% for nearly all models.
- Defense Efficacy: The proposed linear probe defense achieved near-perfect separation between clean and injected messages. As shown in the ROC curves, the probes can achieve a >99% true positive rate with zero false positives in the tested regimes.
Limitations and Future Work
- Scope of Defense: The linear probe method is specifically designed for role spoofing. It does not detect other types of prompt injections, such as jailbreaks that don't involve impersonation.
- Brittle Training: While the authors suggest that adding more "edge cases" to training data might help, they warn this is a brittle solution that doesn't guarantee the model will learn a truly robust structural mechanism.
- Future Integration: The authors hope frontier model providers will incorporate these simple linear probe monitors into their inference engines to provide a more robust layer of security for autonomous agents.
Summary updated