Sealed queries let local agents cut injected instructions
Reviewing SEAL: Sealed Queries for Local Sanitization against Indirect Prompt Injection · Doohyun Kim, Donghwa Kang, Mingyu Jun et al.

Researchers show a local agent can strip injected instructions from tool output using its own attention, scored against a reference the attacker never touches. It cuts attacks to almost nothing while keeping task evidence, though it needs model internals and leaves some room for attackers who hold the defence parameters.
An agent reads a tool response, and buried in it is an instruction to do something the user never asked for. Against an undefended local model on one standard benchmark, about a third of those attempts work. With the defence in this research, that drops from 34.6% to 0.1%.
The defence, which the researchers call SEAL, edits the tool output before the agent acts on it. It does not add a second model to judge the text, and it does not ask the task model to generate anything. It finds the chunks of text that look like an attacker's goal rather than task evidence, and deletes them.
Using a model's attention to spot injected text is not a new idea. You look at how the model's internals respond to each token and flag the odd ones. The weakness has always been that the inspected text takes part in its own inspection. If the scoring reference is built partly from the tool output, the attacker shapes the question as well as the answer.
The clever part is how the researchers close that door. The scoring queries come only from the trusted starting context plus a short learned prompt. They are computed and cached before any tool text arrives. An attacker can write anything into an email or web page. They cannot touch the reference it is measured against.
The second detail is subtler. Attention is normally a share: every token competes with every other token for weight. That gives an attacker a lever, because padding can make the injection's share look small. SEAL scores each token on its raw value before that sharing happens. The ablations say this choice mattered most.
The cost is modest. The researchers report roughly 127 times fewer defence-related tokens than PISanitizer, a recent sanitisation defence. It also deletes little legitimate text, so task completion under attack rises from about half to over three quarters. That matters, because a filter that shreds evidence just trades one failure for another.
The adaptive attacker still has a foothold
What I respect is that they tested attackers who know the defence exists. Optimised prefixes built against a surrogate model mostly failed. White-box searches with access to the deployed parameters did better, finding residual evasions that work through the cached keys or hide inside a single text unit. Those learned parameters become something worth stealing.
The precondition is the bigger limit. SEAL needs the model's internal attention states, so it does not apply to API-only models. It was trained and tested on two backbones, Qwen3.5-9B and Gemma 4 12B, and generalisation beyond them is not established. For anyone running agents on local open-weight models, it is worth a serious look.
The seal holds against text. It is thinner against someone holding the parameters.
Further analysis
Problem
The paper studies indirect prompt injection against locally deployed frozen large language models that use untrusted tool outputs. Attackers embed instructions in tool responses to redirect agents away from their authorised tasks. Defences must suppress such attacks while preserving benign task evidence and operating under constrained inference budgets typical of local deployment, without introducing extra verifier models or heavy runtime costs.
Approach
SEAL sanitises tool outputs by learning a short soft prompt and a linear readout offline while keeping the task model frozen. At inference SEAL constructs sealed queries from the trusted initial context and the learned soft prompt, caches these queries, and scores tokens using the model’s cached keys before softmax normalisation so scores are not affected by competing context tokens. Scoring is aggregated by layer and head, producing unit-level mean scores for contiguous text units. Units whose scores exceed a learned bias are deleted; the edited suffix is replayed and rescored up to a fixed number of passes. Training jointly optimises ranking and boundary losses to separate attack-goal units from benign units, with a preservation regulariser that penalises score changes on unchanged benign units after insertions. SEAL uses modest settings in the evaluation: soft-prompt length 16, two inspection passes, and a preservation weight of 0.2. The method requires access to internal model states and is trained and evaluated on frozen Qwen3.5-9B and replicated on Gemma 4 12B.
Key Findings
- Substantial reduction in attacker success: on the AgentDojo benchmark SEAL reduced attack success rate to 0.1% from around 27.2–27.5%, while increasing Joint (task completion without attack success) by about 18.8–19.1 percentage points.
- Low collateral deletion and high removal quality: SEAL removed 3.1% of clean characters and achieved 93.3% removal F1 for injected blocks on AgentDojo, compared with 46.3% clean removal and 49.8% removal F1 for a representative attention-based baseline.
- Low runtime token cost: SEAL’s Prefill token costs averaged 64.6 tokens on AgentDojo and 257.9 on AgentDyn B, yielding roughly 127× and 29× reductions in defence-related tokens relative to PISanitizer on those benchmarks.
- Robustness to adaptive attacks and transfer: grey-box surrogate-optimised prefixes saw ASR reduced from 19.4% to 1.4% and Joint increased from 65.3% to 73.6%; white-box prefix and infix searches showed markedly lower ASR under SEAL than without defence, although some residual evasion remained.
- Component importance: ablating the sealed-query construction, pre-softmax scoring, or the preservation regulariser each reduced Joint performance, with pre-softmax scoring having the largest individual impact.
- Cross-backbone applicability: retraining SEAL on Gemma 4 12B reduced ASR from 57.1% to 0.3% and raised Joint from 33.4% to 66.8%, indicating the method transfers across model families.
Limitations
SEAL requires access to internal attention states and so does not apply to API-only models. Evaluation is limited to two backbones and selected domains; generalisation across further models and domains is not established. Sanitisation can still remove useful task evidence and reduce utility in some cases, and residual key-mediated or within-unit evasions remain possible.
Implications
For attackers, the paper demonstrates that adaptive optimisation—including grey-box and white-box prefix or infix searches—can still find partial evasions, so defences must expect key-mediated and within-unit strategies. For offensive research, SEAL highlights that sealed reference queries and pre-softmax scoring raise the bar for transferable attacks by protecting the scoring reference from inspected text and preventing context-normalisation manipulations. However, access to deployed defence parameters enables stronger white-box searches that can yield residual evasion, suggesting attackers with white-box access can still probe for weaknesses.
The paper title, authors and abstract
SEAL: Sealed Queries for Local Sanitization against Indirect Prompt Injection
Indirect prompt injection threatens local LLM agents through untrusted tool outputs, motivating defenses that suppress attacks while preserving task evidence under limited inference budgets. We introduce SEAL, which learns a soft prompt and scoring readout offline to sanitize tool outputs using a frozen task model. SEAL constructs scoring queries from trusted initial context and the learned prompt, keeping the reference independent of inspected tool text. It scores tokens without normalization across context tokens and uses preservation regularization to encourage retention of useful evidence during localized deletion. This design requires neither defense-generated tokens nor a separate verifier model. Across AgentDojo and AgentDyn, SEAL suppresses attacks while improving task completion under attack. Specifically, on AgentDojo, SEAL reduces attack success from 34.6\% to 0.1\% and increases Joint---task completion without attack success---from 51.4\% to 77.5\%, while using approximately $127\times$ fewer defense-related tokens than PISanitizer, a state-of-the-art prompt injection defense. Replication on a second backbone with the same training recipe supports applicability across model families.


