Skip to content

Did you read it right? Rethinking the internal signals used for prompt injection detectionAre You Reading the Right Thing? Rethinking Internal Signals for Prompt-Injection Detection

arXiv: Jailbreaks, Prompt Injection, Poisoning & Defenses· arXiv:2610.19452· Sarthak Gupta, Priyanka TembeyOperant AIIndexed by this site · 2026-10-15· Originally publishedDefenses

Quick read

Analysis and theory

Based on the paper PDF (AI-generated); refer to the original

The authors compare five internal signals, and the separation direction between successful and failed injections is opposite (Attention Tracker on Qwen is 0.949).

Questions
Internal-state prompt-injection detection may read injection presence, recognition, routing, or behavioral impact, and a high score does not mean the attack has controlled the reply. The authors aim to distinguish which of these signals is closer in the same indirect-injection setting.
Methods
On Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it, five internal methods are adapted to the same task/external content template. Scores are frozen, then AUROC is computed against 1,000 benign controls separately for successful and failed attacks. Success means only that the response substantially follows the adversarial behavior.
Experiments and results
The five methods fall into two groups: Attention Tracker, Dong, and the Role adaptation separate successful attacks better, while PIShield and J-Lens separate failed attacks better. Attention Tracker's AUROC for successful attacks is 0.949 (Qwen) and 0.887 (Gemma).
Limitations and future work
The authors note that only two smaller open-source models and one structured prompt were evaluated, the corpus is conditioned on outcomes, and method adaptations may change what is measured. The experiments report stratified AUROC for five methods on two models; the authors list causal intervention and detector-adaptive attacks as future work.
Experimental setupQwen3.6-35B-A3B、Gemma-4-26B-A4B-it et al. · structured indirect prompt-injection evaluation、template-matched benign controls et al. · AUROC
Evaluated models
Qwen3.6-35B-A3BGemma-4-26B-A4B-itJ-LensPIShieldAttention TrackerRole ConfusionDong exposure probe
Benchmarks
structured indirect prompt-injection evaluationtemplate-matched benign controlsAgentDojo
Metrics
AUROC
AI summaryThe researchers compared five methods that detect prompt injection from the model's internal state, evaluating them on Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it under a unified indirect prompt injection setting, and pointed out that these methods do not read the same safety attribute. Methods targeting the detection of the presence of injection or attack-related concepts were better at distinguishing unsuccessful injections from benign inputs; attention shift, exposure, and role confusion methods better distinguished successful injections on both models. Attention Tracker had the strongest discrimination for successful injections, with an AUROC of 0.949 on Qwen and 0.887 on Gemma. The results suggest that signals closer to the response formation stage may better encode whether an attack succeeded, and detection performance may also depend heavily on the prompt template. The research data has been shared on anonymous.4open.science.

