arXiv:2610.39758cs.CROct 2026

Manuscript Offprint

arXiv:2610.39758

SEAL: Sealed Queries for Local Sanitization against Indirect Prompt Injection

Doohyun Kim, Donghwa Kang, Mingyu Jun, Brent ByungHoon Kang

Abstract

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×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.

1 Introduction

Recent advances in compact, openly available large language models (LLMs) are making local deployment increasingly practical, improving reasoning and instruction following at modest model sizes (Gemma Team, 2025; Qwen Team, 2026). Developers report concerns about agent data security and privacy (Stack Overflow, 2025), and local LLM pipelines already support privacy-preserving clinical information extraction (Wiest et al., 2024). Improving capabilities and practical demand for data control make securing local agents increasingly important.

Local deployment does not make the content an

(a) Natural-language reinforcement

Figure

(b) Auxiliary LLM inference

Figure

(c) Attention-based defenses

Figure

Figure 1: Representative defense pathways for frozen local agents. (a) Natural-language reinforcement adds reminders or delimiters to the agent input. (b) Auxiliary LLM inference generates extra decisions to guide or verify execution. (c) Attention-based defenses inspect internal attention signals to detect or remove suspicious content.

agent reads trustworthy. A retrieved page, message, or record may contain useful task data alongside instructions written to redirect the agent. This threat, indirect prompt injection (IPI), crosses the boundary between external data and authorized instructions (Greshake et al., 2023; Zhan et al., 2024; Debenedetti et al., 2024). We consider local agents whose initial instructions and tool definitions are trusted but whose tool outputs may be attacker-controlled. We keep the task model frozen, protecting the model the operator has already selected.

Memory capacity and model-loading costs constrain local inference (Alizadeh et al., 2024), while multiple large models can incur memory contention and transfer overhead on consumer GPUs (Xu et al., 2026). We therefore target resource-constrained deployments, seeking stronger security with preserved task performance and limited additional in-ference, without requiring a separate verifier LLM. Figure 1 summarizes three defense families that reuse the selected task model.

These families present different tradeoffs for our goal. Natural-language reinforcement is lightweight (Schulhoff, 2024; Hines et al., 2024), but leaves substantial attack success in our local-agent evaluation ( §5.2§5.2). Auxiliary LLM inference can strengthen protection (He et al., 2026; Li et al., 2025), but extra calls and generated decisions consume additional inference budget even when they reuse the task model ( §5.3§5.3).

Attention-based defenses offer a promising route by using internal attention signals, reducing reliance on generated verification responses (Hung et al., 2025; Geng et al., 2026). The challenge is to make these signals reliable without sacrificing task evidence: scores can depend on the inspected text and surrounding context, and removal can discard useful content. These challenges motivate the design requirements in §3.

We introduce SEAL, which searches for a short soft prompt —a sequence of continuous input embeddings—that helps the frozen model distinguish injected instructions from benign task content. SEAL combines a scoring reference built from trusted context with selective removal optimized to preserve useful content. It sanitizes tool outputs before the agent continues, without generating defense responses or changing the task model's weights.

Our contributions are:

• We analyze attention-based sanitization in frozen local agents and identify requirements for reliable scoring and task preservation.

• We introduce SEAL, which searches for a soft prompt to elicit security signals from the task model and selectively removes injected instructions while preserving benign content.

• Through evaluations against seven baseline defenses across multiple benchmarks and additional robustness analyses, we demonstrate that SEAL reduces attack success while maintaining high Joint with low defense-related token costs.

References (28)