Skip to content

SEAL: Local sanitization with sealed queries against indirect prompt injectionSEAL: Sealed Queries for Local Sanitization against Indirect Prompt Injection

arXiv: Jailbreaks, Prompt Injection, Poisoning & Defenses· arXiv:2610.39758· Doohyun Kim, Donghwa Kang, Mingyu Jun, Brent ByungHoon KangGraduate School of Information Security, KAIST; School of Computing, KAISTIndexed by this site · 24 days ago· Originally publishedDefenses

Quick read

Defenses

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

The authors propose SEAL, which uses an offline-learned soft prompt and scoring readout to sanitize tool outputs for a frozen local agent; on AgentDojo, ASR drops from 34.6% to 0.1%.

Threat modelIndirect prompt injection: the agent's initial instructions and tool definitions are trusted, but tool outputs may be controlled by an attacker; the attacker can modify tool text but cannot modify the trusted initial context C0, backbone weights, or defense parameters. The task model remains frozen. Adaptive evaluation includes grey-box (the attacker knows the backbone weights, algorithm, and public training recipe, optimizes prefixes with a surrogate model, and does not know the deployed defense parameters) and the white-box setting in the appendix.

Questions
Local LLM agents face indirect prompt injection in tool outputs, while local deployment has a limited inference budget. The authors argue that existing attention-based defenses' scores depend on the text being inspected, that scores are affected by context normalization, and that deletion loses task evidence.
Methods
SEAL offline learns a soft prompt and a scoring readout, scores tool outputs with a frozen task model and deletes locally: queries are constructed from the trusted initial context (M1), scoring occurs before softmax normalization (M2), and a preservation regularizer is added during training (M3); it does not generate defense text or use a separate verification model.
Experiments and results
Evaluated on AgentDojo with a frozen Qwen3.5-9B, SEAL reduces ASR from 34.6% to 0.1%, raises Joint from 51.4% to 77.5%, and uses about 1/127 of PISanitizer's defense tokens; Gemma 4 12B reproduces ASR dropping from 57.1% to 0.3%; under grey-box adaptive attacks, ASR is 1.4%.
Limitations and future work
The authors note: access to the internal states of the frozen backbone is required, so it does not directly apply to API-only models; evaluation is limited to two backbones and a subset of domains in AgentDojo/AgentDyn; sanitization may still remove useful task evidence and reduce utility.
Experimental setupQwen3.5-9B、Gemma 4 12B · AgentDojo、AgentDyn · CU、ASR et al.
Evaluated models
Qwen3.5-9BGemma 4 12B
Benchmarks
AgentDojoAgentDyn
Metrics
CUASRAUJointRemoval F1Clean removalPrefill/Generation tokens
AI summaryThe researchers propose SEAL, a defense against indirect prompt injection that uses a frozen task model to sanitize untrusted tool outputs; the paper reports reducing the attack success rate from 34.6% to 0.1% on AgentDojo. On both benchmarks, AgentDojo and AgentDyn, SEAL suppresses attacks while improving task completion under attack, with the Joint task completion rate on tasks with no successful attack on AgentDojo rising from 51.4% to 77.5%. Methodologically, SEAL learns a soft prompt and a scoring readout offline; the scoring query consists of a trusted initial context and the learned prompt, so that the scoring reference does not depend on the tool text being inspected; it scores token by token without cross-context normalization, and uses a preservation regularizer to encourage retaining useful evidence when making local deletions. This design requires neither tokens generated by the defender nor a separate verifier model, and the defense-related token overhead is about 1/127 that of the state-of-the-art prompt injection defense PISanitizer.

The researchers propose SEAL, a defense against indirect prompt injection that uses a frozen task model to sanitize untrusted tool outputs; the paper reports reducing the attack success rate from 34.6% to 0.1% on AgentDojo. On both benchmarks, AgentDojo and AgentDyn, SEAL suppresses attacks while improving task completion under attack, with the Joint task completion rate on tasks with no successful attack on AgentDojo rising from 51.4% to 77.5%. Methodologically, SEAL learns a soft prompt and a scoring readout offline; the scoring query consists of a trusted initial context and the learned prompt, so that the scoring reference does not depend on the tool text being inspected; it scores token by token without cross-context normalization, and uses a preservation regularizer to encourage retaining useful evidence when making local deletions. This design requires neither tokens generated by the defender nor a separate verifier model, and the defense-related token overhead is about 1/127 that of the state-of-the-art prompt injection defense PISanitizer.

