arXiv(opens in a new tab)cs.AIOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.19452

Are You Reading the Right Thing? Rethinking Internal Signals for Prompt-Injection Detection

Sarthak Gupta, Priyanka Tembey

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Several recent studies propose detecting prompt injections from a language model's internal state. But these methods do not measure a single security property. Residual-stream probes, attention scores, role projections, exposure probes, and concept readouts may capture injection presence, recognition, information routing, or behavioral influence. It is therefore unclear what differences in prompt-injection detection performance reveal about the internal signals these methods read. We study how five representation-reading methods vary under a common structured indirect prompt-injection setup on Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it. We evaluate each method by how well it distinguishes injected prompts from benign controls. We then further analyze each detection method's ability to detect attacks in cases where they are successful and in cases where they are not. This helps us better assess what properties each detection method might rely on. Methods trained to detect injection presence or attack-related concepts generally separate unsuccessful injections more strongly from benign inputs, whereas attention diversion, exposure, and Role-confusion based methods separate successful injections more strongly on both models. Attention Tracker provides the strongest consistent successful-injection separation, reaching 0.949 AUROC on Qwen and 0.887 on Gemma. These results suggest that signals closer to response formation may better encode information about an attack's success, and that detection performance can depend strongly on the prompt template. We share the data associated with this study at https://anonymous.4open.science/r/paper-evaluation-data-7877

1 Introduction

Large language models (LLMs) now power agents that interact with external tools, execute code, and modify external state [Debenedetti et al., 2024]. This capability introduces severe security risks, such as indirect prompt injection. When an agent processes untrusted data, an adversary can embed malicious instructions. These instructions can elicit unwanted behavior because LLMs often fail to reliably separate trusted instructions from instructions embedded in untrusted data [Wallace et al., 2024, Zverev et al., 2025].

Mechanistic-interpretability research shows that safety-relevant properties can be encoded linearly in transformer hidden states. Truthfulness, harmfulness, and refusal behavior have been recovered as linear directions in the residual stream [Zou et al., 2023, Marks and Tegmark, 2024, Arditi et al., 2024]. These directions can also be used to steer model behavior at inference time, as in Contrastive Activation Addition [Rimsky et al., 2024]. Other studies localize safety-relevant computation to a small subset of layers [Li et al., 2025] or attention heads [Zhou et al., 2025]. More recent interpretability tools aim to read out a model's internal, pre-verbalization concepts more generally rather than targeting a single hand-picked property [Gurnee et al., 2026]. This literature motivates the hypothesis that internal states may provide safety-relevant information beyond a model's generated

40th Conference on Neural Information Processing Systems (NeurIPS 2026). Workshop: Foundations of Language Model Security.

Figure

Figure 1: Overview of our evaluation. We compare five internal-state methods on the same structured inputs and separate attacks by behavioral outcome. The two signal groups show different patterns across successful and unsuccessful attacks.

response. Whether that information is faithful, robust, and predictive of behavior remains an empirical question.

Recent work includes internal-state prompt-injection detectors as well as general interpretability methods that can be adapted to this setting. Zou et al. [2025] propose PIShield. They show that the residual-stream representation of the final prompt token at a specific “injection-critical” layer is linearly separable between clean and injected inputs, without requiring the model to generate a response. Hung et al. [2025] instead exploit attention-level internal signals through Attention Tracker. They show that certain heads systematically redirect focus from the user’s original instruction toward an injected one. Ye et al. [2026] introduce Role Confusion. They use role probes to measure whether injected text occupies the same representational space as the trusted role it imitates. Dong et al. [2026] train linear probes on pre-generation hidden states to identify latent signals of indirect prompt-injection exposure in agentic LLMs. Anthropic’s Jacobian lens (J-lens) method [Gurnee et al., 2026] was proposed as a general-purpose tool for surfacing a model’s verbalizable, pre-output concepts. The authors report a qualitative case in which it exposes internal recognition of retrieved prompt-injection content. The three detector papers posit a detectable internal trace of injection, while Role Confusion and J-Lens provide complementary role-perception and concept-readout signals that we adapt for evaluation.

In this work, we test these signals under a common evaluation setup. We adapt five methods to the same structured prompts and evaluate each method on two open-weight models. Unlike presence-based evaluations [Zou et al., 2025, Hung et al., 2025], we divide injections according to the model's observed behavior. An attack is successful only when the response materially follows the adversarial instruction. For each method, we use AUROC to compare the detection methods' ability to detect successful and unsuccessful indirect prompt injection attacks with the same 1,000 template-matched benign controls. We use this comparison to ask why some internal signals align with successful attacks better than others.

We observe that attention routing separates successful attacks more strongly, while injection-presence and recognition probes often separate unsuccessful attacks more strongly. This pattern suggests that performance depends on what a method measures instead of only the position where the model's internal state is read at.

References (22)