MIRAGE: Polarity-Flipping Encoding Subspace in LLM AgentsMIRAGE: A Polarity-Flipping Encoding Subspace in LLM Agents
The authors state that covert encoded exfiltration by LLM agents is supported by a shared low-dimensional subspace in the residual stream, and on this basis build the dual-channel monitor MIRAGE, with AUC = 0.918 on 126 agent scenarios.
Adversarial subset of indirect prompt injection (IPI): third-party-authored retrieved content coerces the agent to encode credentials (Base64, ROT13, acrostic, etc.) and exfiltrate them via replies or tool calls. Defenders need white-box hidden-state access, reading the residual stream in real time on locally deployed open-source models.
- When an LLM agent is coerced by indirect prompt injection into encoding credentials and exfiltrating them, the output text is fluent, and output-side detection (perplexity, fine-tuned classifiers) is near random or fails to generalize to unseen encodings. The authors aim to answer: can such covert exfiltration be detected from internal computation rather than surface text.
- The authors search the residual stream for a low-dimensional linear direction corresponding to encoding computation, train a logistic regression probe (validated with leave-one-encoding-out), and use the polarity flip of the same direction at the last input token to distinguish two execution strategies—"inline simulated encoding" and "outsourcing to a tool"—forming the dual-channel real-time monitor MIRAGE.
- LOEO AUC 0.975–1.000 on 8 models; dual-channel AUC = 0.918 on 126 agent exfiltration scenarios, output-side perplexity baseline 0.518; benign-encoding FPR ranges from 0% for Qwen-7B to 100% for Phi-3.5; the authors report that within the tested attack budgets, all attacks that suppressed the subspace also broke encoding fidelity.
- The authors note: white-box hidden-state access is required; the subspace also triggers on benign encoding-related constrained generation and requires per-deployment calibration; causal evidence is only partial; large sampling budgets, gradient-free adaptive sampling, and training-time attacks are left as future work. Deployment adaptability was fully screened only for the three families Qwen-7B, Mistral-7B, and Phi-3.5.
- Evaluated models
- Qwen2.5-7B-InstructQwen2.5-1.5B-InstructQwen2.5-3B-InstructQwen2.5-14B-InstructMistral-7B-Instruct-v0.3Llama-3-8B-InstructDeepSeek-7BPhi-3.5-mini-instruct
- Benchmarks
- AlpacaSelf-InstructLiu et al. (2023) prompt-injection templatesJailbreakBenchNotInjectGSM8KHumanEvalMATH126-scenario agentic suite46-scenario benign-encoding compatibility suite
- Metrics
- AUCFPRTPREERCohen's dSpearman ρ
Researchers find that when LLM agents are coerced into covertly exfiltrating sensitive data using encodings such as Base64, ROT13, and acrostics, although the outputs can bypass output-side detection, the computation supporting it is a shared low-dimensional encoding subspace in the residual stream, a conclusion that holds across nine encoding families and eight models from five architecture families. A logistic regression probe trained on eight encoding families reaches AUC 0.975-1.000 on the held-out ninth encoding family; the same direction also flips polarity at planning tokens, distinguishing before encoded text generation whether the model will simulate the encoding inline or switch to a tool call. Based on this, the authors build a dual-channel real-time monitor, MIRAGE, which reaches AUC 0.918 across 126 agent exfiltration scenarios, markedly higher than output-only detection at 0.518. The monitoring effect is essentially a property of the host model's geometry, and the benign-encoding false positive rate ranges from 0% for Qwen-7B to 100% for Phi-3.5; the authors also report that within the tested adversarial budgets, attacks that suppress this subspace simultaneously degrade encoding fidelity, and emphasize that this is an empirical regularity over the evaluated budgets, not a claim of structural impossibility.
Paper analysis
What problem does this paper attempt to solve?
Output-side detection cannot stop encoded exfiltration, so the authors turn to the model's internal computation, looking for an encoding-subspace signal that can be read in real time.
Core question: when an LLM agent is coerced into covertly encoding sensitive data for exfiltration via Base64, ROT13, acrostics, etc., the output text is fluent and output-side detection fails—can it be detected from internal computation?
- Problem setting and importance: an attacker poisons documents the agent will retrieve, hiding instructions to "encode credentials and send them via a tool call"; after the model complies, the output text is fluent. The authors cite prior work stating that covert encoding is hard to detect.
- Shortcomings of existing methods (per the paper): output-side defenses fail—perplexity detection AUC = 0.518, and fine-tuned DeBERTa-v3-base drops to AUC = 0.295 on held-out encoding families. The authors argue the signal is not in the surface text but in the computation.
- Core observation: encoding computation across 9 encoding families and 8 models from 5 architecture families occupies a shared low-dimensional subspace in the residual stream; the same direction flips polarity at the planning token, distinguishing the two execution strategies "inline simulation" and "outsource to tool."
- Proposed in the paper: MIRAGE (Model-Internal Readout of Agentic Generation Exfiltration), a dual-channel real-time monitor using the above two signals, plus a 126-scenario agent exfiltration evaluation suite.
- Threat model:
- Attacker goal: coerce the agent into encoding credentials from the system prompt and exfiltrating them via reply text or tool calls.
- Attacker knowledge and capability: third-party-authored retrieved content (indirect prompt injection, an adversarial subset of IPI); the robustness evaluation additionally covers white-box gradient (GCG), black-box sampling, projection, and prompt-adaptive attackers.
- Victim system: a Qwen-7B agent with 5 tools (web/code/email/file/API) and credentials in the system prompt.
- Defender assumption: white-box hidden-state access, targeting locally deployed open-source models; benign IPI is out of scope.
What related research exists?
Related work falls into four groups: prompt injection defenses, linear probes and activation steering, agent safety benchmarks, and cross-model computation universality.
Prompt injection and output-side defenses
- Greshake et al. (2023), Perez & Ribeiro (2022)—input-side filtering; Zhan et al. (2024), Yi et al. (2023)—sandboxed tool calls.
- Alon & Kamfonas (2023)—perplexity detection; Inan et al. (2023)—output text scoring. The paper measures a perplexity baseline AUC = 0.518 as evidence that output-side methods fail.
- Motwani et al. (2024), Roger & Greenblatt (2023), Greenblatt et al. (2024)—the paper cites them to show that covert encoding in model outputs is hard to detect.
Linear probes and activation steering
- Marks & Tegmark (2024), Arditi et al. (2024), Burns et al. (2023)—use linear probes to recover low-dimensional subspaces such as truth, refusal, and harmful intent.
- Zou et al. (2023a), Turner et al. (2024)—activation steering, used to causally validate such directions; this paper uses it for selective fidelity-reduction experiments.
- Belinkov (2022)—standard probing methods; the paper notes that they do not require transfer across surface forms, whereas this paper's LOEO setting does.
Agent safety benchmarks and threat models
- Ruan et al. (2024), Debenedetti et al. (2024), Wu et al. (2024)—suites measuring attack success rates; the paper states that MIRAGE reads internal states and is complementary to them.
- Hubinger et al. (2024), Park et al. (2024b)—deception threats; Chen et al. (2024)—tool misuse threats; the authors state that this paper's method can generalize to these threats.
Cross-model computational universality
- Chughtai et al. (2023), Gurnee & Tegmark (2024)—document task-invariant computation across models; the authors state that this paper extends such universality to the encoding subspace.
- Olsson et al. (2022), Nanda et al. (2023)—universality findings in mechanistic interpretability, echoing this paper's result of "shared geometry, architecture-specific circuits."
Baselines and benchmarks: output-side baselines are perplexity (Alon & Kamfonas, 2023), TF-IDF+LogReg, fine-tuned DeBERTa-v3-base, and a same-model static text encoder (Qwen-7B-as-encoder); external specificity benchmarks are JailbreakBench (Chao et al., 2024; Mazeika et al., 2024) and NotInject (Toyer et al., 2024); injection templates come from Liu et al. (2023). Authors' positioning: rather than filtering inputs or classifying outputs, read behavioral intent directly from residual-stream geometry.
How does the paper address this problem?
Find a shared linear direction for encoding computation in the residual stream, train a probe, and read it at two points during generation—at the planning token—forming a dual-channel monitor.
Overall approach: encoding computation leaves a shared low-dimensional linear signal in the residual stream; a logistic regression probe reads it token by token during generation (burst channel), and the polarity flip of the same direction at the last input token identifies the intent to "outsource to a tool" (intent channel); the two channels are fused into the MIRAGE real-time monitor.
Definition and training of the encoding subspace
- Paired positive and negative samples are constructed for 9 encoding styles (keyed Caesar, homophonic substitution, columnar transposition, acrostic, synonym chain, narrative paraphrase, sentiment polarity, word-length steganography, hex).
- The direction for each style is defined as the difference of positive and negative sample means: vs = h̄s+ − h̄s−, where h is the residual-stream hidden state. The authors report pairwise cosine similarities of 0.32–0.64 among the 9 directions, concentrated in a subspace of dimension ≤5, explaining 20–40% of between-class variance.
- Hidden states are taken from the final transformer layer at each generated token; training data are synthetic and author-generated, 100–200 per family; 3 seeds (42/123/456), with Qwen-14B, Llama-3-8B, and DeepSeek-7B using a single seed due to compute.
Probe architecture and scoring
- Pipeline: L2 normalization → per-dimension RobustScaler → L2-regularized logistic regression, applied to mean-pooled hidden states from the top quarter of layers, giving a per-token score σt ∈ [0, 1].
- Aggregation: 5-token max-burst rule (deployment default); burst threshold τ = 0.307, taken as the 98.5% quantile of 500 Alpaca benign replies, calibrated once and then fixed.
- Zero-shot variant: score by cosine similarity with the aggregated mean-difference direction vall, requiring no labeled corpus.
Planning-time polarity flip (intent channel)
- At the last input token, the same direction is positive when the model will "inline-simulate encoding" and negative when it will "outsource to a tool call" (mean projection 0.62 vs. 0.11 on 126 scenarios).
- Deployment uses an OR rule: an alert fires if either the burst threshold τ = 0.307 or the intent threshold τintent = 0.160 is triggered; a leakage-safe leave-one-out fusion is also reported as a threshold-free summary.
Evaluation methods
- LOEO: 9-fold leave-one-encoding-out, where the probe does not see the tested encoding family during training.
- E2E: Liu et al. (2023) injection templates (8 surface encodings × 5 retrieval contexts, 1,266 injections) against 1,050 Alpaca+Self-Instruct benign replies.
- Agent suite: 126 scenarios (81 attack + 45 benign), 50 handwritten + 76 LLM-generated then manually filtered; LLM-generated scenarios enter only the test pool and are not used for training, calibration, or fusion fitting.
- Data discipline: all adversarial inputs (GCG suffixes, sampling, projection, 120 prompt-adaptive trials) were authored only after the probe weights were frozen (freeze-then-author).
What experiments did the paper conduct?
LOEO generalization, E2E injection detection, 126-scenario agent monitoring, external specificity, adversarial robustness, and mechanistic analysis; headline number AUC 0.918.
Experimental Setup
- Models tested: Qwen2.5-1.5B/3B/7B/14B-Instruct, Mistral-7B-Instruct-v0.3, Llama-3-8B-Instruct, DeepSeek-7B, Phi-3.5-mini-instruct, 8 in total, across 5 architecture families.
- Data: probe training uses synthetic data (9 families × 100–200 entries); E2E uses 1,266 injections (Liu et al. template, 8 encodings × 5 contexts) against 1,050 benign responses; agent suite 126 scenarios (81 attacks + 45 benign); external specificity pool 1,489 entries (JailbreakBench-Harmful/Benign + NotInject, 4 models).
- Baselines: perplexity, TF-IDF+LogReg, fine-tuned DeBERTa-v3-base, Qwen-7B-as-encoder (same weights as a static text encoder), 6-feature surface-statistics baseline.
- Metrics and decision rule: AUC as primary; burst threshold τ = 0.307 (98.5% quantile of Alpaca 500); intent threshold τintent = 0.160; no LLM judge, decisions based on encoding fidelity and threshold rules.
- Repeats: Qwen-1.5B/3B/7B and Mistral-7B each with 3 seeds; Qwen-14B, Llama-3-8B, DeepSeek-7B single seed.
- Inference settings: temperature 0, top-p 1.0, at most 300 tokens.
Main Results
Per Table 2 (LOEO, 9 folds, multi-seed mean):
Model LOEO AUC Worst single-encoding AUC Qwen2.5-1.5B 1.000 ± 0.000 1.000 Qwen2.5-3B 1.000 1.000 Qwen2.5-7B 0.997 ± 0.001 0.986 Qwen2.5-14B 1.000 1.000 Mistral-7B 0.975 ± 0.006 0.762 Llama-3-8B 1.000 1.000 DeepSeek-7B 1.000 1.000 - Phi-3.5-mini is also 1.000 across all 9 encodings and 3 seeds (Appendix C); zero-shot variants Qwen-7B 0.971, Mistral-7B 0.949, 2–5 points lower than the trained probe.
- The authors state: if the probe learned encoding-specific surface features, holding out that family should fail, but 7 of 8 models have mean ≥0.997; the only unsaturated one is Mistral-7B (0.975), whose narrative paraphrase is 0.762 on seed 42.
- The authors' interpretation of the Mistral gap: mechanical encodings (Caesar, hex, columnar) saturate to 1.000 on all models, while semantic encodings expose a Mistral-specific 10–13 point gap, which the authors consider an architecture-specific representational choice rather than a probe defect.
Signal Location: Dynamic at Generation vs Static Text
- What was tested: a single forward pass over completed responses using Qwen-7B's own weights, mean-pooled, then the same LOEO probe trained (Qwen-7B-as-encoder).
- Results: under chat-template-matched comparison the encoder is 0.903, 9.4 AUC points lower than the generation-time probe's 0.997 (Table 3); perplexity 0.518, TF-IDF+LogReg 0.818, DeBERTa-v3-base 0.846 (worst 0.295).
- Authors' interpretation: the discriminative signal is in the hidden-state dynamics at generation time and is not accessible from static text, even with the same model.
End-to-End Injection Detection and the Qwen-14B Special Case
- E2E results: burst probe AUC = 0.928–0.969 on 4 models; Qwen-7B is 0.969 (EER = 0.097); last-token scoring drops to 0.37–0.76.
- Qwen-14B three numbers (Table 4): LOEO 1.000; conditional E2E (35 compliant samples that actually produced encodings) 1.000; unconditional E2E (all 1,266 injections) 0.640. Authors explain: RLHF refusals compress the positive class, and from a system-safety perspective a refusal means no leakage.
- External specificity: 0 false positives on 1,489 benign responses (95% Clopper–Pearson CI [0.0%, 0.25%]); removing either L2 normalization or RobustScaler raises FPR from 0% to 83–97% (Table 5).
Agent Monitoring (126 Scenarios) and Adversarial Robustness
- Channel decomposition (Table 8): burst single channel AUC = 0.677 (covers 31/81), intent single channel 0.913 (60/81), OR rule 69/81, leakage-safe LOO fusion AUC = 0.918 (95% CI [0.857, 0.957]); re-verified over 50 stratified splits, test-half AUC = 0.913 ± 0.029.
- Attack composition: of 81 attacks, 27 were refused by RLHF, 31 were caught by burst, 23 were missed by burst (tool-delegation type), and the intent channel caught 19 of those.
- Adversarial evaluation (Table 7): 300-step GCG × 4 losses — subspace suppressed below τ within 50 steps, but encoding fidelity 0/5 within 300 steps; sampling N ∈ {1, 10, 50} — 0/120 escapes; projection attack removes 84.7% of subspace positive variance — AUC still 1.000; 120 prompt-adaptive trials — 0/120 escape simultaneously under the default threshold, 3/120 (2.5%, all URL-encoded no-ops) under the stricter threshold τ = 0.405. The authors emphasize this is an empirical regularity at the tested budgets, not a structural impossibility.
- Weak-alignment control: on Qwen-1.5B detection rises from 49/120 to 99/120, with mean burst 1.5–4 times higher; the authors believe the coupling reflects the encoding computation itself rather than a refusal artifact.
Other Ablations and Analyses
- Deployment suitability (Table 9, 46 benign encoding scenarios): Qwen-7B FPR 0%, Mistral-7B 18.8%, Phi-3.5 100%; the authors call this a property of the host model's geometry — in the 3-class PCA of Figure 3, Qwen-7B's three clusters separate, Mistral-7B's partially overlap, and Phi-3.5's three clusters collapse into one.
- Cross-architecture consistency: the single-encoding LOEO difficulty ranking of Qwen-7B and Mistral-7B has Spearman ρ = 0.957 (p < 0.0001);跨种子探针方向余弦相似度 >0.998.
- Negative control (Table 6): 300 GSM8K math reasoning items average burst 0.0001, 0/300 triggered; benign constrained generation and encoding explanations do trigger (n=5, burst 0.72–0.76), which the authors call expected behavior for detecting encoding computation rather than a defect.
- Head ablation (Table 19): on Qwen-7B, 5 Layer-0 heads remove 68% of the simulate-vs-outsource margin; on Mistral-7B, the top-5 jointly remove only 18% (spread across layers 1–15); AUC remains 1.000 after ablation on both models.
- Causal steering (Table 21): at α = 4, encoding fidelity drops 30% and benign output degrades 0%; at α = 8, benign consistency drops to 2/6.
- Embedding-layer confound control (Table 17): embedding-layer AUC = 1.000 collapses to 0.500 after matching the last token, while decoder layers L1–L28 remain 0.977–1.000 under the control.
What are some points that can be further explored?
The authors list limitations including white-box dependence, benign-encoding triggering, and partial causal evidence, and list untested attack budgets as future work.
Limitations and future directions noted by the authors
- white-box dependence (§7.4, Appendix B.7-a): MIRAGE requires hidden-state access; black-box API models are not applicable; it targets locally deployed open-source models.
- Benign encoding-constrained generation also triggers (§7.4, Appendix B.7-c): the subspace also activates for benign encoding-related computation such as acrostics and encoding explanations; covert intent and benign constraints are not fully separable at τ = 0.307 and require per-deployment calibration.
- LOEO does not extrapolate to deployment (§7.4, Appendix B.7-d): LOEO (0.975–1.000), E2E (0.928–0.969), agentic burst-only (0.677), and dual-channel (0.918) are numbers for four different questions; high LOEO cannot be extrapolated to deployment accuracy.
- Causal evidence is only partial (§7.4, Appendix B.7-f): activation steering α = 4 reduces fidelity by 30% with 0% benign degradation; SAE decomposition and similar ablations on Mistral/Llama/Phi are future work.
- Untested attack budgets (§8, Appendix B.7-g): N ≥ 500 sampling, gradient-free adaptive samplers (NES, SPSA), training-time attacks (fine-tuning the host to suppress the subspace), long CoT routing; the authors state these may decouple suppression from fidelity and leave them as future work.
- Open frontiers (§8): the precise circuit of simulate-vs-outsource, detection–fidelity coupling under larger budgets, and whether training-time host geometry can be engineered to separate covert from overt encoding.
Experimental coverage
- Models tested are 8 open-source models across 5 architecture families; deployment-adaptability screening (46-scenario benign-encoding FPR) is complete only for the three families Qwen-7B, Mistral-7B, and Phi-3.5 (Appendix B.7-b).
- The agent suite has 126 scenarios (81 attack + 45 benign); attacks cover 5 tools, 9 encoding families, and both inline and tool-delegated types; 76 of the scenarios were LLM-generated and then manually filtered.
- Adversarial evaluation covers 4 attacker types: 300-step GCG × 4 losses (3 models), sampling N ∈ {1, 10, 50}, projection (removing 84.7% of variance), and 120 prompt-adaptive trials (24 strategies × 8 families × 5 credential targets, Qwen-7B; replicated on Qwen-1.5B).
- Specificity evaluation: 1,489 external benign replies (4 models), 300 GSM8K, 46 benign encoding scenarios; the small-sample group for benign constrained generation and encoding explanations is n = 5 (Table 6).
- The paper does not report a finer-grained upper bound on specificity for encoding-adjacent traffic beyond the benign-encoding compatibility suite (the authors state that 0/1,489 is only a sanity check, not a tight bound).
Summarize the main content of the paper
The computational trace of encoded exfiltration can be read linearly: a shared subspace plus a planning-time polarity flip form a dual-channel monitor, AUC 0.918.
A mechanistic-interpretability-driven agent safety defense paper: rather than filtering inputs or classifying outputs, it reads the computational trace of covert encoded exfiltration from residual-stream geometry.
- Problem: indirect prompt injection coerces the agent into encoding credentials and exfiltrating them, with fluent output text; the authors report perplexity detection AUC = 0.518 and fine-tuned DeBERTa-v3-base dropping to 0.295 on held-out encoding families, so output-side methods fail.
- Method: the difference of positive and negative sample means across 9 encoding families gives low-dimensional encoding directions in the residual stream, and a logistic probe is trained to score token by token (burst channel); the same direction flips polarity at the last input token, distinguishing inline simulation from outsourcing to a tool (intent channel); the two channels form MIRAGE, with thresholds τ = 0.307 and τintent = 0.160.
- Generalization results: LOEO AUC 0.975–1.000 across 8 models (Table 2); a same-model static text encoder is 9.4 points lower under template matching, and the authors state the signal is in the dynamics during generation.
- Deployment results: on the 126-scenario agent suite, dual-channel LOO fusion AUC = 0.918 (95% CI [0.857, 0.957]), burst-only 0.677, intent-only 0.913; 0 false positives on 1,489 external benign replies.
- Boundary results: benign-encoding FPR ranges from 0% for Qwen-7B to 100% for Phi-3.5, and the authors state that monitor compatibility is an auditable property of the host model's geometry; within the tested budgets (GCG, sampling, projection, 120 prompt-adaptive), all configurations that suppressed the subspace also broke encoding fidelity, and the authors explicitly state this is an empirical regularity, not a structural impossibility.
- Authors' conclusion: the route of reading behavioral intent directly from mechanistic geometry can generalize to deception, covert coordination, and tool misuse; limitations are white-box dependence, benign-encoding triggering requiring calibration, partial causal evidence, and larger attack budgets untested.
Related papers
Show 3 more papers
- Post-Training Large Language Models with LLMONDefensesarXiv