Related events and news

1 events · 1 news mentions

News that mentions this paper

周报:预训练投毒可植入智能体后门

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Defending resource-constrained local frozen agents against indirect prompt injection while preserving task evidence and adding no inference burden.

    Core question: how to defend a local LLM agent using a frozen task model against indirect prompt injection (IPI) under a limited inference budget, suppressing the attack while preserving the evidence needed to complete the task.

    • Setting and motivation: compact open-source models make local deployment more practical, and developers care about data security and privacy; however, retrieved web pages, messages, or records may contain both useful data and instructions that redirect the agent (the authors cite Greshake et al., 2023, etc.).
    • Shortcomings of existing methods (authors' view): natural-language reinforcement is lightweight but leaves many residual attacks; auxiliary LLM reasoning consumes extra calls and decoding budget; attention-based defenses' scores depend on the inspected text and context, and deletion discards useful content (§1, Figure 1).
    • Core observation: analyzing attention sanitization with PISanitizer as the representative, the authors find that the scoring reference depends on the inspected text (O1), token scores are affected by normalization against competing context (O2), and suppressing attacks sacrifices task performance (O3), from which they propose three design challenges C1–C3 (§3).
    • The paper proposes: SEAL—offline learning of a soft prompt and a scoring readout, using the frozen task model to score tool outputs and selectively delete injected instructions, without generating defense tokens or requiring a separate verification model (§4).
    • Threat model:
      • Goal: use instructions in tool output U to redirect the frozen task model F outside the original user request.
      • Knowledge/capability: the attacker can modify tool text but cannot change the trusted initial context C0, backbone weights, or defense parameters (§3).
      • Victim system: a local agent whose initial instructions and tool definitions are trusted and whose tool outputs are untrusted; the task model remains frozen.
      • Adaptive evaluation: a grey-box attacker knows the backbone weights, algorithm, and public training recipe, and uses a surrogate model to optimize a 20-token prefix, but does not know the deployed defense parameters (§5.5); Appendix C.3 additionally tests white-box.
  2. What related research exists?

    Related work is divided into two groups: IPI attacks and benchmarks, and three types of runtime defenses; baselines cover Sandwich, Spotlighting, AttriGuard, DRIFT, tool_filter, Attention Tracker, and PISanitizer.

    IPI attacks and evaluation benchmarks

    • Greshake et al. (2023) proposed indirect prompt injection, which redirects LLM applications via instructions embedded in external content.
    • InjecAgent (Zhan et al., 2024) and AgentDojo (Debenedetti et al., 2024) evaluate this threat in tool-using agents; AgentDyn (Li et al., 2026) includes open-ended tasks with beneficial third-party instructions.
    • Adaptive attacks by Zhan et al. (2025) and Nasr et al. (2026) expose failures missed by weak or non-adaptive evaluations; the authors therefore argue for evaluating safety, task preservation, and attacks adaptive to the defense together.

    Natural-language reinforcement

    • Sandwich (Schulhoff, 2024) repeats the user request after external content; Spotlighting (Hines et al., 2024) marks external content and appends processing instructions. The authors state that such methods are lightweight but leave more attack successes in their local-agent evaluation (§5.2).

    Auxiliary LLM reasoning

    • AttriGuard (He et al., 2026) attenuates control cues in external observations and re-executes the agent to test tool calls; DRIFT (Li et al., 2025) builds a task plan, verifies deviations, and masks conflicting instructions.
    • MELON (Zhu et al., 2025) compares tool calls under the original versus masked user request; TaskShield (Jia et al., 2025) checks whether instructions and tool calls serve the user's goal; AgentDojo's tool_filter uses an LLM call to select task-relevant tools before execution. The authors state that such methods consume extra inference budget even when reusing the task model (§1).

    Attention-based defenses

    • Attention Tracker (Hung et al., 2025) detects attention deviation from the original instruction; PISanitizer (Geng et al., 2026) generates scoring tokens and uses their attention to locate and delete suspicious segments.
    • RENNERVATE (Zhong et al., 2026) aggregates attention across heads and response tokens for token-level detection and sanitization; RAP-ID (Yang et al., 2026) combines system-anchor key comparison with attention and logit signals for detection.

    Baselines and positioning: the Qwen comparison includes no defense and seven baselines—Sandwich, Spotlighting, AttriGuard, DRIFT, tool_filter, Attention Tracker, PISanitizer—on AgentDojo and AgentDyn (§5.1). The authors position SEAL as a design in the attention-based line that addresses three problems—trustworthy scoring reference, normalization dependence, and evidence preservation—and does not require auxiliary generation.

  3. How does the paper address this problem?

    SEAL constructs scoring queries from the trusted context plus a learned soft prompt, scores tokens before normalization, deletes by unit mean, and adds a preservation regularizer.

    Overall approach: SEAL uses three components M1–M3 to address challenges C1–C3 respectively, scoring each tool output U with a frozen task model F and selectively deleting suspicious text before the agent continues (Figure 3). Only the soft prompt E and readout parameters (θ, b) are learned; F remains frozen.

    Problem setting

    • F is the frozen task model, H is the dialogue history before the new tool output (possibly containing earlier untrusted observations), and C0 is the trusted initial context (including system/user messages and tool definitions).
    • The attacker redirects F using instructions in U; they can modify tool text but cannot modify C0, backbone weights, or defense parameters.

    M1: Query Sealing

    • The soft prompt E = (e1, ..., eM) is M learned continuous input embeddings; starting from a copy of the cached state after C0, a separate branch processes only E up to the selected deepest layer, without updating the task generation state.
    • The sealed query qℓ h j = Π QFℓ h j(C0; E), i.e., the coordinates not rotated by positional encoding are taken from the frozen model's queries at the soft prompt positions; for fixed C0 and E, the query is independent of tool text (addressing C1).
    • The query is cached once per trusted context and reused across tool calls; E is never spliced into the task generation input.

    M2: Scoring before softmax

    • The agent's normal prefill (H, U) provides tool keys; the token score aggregates the compatibility of the M sealed queries with that token's cached key using log-mean-exp, then sums over learned layer-head weights wℓh and bias b: d(t) = ∑ℓ,h wℓ h aℓ h(t) + b.
    • The softmax normalizes only the learned layer-head weights, not the input tokens; with fixed queries and keys, the token score is independent of competing context tokens (addressing C2). Qwen uses 1/√256 scaling, Gemma uses its native scaling.

    M3: Preservation regularizer and local deletion

    • U is split into units ui at sentence and structural boundaries; the unit score si is the mean of its token scores, and the unit is deleted if si > 0; units that are only whitespace or have no overlapping tokens are not deleted.
    • After deletion, the pre-tool cache is restored, the edited suffix is replayed and rechecked, with a check-round budget R = 2; the training objective is L = Lrank + Lboundary + λLpres, where the preservation term Lpres penalizes the score change of unchanged benign units after inserting attack or benign instructions (addressing C3), with λ = 0.2.
    • Benign training data contains legitimate instructions aimed at human readers, so imperative mood is not itself a positive label; the authors note that this regularizer does not guarantee unchanged scores or content preservation on every input.

    Training and implementation details

    • E, θ, b are jointly optimized offline (Adam, 6 epochs, seed 0) and fixed at inference; no defensive decoding or separate verification model is needed.
    • Key parameters: soft prompt length M = 16, check budget R = 2; the Qwen readout head uses 16 query heads each at layers {3,7,11,15}, with 65,601 trainable parameters; Gemma 4 12B has 61,505 (Appendix A.4, A.5).
    • Training uses leave-one-domain-out AgentDojo trajectories, and evaluation-family attack outputs are excluded from training and validation; AgentDyn reuses the all-domain AgentDojo checkpoint without further training (§5.1, Appendix A.3).
  4. What experiments did the paper conduct?

    On AgentDojo/AgentDyn with a frozen Qwen3.5-9B, compared against seven baselines, with ablations, grey-box/white-box adaptive attacks, threshold sweeps, and a Gemma 4 12B reproduction.

    Experimental setup

    • Models evaluated: frozen Qwen3.5-9B (main experiments), frozen Gemma 4 12B (reproduction, §5.7).
    • Benchmarks and scale: AgentDojo (57 clean / 778 attacked episodes; including 389 attacks each for important_instructions and tool_knowledge) and AgentDyn (60/560 per setting; A uses the original parser, B uses schema-aware parameter coercion) (§5.1, Appendix A.1).
    • Baselines: no defense plus seven defenses—Sandwich, Spotlighting, AttriGuard, DRIFT, tool_filter, Attention Tracker, PISanitizer, all adapted to the same frozen task model.
    • Metrics: CU (clean task success rate), ASR (attack success rate), AU (task success rate under attack), Joint (task success and attack failure on the same attacked episode); episodes that complete with errors are retained.
    • Determination method: task success and attack success are determined by the benchmark protocol; the paper does not state that an LLM judge is used; threshold sweeps and ablations use the task-complete subset (AgentDojo 57/57, AgentDyn B 60/60), and sampling keys are shared across methods.
    • Number of repetitions: one run per key; paired comparisons include differences from independent runs (Appendix A.1).

    Main results

    According to Table 3 (frozen Qwen3.5-9B, %):

    Swipe horizontally to read the table

    DefenseAgentDojo ASR↓AgentDojo Joint↑AgentDyn A Joint↑AgentDyn B Joint↑
    No defense34.651.415.442.7
    Sandwich27.258.712.940.0
    Spotlighting27.558.413.840.9
    AttriGuard8.172.516.443.0
    DRIFT1.968.521.223.0
    tool_filter3.239.61.81.1
    Attention Tracker0.015.00.00.0
    PISanitizer1.729.215.216.1
    SEAL0.177.518.951.2
    • The authors state that SEAL's direct sanitization provides stronger protection than natural-language reinforcement with better task completion: ASR drops from 27.2–27.5% to 0.1%, and Joint rises by 18.8–19.1 percentage points.
    • The authors state that SEAL exceeds the best Joint of the auxiliary-LLM-reasoning family (77.5% vs. 72.5%) and does not generate defense decisions; existing attention defenses achieve ASR of at most 1.7% but Joint of only 15.0–29.2%.
    • Exception: on AgentDyn A, SEAL's Joint (18.9%) is lower than DRIFT's (21.2%); SEAL's ASR is 0.0% on both AgentDyn settings, and its Joint is highest in B (51.2%).

    Inference cost

    • Table 4: SEAL averages 64.6 and 257.9 prefill tokens and 0 generation tokens per tool context on AgentDojo and AgentDyn B; the authors state this is about a 127× and 29× reduction relative to PISanitizer (8,185.6 / 7,404.9 prefill).
    • The authors state that SEAL's token cost is comparable to lightweight natural-language reinforcement methods while achieving higher Joint and lower ASR; costs are measured on fixed tool contexts (Appendix C.1).
    • Appendix C.1 additionally reports that the instrumented segment with cached SEAL takes 233.6 ms (AgentDojo) and 329.3 ms (AgentDyn B) on an H200; the authors note this does not constitute an end-to-end latency saving.

    Adaptive attacks

    • Grey-box prefix transfer (Table 6, 24 Banking/Slack pairs, attacker optimizes a 20-token prefix with a surrogate model): SEAL reduces ASR from 19.4% with no defense to 1.4%, and raises Joint from 65.3% to 73.6%; with random prefixes, SEAL's ASR is 0.0%.
    • White-box search (Appendix C.3, Table 16, against deployed parameters, 3 execution seeds sharing task pairs): under optimized prefixes, SEAL's ASR is 4.2% (no defense 25.0%), and under infixes diluted within a unit, 2.8% (no defense 25.0%); the authors state that key-mediated and within-unit residual escapes remain after sealing.

    Sanitization quality and threshold sweep

    • Appendix C.2 (Table 13): on AgentDojo, SEAL's clean removal is 3.1% and Removal F1 is 93.3%, versus PISanitizer's 46.3% / 49.8% and Attention Tracker's 75.4% / 72.9%; the authors state that SEAL's deletions are more concentrated on injected content.
    • Threshold sweep (§5.6, Table 17, m ∈ {0, 0.5, 1, 2}): on AgentDojo, ASR is 0.0–3.5% and Joint is 71.9–78.9%; on AgentDyn B, ASR is 0.0% throughout and Joint is 51.7–55.0%; the authors state that SEAL does not depend on a single operating point.
    • Gemma 4 12B reproduction (Table 7, AgentDojo clean + important_instructions): SEAL reduces ASR from 57.1% to 0.3% and raises Joint from 33.4% to 66.8%, the lowest ASR and second-highest Joint among the evaluated methods; the authors state this supports applicability across model families.

    Other ablations and analyses

    • Component ablation (Table 5, AgentDojo task-complete subset, retrained variants): full SEAL Joint is 78.9%; w/o M1 drops to 71.9%, w/o M2 to 66.7%, w/o M3 to 75.4%, with ASR 0.0% for all variants.
    • O1 intervention (Table 1, 242 Banking/Slack pairs): an optimized suffix reduces PISanitizer's first-round target detection from 185/185 to 120/185, returning to 170/185 after restoring the control query.
    • O2 context sensitivity (Table 2): with five copies of the payload, PISanitizer overturns 85/150 original deletion decisions (56.7%); adding four benign sentences overturns 26/150 (17.3%).
    • O3 (Figure 2): PISanitizer deletes 46.3% of clean text, Attention Tracker 75.4%.
    • Negative result: the AgentDyn clean-task audit (Table 15) shows that delegated instructions are deleted in both failed and successful tasks; the authors state that deletion alone cannot explain the failures, and that this post-hoc analysis does not isolate the effect of the preservation objective.
  5. What are some points that can be further explored?

    The authors list three limitations: access to internal states is required, evaluation is limited to two backbones and some domains, and sanitization may still mistakenly delete task evidence.

    Limitations and future directions noted by the authors

    • SEAL requires access to the internal states of the frozen backbone and does not directly apply to API-only models (Limitations).
    • Evaluation is limited to two backbones and selected domains in AgentDojo and AgentDyn; generalization to broader backbones and domains remains to be established (Limitations).
    • Although SEAL can identify attack target units, sanitization may still remove useful task evidence and reduce task utility (Limitations).

    Experimental coverage

    • The backbones tested are frozen Qwen3.5-9B and Gemma 4 12B, 2 in total; the benchmarks are AgentDojo (57 clean/778 attacked) and AgentDyn (60/560 per setting) (§5.1).
    • Baselines cover seven methods across three defense families, all adapted to the same frozen task model; the authors state that the baseline set was chosen after known development results and subject to available training artifacts and local adaptation constraints, and that omitted methods are not thereby shown to be worse (Appendix A.2).
    • Adaptive evaluation includes grey-box prefix transfer (24 Banking/Slack pairs, Table 6) and white-box prefix/infix search against deployed parameters (3 execution seeds sharing task pairs, Appendix C.3); the authors note these executions are not 72 independent attack searches.
    • One execution per key, and paired comparisons include independent-run variance (Appendix A.1); the paper does not report whether task success and attack success determinations used LLM judges or human agreement.
    • Training data exclude evaluation-family attack outputs, but the authors note that benign outputs of these episodes remain usable and earlier text may contain injected text, so this exclusion does not mean no exposure to the evaluation family at all (Appendix A.3).
  6. Summarize the main content of the paper

    SEAL uses an offline-learned soft prompt to sanitize tool outputs for a frozen local agent, reducing ASR to 0.1% and raising Joint to 77.5% on AgentDojo.

    A defense paper against indirect prompt injection for local LLM agents, targeting deployment settings with limited inference budget and a frozen task model.

    • Problem: tool outputs may contain both useful evidence and redirecting instructions; analyzing existing attention-based sanitization (with PISanitizer as the representative), the authors find three problems: the scoring reference depends on the inspected text, token scores are affected by context normalization, and suppressing attacks sacrifices task performance.
    • Method: SEAL offline learns a soft prompt E and a scoring readout (θ, b), scores with the frozen model, and deletes locally: M1 constructs a sealed query from the trusted initial context that is independent of the tool text; M2 scores before softmax normalization; M3 uses a retention regularizer to encourage stable scores for benign content. It generates no defense tokens and uses no separate verification model.
    • Main results: on AgentDojo with frozen Qwen3.5-9B, SEAL reduces ASR from 34.6% to 0.1% and raises Joint from 51.4% to 77.5%, outperforming seven baselines (Table 3); defense tokens are about 1/127 of PISanitizer's (Table 4).
    • Robustness: under grey-box prefix transfer attacks, ASR is 1.4% (19.4% without defense, Table 6); under white-box search, prefix ASR is 4.2% and infix 2.8% (25.0% each without defense, Table 16); in the Gemma 4 12B replication, ASR drops from 57.1% to 0.3% (Table 7).
    • Exception: on AgentDyn A, Joint is 18.9%, lower than DRIFT's 21.2%; the authors state that key-mediated and intra-unit residual escapes remain after sealing.
    • Authors' conclusion: the three components together achieve selective deletion without auxiliary LLM reasoning, improving task completion under attack while suppressing attacks at low token cost; limitations are that access to model internal states is required, evaluation coverage is limited, and sanitization may still mistakenly delete task evidence.

Related papers

Show 3 more papers
Read originalarxiv.org