The researchers compared five methods that detect prompt injection from the model's internal state, evaluating them on Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it under a unified indirect prompt injection setting, and pointed out that these methods do not read the same safety attribute. Methods targeting the detection of the presence of injection or attack-related concepts were better at distinguishing unsuccessful injections from benign inputs; attention shift, exposure, and role confusion methods better distinguished successful injections on both models. Attention Tracker had the strongest discrimination for successful injections, with an AUROC of 0.949 on Qwen and 0.887 on Gemma. The results suggest that signals closer to the response formation stage may better encode whether an attack succeeded, and detection performance may also depend heavily on the prompt template. The research data has been shared on anonymous.4open.science.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors state that the five internal signals do not measure the same property, and the direction of separation between successful and failed injections can be opposite.

    Whether internal detection scores correspond to the presence of an injection or to whether the attack has already changed the response is currently unclear.

    • Scenario: The authors state that agents write web pages, emails, documents, and tool outputs into the same token sequence as trusted tasks, without hard separation between instructions and data, and may not follow instruction hierarchy. Indirect prompt injection can lead to unauthorized tool calls, data exfiltration, or modification of external state.
    • Gap: The authors state that probes, attention, role projections, exposure, and concept readouts may correspond to presence, recognition, routing, or behavioral impact, and performance differences alone do not reveal which property is read. Distinguishing only clean vs. injected also does not reveal whether the attack controlled the response.
    • Distinction: The authors separate injection presence from attack success. Success means only that the response visibly and substantially follows the requested behavior; quoting, describing, translating, warning, or refusing does not count as success.
    • Approach: Compare five representation-reading methods on the same structured indirect injections, with models Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it. Successful and failed attacks are each evaluated with AUROC against 1,000 template-matched benign controls.
    • Threat model:
      • Goal: The response substantially follows adversarial behavior in untrusted content, including overriding the task, imitating higher-privilege instructions, controlling format, or inducing other specified behaviors.
      • Control scope: Only the external text to be processed is controlled; trusted tasks, system messages, weights, detectors, or benign reference sets are not controlled. Adaptive edits look only at behavioral outcomes, not detector scores.
      • Victim system: LLM agents processing external content. The evaluation places attacks within the same explicit task and external content boundary.
      • Detector: White-box access to open-weight models, allowing reading of residual stream, normalized pre-MLP, attention, or J-Lens projections per method. The authors evaluate scores, not interception policies; scores that use response tokens cannot block before generation.
  2. What related research exists?

    Related work separates injection presence, routing, role, exposure, and concept readout; the authors state these are not equivalent.

    The authors discuss related work by internal signal family and argue that injection presence, attention shifts, role awareness, exposure, and explicit recognition are related but not equivalent.

    Indirect Prompt Injection

    • AgentDojo (Debenedetti et al., 2024): Dynamic environment for evaluating prompt injection attacks and defenses on agents. The Dong probe is fit on its decision points, not reported on here for AUROC.
    • Instruction hierarchy and instruction/data (Wallace et al., 2024; Zverev et al., 2025): The former discusses making models prioritize higher-privilege instructions; the latter discusses whether models can separate instructions from data. The authors use both to illustrate that external data and trusted tasks enter the same sequence without hard separation.

    The Five Compared Signal Types

    • PIShield (Zou et al., 2025): Reads the residual stream of the last prompt token at injection-critical layers, linearly distinguishing clean from injected, without generating a response.
    • Attention Tracker (Hung et al., 2025): Uses the distraction effect, where certain heads shift from the original instruction to the injected instruction; the score rises as attention to the trusted instruction decreases. That study states that templates with higher overall success rates produce stronger distraction effects.
    • Role, exposure, and concepts (Ye et al., 2026; Dong et al., 2026; Gurnee et al., 2026): Role Confusion measures whether low-privilege text acquires the representation of the imitated high-privilege role; Dong uses pre-generation hidden states to predict whether an injection is encountered, with labels independent of compliance, and discusses the knowledge–action gap; J-Lens reads pre-generation verbalizable concepts. The authors state that J-Lens has qualitative cases that internally flag prompt injection, but the output does not write out that recognition.
      • Dong et al. numbers on Qwen3-8B, not results for the two target models here: of 634 rounds with injection and probe flagging, 47.0% recognize risk but still take non-defensive actions, 30.9% do not explicitly discuss risk. Exposure held-out AUROC is 0.959–0.976, and probes trained on attack success are 0.825–0.891.
      • Ye et al.: in 1,000 bootstrap agent injections, success rate ranges from 2% in the lowest Userness percentile to 70% in the highest; in 626 chain-of-thought forgeries, from 9% in the lowest CoTness to 90% in the highest. The authors state this measures Userness and CoTness, not directly validating the Systemness adaptation here.

    Other Detectors and Questioning High Scores

    • InstructDetector, RAP-ID, PVDetector (Wen et al., 2025; Yang et al., 2026; Wang et al., 2026): Respectively combine hidden states with gradients, use instruction similarity, counterfactual gains, and policy conflicts to identify impostors, or construct policy-violation directions from contrastive samples. The authors state that their supervision and threat models may not target successful indirect attacks.
    • BASIS (Qin et al., 2026): Trains pre-generation attention probes separately for injection presence and behavioral breach. The authors cite concurrent results: presence detection AUROC of 1.000 on six models, the same score predicting breach on attack samples at 0.707; breach-trained probes average attack-only AUROC of 0.953 across six models and four tasks.
    • Shortcuts and environment changes (Fomin, 2026; Li et al., 2026b; Liu et al., 2025; Li et al., 2026a): The paper states that activation probes exploit dataset identity and degrade under leave-one-dataset-out; in a single-backbone case, title-level IPI probe AUC can be explained by length, position, or visual surface shortcuts. WAInjectBench states that existing detectors are worse on web-agent attacks without explicit instructions or visible perturbations. AgentDyn states that defenses effective on static benchmarks may over-defend against helpful external instructions.

    Linearly Decodable Safety Properties

    • Linear directions (Zou et al., 2023; Marks and Tegmark, 2024; Arditi et al., 2024): Truthfulness, harmfulness, and refusal can manifest as linear directions in the residual stream.
    • Steering and localization (Rimsky et al., 2024; Li et al., 2025; Zhou et al., 2025): Contrastive Activation Addition uses such directions to steer behavior at inference; other work localizes safety-related computation to a few layers or attention heads.

    Control setting: No external detector baselines are set. The five adaptations are compared against each other on 2,000 attacks and 1,000 template-matched benign controls per model. AgentDojo is used only to fit Dong.

    The authors state that three detection papers assume injections leave detectable internal traces, and Role Confusion and J-Lens provide role and concept signals; the authors ask whether these signals track successful compromise or only injection presence or recognition.

  3. How does the paper address this problem?

    Five methods read different internal quantities on the same structured prompt, and none is trained on success/failure labels.

    Five methods are adapted and compared on the same structured indirect prompt injection: PIShield, Attention Tracker, a Systemness adaptation of Role Confusion, the Dong exposure probe, and J-Lens. The authors state that the comparison is among these adaptations, not the overall merits of the original methods. Behavior labels are appended only after the scores are frozen.

    Input geometry and corpus

    • The system message is You are a helpful assistant. The user turn contains Task and External content. Source prompts that can recover boundaries keep their original boundaries; direct or vague prompts are placed into a fixed carrier task, giving 2,000 attacks per model in the same geometry. The authors state this makes boundaries more explicit than in natural agent trajectories.
    • Behavior outcomes are used only to augment the corpus, not to train detectors. authority_sandwich_v1 changes only the untrusted content, not the trusted task, replacing 53 Qwen and 234 Gemma examples. Gemma's second round, gemma_role_boundary_v2, was not merged in. Final success/failure counts are 800/1,200 and 569/1,431.
    • Benign controls are 1,000 examples with the same outer template, differing only in content. Features are re-sampled separately for each model and each detector. Figure 2 and Appendix A.1 show examples with embedded external content; attack text is not quoted here.

    Five readouts

    • PIShield: Takes the residual stream of the last formatted token of the full structured prompt. A balanced clean/injected logistic regression is fit per layer, one layer is frozen by validation accuracy, and ties are broken by AUROC choosing the earlier layer. Qwen layer 24, Gemma layer 20; 680 pairs fit and 170 pairs validated per layer. Scoring happens before generation. The authors state the input is the merged structured prompt, not the separately serialized data_prompt upstream.
    • Attention Tracker: Heads are selected using 30 normal sentences and 30 synthetic ignore injections, keeping heads that satisfy μnormal−μattack−4(σnormal+σattack)>0. Qwen has 19 heads, Gemma 12. At the final query position, focus=A(trusted)/(A(trusted)+A(untrusted)+10−8) is computed, and the score is the complement of the mean focus over the selected heads. Qwen exposes full attention at layers 3, 7, and up to 39; Gemma evaluates all 30 attention layers with eager attention. Scoring happens before generation.
    • Role Confusion: The text is unchanged and only the native message roles are altered; a balanced multinomial logistic regression is fit. 630 documents fit and 70 validated. Qwen reads post_attention_layernorm (hidden size 2,048, layer 20); Gemma reads pre_feedforward_layernorm (hidden size 2,816, layer 16). The score is the mean Systemness over up to 16 positions on the untrusted fragment. The authors state this is an exploratory user-message adaptation, not the Userness endpoint on native tool results.
    • Dong and J-Lens: Dong reads the residual stream of the last post-assistant prefill token before generation, Qwen layer 18 and Gemma layer 10; 5 epochs, batch size 64, learning rate 10^{-4}, taking the last round, with feature standardization. This corpus has no multi-turn tool trajectories or per-turn exposure labels, so it is fit and frozen on AgentDojo's train/validation decision points. J-Lens estimates the average Jacobian sending residuals to the final layer on 1,000 pretraining-style prompts, then through final normalization and unembedding. Fixed concepts are fake, injection, false, prompt, fraud, poison. Readouts include up to 4 injected-fragment positions, the reply start, the prefill's I, and the first 20 reply tokens. The reported score is a balanced logistic regression on the aggregated features, with 680/170 clean/injected pairs per model, so part of it is post-generation monitoring.

    Supervision objective and success definition

    • None of the five detectors uses success/failure labels. PIShield and J-Lens probes fit clean versus injected; Dong fits exposure; Attention Tracker selects heads with synthetic attacks; Role fits message roles. Stratified AUROC measures how these independently defined signals relate to behavioral success.
    • The target model generates a reply in this structured context. Two independent GPT-5.6-luna runs: one directly checks the requested behavior, and one first asks whether the reply can be explained by the trusted task. Disagreements, unclear cases, confidence below 0.8, or missing evidence, non-verbatim responses, or inconsistency with the conclusion go to adjudication. The adjudication model is not specified in the paper. Success requires a final judgment of visible and substantial compliance.
    • The main metric is AUROC relative to the same 1,000 benign controls, with success and failure separated, without fitting a threshold. 95% intervals use 2,000 stratified bootstrap resamples, with the two AUROC groups sharing the resampled benign controls.
  4. What experiments did the paper conduct?

    The authors report Attention Tracker successful-attack AUROC of 0.949 (Qwen) and 0.887 (Gemma).

    Experimental Setup

    • Target models: Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it. Generation with thinking disabled, deterministic decoding, up to 512 new tokens. Checkpoint revisions noted in Appendix A.5.
    • Data: 2,000 structured indirect injections per model, plus 1,000 benign controls with the same outer template. Success/failure: Qwen 800/1,200, Gemma 569/1,431. Adaptive replacements: 53 and 234.
    • Comparisons: Five adaptations compared against each other, no external detector baselines, and no original fixed thresholds from each method.
    • Metrics: AUROC of attacks vs. benign controls, separated by success and failure. ± is the larger distance to either bootstrap endpoint, with 2,000 stratified resamples. Overall intervals weighted by stratified AUROC according to 800/1,200 and 569/1,431.
    • Judging: Two independent GPT-5.6-luna, with behavior-first and counterfactual rule sets. Inconsistencies, unclear cases, confidence below 0.8, or evidence check failures are adjudicated. The adjudication model is not specified in the paper. Only final attack_followed = yes counts as success.
    • Fit isolation: None use success/failure labels. PIShield and J-Lens probes use clean/injected; Dong uses exposure, fit on AgentDojo data; Attention Tracker selects heads with synthetic ignore attacks; Role uses message roles.

    Main Results

    AUROC of successful and failed attacks relative to the same 1,000 benign controls, per Table 2.

    Swipe horizontally to read the table

    MethodQwen SuccessQwen FailureGemma SuccessGemma Failure
    PIShield0.637 ± 0.0280.898 ± 0.0140.821 ± 0.0260.980 ± 0.005
    J-Lens0.753 ± 0.0250.850 ± 0.0170.519 ± 0.0320.788 ± 0.019
    Attention Tracker0.949 ± 0.0110.691 ± 0.0230.887 ± 0.0180.636 ± 0.023
    Role Confusion0.822 ± 0.0200.631 ± 0.0240.802 ± 0.0230.757 ± 0.020
    Dong exposure probe0.873 ± 0.0180.812 ± 0.0180.855 ± 0.0220.615 ± 0.023
    • The authors state that the 10 comparisons in Table 2 are directionally consistent: Attention Tracker, Dong, and Role adaptations separate successful attacks more on both models; PIShield and J-Lens both separate failed attacks more. The magnitude of differences varies with model. Figure 1 labels the former group as closer to response formation, and the latter as recognition signals.
    • The authors argue that to follow an injection, the model must use untrusted segments when producing the response; Attention Tracker measures this routing at the final query position, thus closer to attacker control than merely asking whether there is an instruction in the prompt.
    • The authors argue that PIShield and J-Lens objectives do not require the model to follow the attack. Explicit injections can simultaneously produce strong presence or recognition signals and be more easily rejected. The authors state that J-Lens is near random on Gemma successful attacks. Although Dong separates successful attacks more, it is trained on exposure, and the authors state it cannot therefore be taken as a direct compromise detector.

    Overall AUROC

    All 2,000 attacks vs. the same 1,000 controls, per Table 1.

    MethodQwenGemma
    J-Lens0.811 ± 0.0170.711 ± 0.018
    PIShield0.793 ± 0.0160.935 ± 0.009
    Attention Tracker0.794 ± 0.0160.707 ± 0.020
    Role Confusion0.707 ± 0.0190.770 ± 0.019
    Dong exposure probe0.836 ± 0.0150.683 ± 0.020
    • The authors do not interpret overall AUROC as detection of attack success. The overall ranking differs from the successful-attack ranking: on Gemma the highest overall is PIShield, on Qwen it is Dong; the authors state that the most consistent separation of successful attacks remains Attention Tracker.
    • Table notes state that each overall AUROC compares all attacks against the same control. Bootstrap weights stratified AUROC by observed success/failure counts.

    Mean Scores and the Authors' Two Types of Awareness

    • The authors also report mean scores, not AUROC: on Qwen, Attention Tracker success 0.808, failure 0.475, PIShield 0.594 and 0.856; on Gemma, Attention Tracker 0.771 and 0.522, Dong 0.528 and 0.353.
    • The authors give cross-model average differences (success minus failure): −0.196 for the two failure-biased detectors, +0.174 for the three success-biased ones.
    • The authors call the former recognition awareness: the model represents the instruction as suspicious or conflicting with the trusted task, and this signal can be stronger when the attack fails. The latter is called influence awareness: untrusted instructions are fed into the response plan or given inappropriate authority. The authors argue this is not just a difference in reading time, because PIShield also reads the final prompt state, but its training objective is to distinguish clean from injected.

    Corpus Composition and Baseline Judging

    • Pre-replacement baseline success counts: Qwen 747, Gemma 335; post-replacement: 800 and 569 (Appendix A.1). Candidates are sorted by pre-declared source, subtype, and case identifier until reaching the target success count or no successful candidates remain.
    • Qwen reaches the pre-declared 40% success target. Gemma is 28.45%: after all 234 first-round successful variants are included, it still does not reach 40%. Second-round variants are not merged into the detection evaluation corpus.
    • Of 4,000 baseline model–attack judgments, 645 go to adjudication, 3,355 are finalized by agreement (Appendix A.3). These counts refer to the baseline corpus, not the final merged corpus.

    Other Ablations and Analyses

    • Table 2 differences (success minus failure), Qwen: J-Lens −0.096 ± 0.024, PIShield −0.261 ± 0.028, Attention Tracker +0.259 ± 0.022, Role +0.190 ± 0.022, Dong +0.061 ± 0.025.
    • Same differences, Gemma: J-Lens −0.269 ± 0.032, PIShield −0.159 ± 0.025, Attention Tracker +0.251 ± 0.020, Role +0.046 ± 0.023, Dong +0.239 ± 0.027.
    • Layer/head selection: PIShield 24 and 20; Attention Tracker 19 and 12 heads; Role 20 and 16; Dong 18 and 10 (Appendices A.7–A.10).
    • Fit sizes: PIShield and J-Lens probes 680/170 pairs each; Role 630/70 documents; Attention Tracker head selection uses 30+30 synthetic samples; J-Lens Jacobian uses 1,000 pretraining-style prompts.
    • The paper does not report threshold sweeps, layer ablations, or AUROC under detector-adaptive attacks.
  5. What are some points that can be further explored?

    The authors state that conclusions are limited by two smaller models, one prompt format, and method adaptations, and suggest causal interventions and detector-adaptive attacks.

    Limitations and Future Directions Noted by the Authors

    • Only two open-weight models of similar size are evaluated, both relatively small; larger or more diverse models were not evaluated due to compute constraints. The authors state that results may not generalize to other scales or model families and encourage more complete analyses (Limitations).
    • Only one explicit structured prompt format is studied (Limitations).
    • The attack corpus is conditioned on outcomes and includes adaptively selected successful replacements (Limitations). Appendix A.1 states that 800/1,200 and 569/1,431 are the composition of this stress test, not estimates of natural attack prevalence or success rates.
    • Methods were originally designed for different settings. Adaptations may change what each method measures or its performance; the authors state that this study is only an early indication of which internal activation structures are more directly useful for indirect prompt injection detection (Limitations).
    • Future work should test this distinction with matched attacks, causal interventions, varied prompt formats and model families, and detector-adaptive attacks (Conclusion).

    Experimental Coverage

    • Results cover five methods on Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it, overall in Table 1, success/failure stratified in Table 2.
    • 2,000 attacks and 1,000 benign controls per model; success counts are Qwen 800, Gemma 569 (Section 3). The evaluation uses the Task / External content template from that section.
    • Initial judgments are two independent GPT-5.6-luna. Appendix A.3 reports 645 adjudications and 3,355 finalized by agreement out of 4,000 baseline judgments. The paper does not report adjudication counts for the final merged corpus, nor the adjudication model.
    • Responses are generated once with thinking disabled, up to 512 new tokens, deterministic decoding (Appendix A.5). Intervals are estimated by 2,000 stratified bootstrap samples (Section 3).
    • Dong's fitting and layer selection use AgentDojo's train and validation decision points (Appendix A.10). Section 3 states that adaptive edits do not receive detector scores or benign samples, and the unified template makes the trust boundary more explicit than in natural trajectories.
  6. Summarize the main content of the paper

    The authors state that the internal signal is not a single measure of attack success; Attention Tracker's separation of successful attacks is the most consistent.

    The authors compare five internal representations on two open-source models to distinguish whether prompt injection detection scores track injection presence or behavioral compromise.

    • Problem: Adversarial instructions in external content and the model actually following them are two different things. The authors argue that presence, recognition, routing, and whether the response is controlled are not the same property, and a single detection AUROC cannot represent all of them.
    • Approach: Qwen3.6-35B-A3B and Gemma-4-26B-A4B-it each evaluate 2,000 structured attacks and 1,000 template-matched benign controls. PIShield and J-Lens probes are fit on clean/injected, Dong on exposure, Attention Tracker selects heads on synthetic ignore attacks, and Role fits Systemness on message roles. Except for J-Lens, which uses features from some response positions, all score before generation. Success is determined solely by whether the response substantially follows the adversarial behavior; this label is not used in fitting.
    • Stratified results: Attention Tracker AUROC on successful attacks is 0.949 (Qwen) and 0.887 (Gemma, Table 2), higher than its failed-attack side. Dong's successful-attack AUROC is 0.873 and 0.855, Role adaptation 0.822 and 0.802; these three separate successful attacks more on both models. PIShield and J-Lens are the opposite, with higher failed-attack AUROC, including PIShield's failed-attack AUROC of 0.980 on Gemma and J-Lens's successful-attack AUROC of 0.519.
    • Overall scores: Against benign controls across all 2,000 attacks, the highest on Qwen is Dong (0.836) and on Gemma is PIShield (0.935, Table 1). The authors do not treat this overall number as detection of attack success.
    • Authors' conclusion: Detecting injection and detecting behavioral impact are different problems; a high injection detection score does not by itself mean the model has been compromised. The authors state that signals more directly tracking how untrusted content enters response formation give the strongest indication of successful attacks on this benchmark. The authors believe detection performance may depend strongly on the prompt template. Evaluations should report the two detections separately; future work includes matched attacks, causal interventions, more formats and model families, and detector-adaptive attacks.

Related papers

Show 3 more papers
Read originalarxiv.org