Skip to content

SpanGuard: A Lightweight IPI Defense That Decouples Instruction Localization from Authorization JudgmentSpanGuard: Decoupling Instruction Localization from Authorization for Lightweight IPI Defense

arXiv: Jailbreaks, Prompt Injection, Poisoning & Defenses· arXiv:2610.26013· Yinxiang Wang, Zehua Ma, Kejiang Chen, Weiming Zhang, Han FangUniversity of Science and Technology of ChinaIndexed by this site · 2026-10-20· Originally publishedDefenses

Quick read

Defenses

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

On AgentDojo, SpanGuard with a 7B guardrail achieves an Overall ASR of 0.32% against GPT-4.1-mini.

Threat modelExternal black-box defense: the attacker embeds malicious instructions in observation o within external content it controls, to induce the agent to execute the attacker's specified task. The defense can read the trusted user instruction u and the intercepted o, and sanitizes it into o′ before the agent consumes it, without modifying or accessing the agent's parameters, internal state, or reasoning process.

Questions
Detecting indirect prompt injection requires simultaneously localizing instructions in tool outputs and judging whether they are authorized by the user's request. The authors believe small models' difficulty mainly comes from the coupling of these two steps, and therefore ask whether defense can be maintained using only a small LLM.
Methods
SpanGuard first performs attack-agnostic chunking: after sentence and line boundaries, it splits further where the cosine between adjacent words is below γ, then greedily merges using the NLL of the next unit's first token relative to τ. τ is calibrated using only benign outputs at a false boundary rate of α=15%. A small model performs two-question authorization using the user task and source, and deletes a block unless it can be explicitly cleared.
Experiments and results
Table 1: The 7B guardrail's Overall ASR is 0.32% against GPT-4.1-mini and 0.00% against Llama-3.3-70B. The authors state the utility loss is negligible. In Table 4, Greedy ASR is 0.0% and Evolutionary is 12.9%.
Limitations and future work
The paper does not specifically discuss limitations. The experiments cover four AgentDojo suites, two victim models, thirteen baselines, and analyses of scale, family, adaptive attacks, and segmentation. The paper does not report the number of tasks or γ, nor does it state the victim models for Table 2, Table 4, and Table 5.
Experimental setupGPT-4.1-mini、Llama-3.3-70B-Instruct et al. · AgentDojo · ASR、BU et al.
Evaluated models
GPT-4.1-miniLlama-3.3-70B-InstructQwen2.5-7B-InstructQwen3-8BLlama-3.1-8BGemma-3-12BMistral-Nemo-12BGLM-4-9B
Benchmarks
AgentDojo
Metrics
ASRBUUA
AI summarySpanGuard proposes a lightweight indirect prompt injection (IPI) defense: it decouples instruction localization from authorization judgment, allowing even small models to maintain strong defense. It first uses unsupervised segmentation to split heterogeneous tool outputs into local regions to localize suspicious instructions, then has a small language model make block-level authorization judgments. Experiments show an attack success rate of 0.32%, negligible loss of benign utility, and effectiveness retained on smaller models.

SpanGuard proposes a lightweight indirect prompt injection (IPI) defense: it decouples instruction localization from authorization judgment, allowing even small models to maintain strong defense. It first uses unsupervised segmentation to split heterogeneous tool outputs into local regions to localize suspicious instructions, then has a small language model make block-level authorization judgments. Experiments show an attack success rate of 0.32%, negligible loss of benign utility, and effectiveness retained on smaller models.

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?

    Small models struggle to simultaneously localize injections and judge authorization; SpanGuard separates the two steps.

    Small models struggle to simultaneously localize injections and judge authorization, which makes lightweight IPI defense difficult.

    • Scenario: The authors state that LLM agents continuously consume web pages, messages, documents, and API responses. When instructions and external data are in the same context, it is necessary to judge what the content says and whether the instruction is authorized by the user's request; the authors state that when this distinction fails, behaviors such as unauthorized tool use and sensitive data disclosure may occur.
    • Existing shortcomings: The authors state that the effectiveness of LLM guardrails is tightly bound to the underlying model's capability, and detection degrades when switching to smaller or weaker models. Existing approaches mostly have a single model perform localization and authorization simultaneously over the entire observation.
    • Observation: The authors believe the difficulty for small models mainly comes from the coupling of the two steps, rather than either subproblem being hard on its own. Injected instructions are often semantically discontinuous with surrounding content, so lightweight, unsupervised segmentation can delineate local regions.
    • Proposed method: SpanGuard first performs attack-agnostic localization, then uses a small LLM to judge for each block whether the instructions in it are authorized by the user's request.
    • Threat model:
      • Goal: Induce the agent to execute the attacker's specified task.
      • Capability: Embed malicious instructions in observation o within external content controlled by the attacker. The paper calls this the standard threat model for indirect prompt injection and does not separately write the attacker's weight knowledge.
      • Victim system: An LLM agent that produces output based on a trusted user instruction u and external observation o.
      • Defense privileges: External black-box defense. It can read u and the intercepted o, and sanitize it into o′ before the agent consumes it; it does not modify or access the agent's parameters, internal state, or reasoning process.
  2. What related research exists?

    The authors divide IPI defenses into prompt, training, and system layers, and argue that LLM guardrails depend on model capability.

    Section 2 of the paper discusses three lines; the experiments separately list comparison baselines.

    Indirect prompt injection in agents

    • External content poisoning: Greshake et al. (2023) embed malicious instructions in web pages, retrieved documents, or other external content, affecting agents that rely on external resources.
    • Evaluation and automatic generation: Zhan et al. (2024) and Debenedetti et al. (2024) evaluate IPI across various agent tasks and environments. Pasquini et al. (2024) use optimization to automatically generate injection instructions that evade conventional preprocessing.

    Existing IPI defenses

    • Prompt-based: Spotlighting by Hines et al. (2024), and Debenedetti et al. (2024), use source signals, delimiting untrusted content, or repeating trusted instructions to change how instructions and external content are presented.
    • Training and alignment: Chen et al. (2025a;b;c) adjust the target LLM to distinguish legitimate instructions from injected prompts. ProtectAI (2023), Chennabasappa et al. (2025), Li et al. (2025), and Liu et al. (2025) train dedicated models to detect injections in external observations.
    • System level: Debenedetti et al. (2025) and An et al. (2025) isolate trusted and untrusted flows at the architecture or execution layer, or restrict tool execution according to predetermined policies. The authors consider these lines to provide complementary protection but note they may depend on model capability, training coverage, or additional architectural constraints.

    LLM guardrails

    • Observation sanitization: PromptArmor (Shi et al., 2025) prompts an LLM to locate and remove injected instructions from external observations. The authors state capable LLMs are effective at this.
    • Behavior or tool signals: Kim et al. (2026), Zhu et al. (2025), and He et al. (2026) detect injections based on agent behavior or tool calls. The authors argue that directly having an LLM localize and judge at the same time may make the defense highly dependent on the guardrail model's capability.

    Baselines and benchmark

    • Benchmark is AgentDojo. Baselines total thirteen: Spotlighting; PIGuard, PromptGuard, DataSentinel, PromptLocate, Chen et al., DataFilter; tool filter, Llama-Guard-3, PromptArmor, CausalArmor, MELON, AttriGuard.

    The authors position this paper as explicitly separating localization and authorization to reduce dependence on guardrail model capability.

  3. How does the paper address this problem?

    SpanGuard first chunks by semantic discontinuity, then uses a small model to make block-level authorization decisions.

    SpanGuard separates localization from authorization: it first uses attack-agnostic unsupervised segmentation to obtain local blocks, then has a small model judge only a single block for whether it contains unauthorized instructions.

    Setting and decoupling

    • Given a trusted user instruction u and observation o, the agent outputs y = Agent(u, o). The defense sanitizes o into o′ before consumption, so that subsequent output completes the user's task and does not execute the attacker's task.
    • The authors formulate existing guardrails as jointly searching regions over the full observation and performing authorization. The coupling requires the model to simultaneously find the location and judge the relationship of that region to the user's intent.
    • This paper first obtains a partition R = L(o), then authorizes region by region. When unauthorized instructions are present, di=Aϕ(u,pi,ri)∈{0,1}, where di=1 means deletion. pi is the trusted source information for that region.

    Attack-agnostic localization

    • Units: split at natural sentence boundaries and line boundaries, then refine using local semantic continuity. The word representation hi is mean pooling of subword contextual embeddings; when the cosine similarity si between adjacent words is below a fixed threshold γ, a boundary is added. The paper does not give γ. This yields the unit sequence U.
    • Greedy chunking: merge consecutive units from left to right. The boundary score is the negative log-likelihood of the first token of the next unit conditioned on the current block, bk=−log Pθ(t(1)rk+1∣ Bk). If bk is below τ, merge into the current block; otherwise start a new block.
    • Calibration: search τ using only benign tool outputs so that the empirical false boundary rate approaches the target α. The implementation takes α=15%. The authors state this rate changes monotonically with τ. Neither calibration nor inference uses attack samples.
    • In the implementation, both localization and authorization use Qwen2.5-7B-Instruct. The paper does not separately name the word-vector model.

    Block-level authorization

    • Each block is independently judged for whether it contains instructions that would make the agent deviate from the user's task. The input is the user task u, the source pk, and the block itself. pk gives the tool call and the field in which the block resides.
    • The judgment is split into two questions: whether the block contains instructions to the assistant; and whether the content of those instructions and their source are authorized by the user's task. Appendix A.1 gives the full prompt and writes the source as the tool name and parameters, the declared return fields, and the field in which the block resides; when no return fields are declared, the entire output is treated as one unstructured free-text segment.
    • Fail-safe: a block is kept only if the judge explicitly confirms it contains no unauthorized instructions. If it is judged to contain unauthorized instructions, or no valid affirmative judgment is given, it is recorded as to be deleted. The authors state this is to avoid treating a weaker model's uncertain or compromised judgment as safe.

    Sanitization

    • After deleting the regions marked as unauthorized, o′ is obtained and passed to the original agent. The defense does not change the agent's parameters or internal state. ASR in the experiments is determined by AgentDojo's security checks.
  4. What experiments did the paper conduct?

    On AgentDojo, the 7B guardrail's Overall ASR against GPT-4.1-mini is 0.32%.

    Experimental setup

    • Benchmark: AgentDojo's banking, slack, travel, and workspace. Six targeted attacks: direct, ignore previous, system message, injecagent, important instructions, tool knowledge. Appendix A.2 gives the attack templates. The paper does not report the number of tasks.
    • Victim models: GPT-4.1-mini and Llama-3.3-70B-Instruct.
    • Guardrail: both localization and authorization use Qwen2.5-7B-Instruct, zero-shot, temperature 0; the localization threshold is calibrated on benign tool outputs at α=15%. Table 2 records it as Qwen2.5-7B, and the paper does not state whether it is the same checkpoint.
    • Baselines: the thirteen listed in Question 2. The independently deployed LLM guardrails use open-source defense models of about 7B and follow each method's original prompts and inference pipeline. Appendix A.3 has implementation notes.
    • Metrics: BU is benign task utility; UA is utility under attack; ASR is the proportion of attacks that achieve the injection goal according to the benchmark's security checks. The authors state that an effective defense should lower ASR while preserving BU as much as possible and keeping UA close to BU.
    • Evaluation: the paper does not use a separate LLM judge, nor does it report the number of repetitions or human agreement.

    Main results

    According to the Overall column of Table 1. SpanGuard uses the above 7B guardrail.

    Swipe horizontally to read the table

    DefenseGPT-4.1-mini ASRGPT-4.1-mini UALlama-3.3-70B ASRLlama-3.3-70B UA
    No defense30.79%73.81%25.08%59.68%
    SpanGuard0.32%74.60%0.00%62.86%
    PromptArmor2.54%83.97%2.06%62.70%
    MELON0.63%53.49%0.16%52.54%
    AttriGuard2.86%71.90%8.10%67.14%
    Spotlighting0.95%62.06%2.22%45.71%
    PromptGuard21.75%51.90%15.87%50.95%
    Chen et al.22.38%51.90%14.60%49.68%

    Not listed: PIGuard, DataSentinel, PromptLocate, DataFilter, tool filter, Llama Guard 3, CausalArmor.

    • The authors state that SpanGuard's Overall ASR is the lowest among the evaluated defenses on both victim models, and that it does not trade aggressive sanitization for low ASR. The UA in the table is not the highest in each column. BU is not in the table: on GPT-4.1-mini, SpanGuard is 70.53% and no defense is 73.68%; on Llama-3.3-70B-Instruct, it is 43.16% and no defense is 44.21%. The authors state that the benign utility loss is negligible. The 0.32% in the abstract matches the Overall for GPT-4.1-mini in Table 1, not the Llama result.
    • The authors state that important instructions and tool knowledge have particularly high ASR with no defense; SpanGuard reduces the ASR of these two categories to 0.00% on both victim models. PromptArmor remains at 1.90% and 10.48% on GPT-4.1-mini, and 0.95% and 7.62% on Llama-3.3-70B. The authors state that whole-input judgment is disturbed by injected content; chunking, block-level authorization, and fail-safe restrict judgment to local parts and conservatively reject when safety cannot be established.
    • Not all six attacks are 0: on GPT-4.1-mini, the ASR for direct and ignore previous is 0.95%. On Llama-3.3-70B-Instruct, the ASR for all six attacks is 0.00%.

    Guardrail scale, family, and latency

    • Figure 3's horizontal axis is model scale (Qwen2.5: 0.49, 1.54, 3.09, 7.62, 14.8, 32.8, 72.7; Qwen3: 0.60, 1.72, 4.02, 8.19, 14.8, 32.8; Llama-3.1: 1.24, 3.21, 8.03, 70.5; unit B). The vertical axis is BU, UA, ASR, with ticks from 0.0 to 0.8. The legend is SpanGuard, PromptArmor, tool_filter, AttriGuard, CausalArmor, No Defense. The curve endpoints cannot be seen in plain text. The paper does not state the victim model for this figure.
    • The authors state that SpanGuard maintains first-tier safety across all evaluated scales, still maintains low ASR at smaller scales, and that BU and UA are broadly comparable to PromptArmor. The authors state that PromptArmor's ASR rises as the defense model gets smaller; action-level defenses are more stable across scales but have a larger utility drop, and ASR remains above 10% on most model configurations. This sentence does not name which of the legend entries it refers to.
    • The variable in Table 2 is Judge model; the paper does not state the victim model, and its numbers are not the same row as the 0.32% in Table 1. BU/UA/ASR: Qwen2.5-7B is 69.10%/64.90%/2.10%, Qwen3-8B is 71.10%/71.10%/0.00%, Llama-3.1-8B is 71.10%/61.90%/1.00%, Gemma-3-12B is 72.20%/71.10%/0.00%, Mistral-Nemo-12B is 72.20%/69.10%/0.00%, GLM-4-9B is 67.00%/60.80%/0.00%. The authors state that the effect is not strongly tied to a particular model family.
    • Table 3 additional latency (seconds): no defense 0.00, Spotlighting <0.01, PIGuard 0.04, CausalArmor 0.35, PromptArmor 0.86, DataSentinel 2.64, SpanGuard 3.89, MELON 8.94, AttriGuard 19.29, PromptLocate 42.21. The authors state that judging multiple chunks separately brings additional inference, which should be viewed together with lower dependence on model capability. The paper does not report hardware.

    Adaptive search

    • Search-based attacks are constructed following Nasr et al. (2026), and AttriGuard's payload mutation and defense-aware evaluation are adopted. The strategies are Evolutionary and Greedy. The paper does not report sample size, number of queries, or victim model.
    • Table 4 ASR: SpanGuard is 12.9% and 0.0%; AttriGuard is 9.7% and 19.4%; DataFilter is 22.6% and 32.3%; PromptArmor is 48.4% and 51.6%; Spotlighting is 58.1% and 64.5%. The order is Evolutionary, Greedy.
    • The authors state that SpanGuard has the lowest ASR under Greedy and is comparable to AttriGuard under Evolutionary; in the table, AttriGuard is lower in the Evolutionary column. The authors believe that independent chunking plus fail-safe constrains the attacker's effective search space.

    Chunking granularity and judgment design

    • Figure 4's vertical axis is Next-token NLL (reset-context). Labeled medians: inj. start 10.93, inj. end 7.09, inj. inner 2.62, host (atk) 1.25, host (benign) 1.05, and α=0.15 is marked. The authors state that the NLL at injection boundaries is higher than inside the injected segment and in benign text.
    • Table 5 does not state the victim model. Whole output's BU/UA/ASR/judgments per task are 73.20%/19.59%/0.00%/6.8; Sentence is 75.26%/53.61%/21.65%/114.4; Block is 71.13%/69.07%/2.06%/36.8. The authors state that relative to sentence, block reduces the number of judgments by 67.8%, with an ASR of 2.06%. The main text does not separately explain Whole output's UA.
    • Table 6: block only gives ASR 3.65% (BU 73.68%, UA 77.94%); adding source gives ASR 0.32% (BU 70.53%, UA 74.60%). This row's values are the same as SpanGuard Overall for GPT-4.1-mini in Table 1, and the table title does not state the victim model. Direct injection judgment gives ASR 18.33% (BU 87.50%, UA 75.00%); instruction recognition plus authorization gives 0.83% (BU 85.00%, UA 83.33%). The BU of the two groups is not at the same level, and the paper does not state whether it is the same task subset. The authors state that source information lowers ASR; the two-step judgment lowers ASR from 18.33% to 0.83% while raising UA.

    Other ablations and analyses

    • γ: the paper does not give a value (Section 4.2). α is 15% in the implementation, and Figure 4 marks it as 0.15.
    • Apart from the above tables, the paper does not give other numerical ablations.
  5. What are some points that can be further explored?

    The paper does not specifically discuss limitations or future research directions.

    Limitations and future directions noted by the authors

    • The paper does not specifically discuss limitations. The Conclusion (Section 6) only summarizes the results and does not list shortcomings or future research questions.

    Scope of experimental coverage

    • The evaluation covers AgentDojo's banking, slack, travel, and workspace, with six targeted attacks, and victim models GPT-4.1-mini and Llama-3.3-70B-Instruct (Section 5.1, Table 1).
    • The baselines are thirteen defenses; the independently deployed LLM guardrail is about 7B. SpanGuard's main experiments use Qwen2.5-7B-Instruct, zero-shot, temperature 0, α=15% (Section 5.1).
    • Figure 3 compares multiple size tiers of Qwen2.5, Qwen3, and Llama-3.1; Table 2 reports six named judge models. The paper does not state the victim model for these two.
    • The adaptive attacks are Evolutionary and Greedy, following Nasr et al. (2026) and AttriGuard's payload mutation and defense-aware evaluation (Section 5.4, Table 4). The paper does not report sample size or number of queries.
    • ASR is computed according to AgentDojo's security checks. The paper does not report the number of tasks, number of repetitions, the value of γ, or human agreement.
  6. Summarize the main content of the paper

    SpanGuard uses unsupervised chunking plus small-model authorization to lower IPI ASR on AgentDojo.

    SpanGuard is an external black-box guardrail for indirect prompt injection against LLM agents. It separates "where to look" from "whether it is authorized," to reduce dependence on guardrail model capability.

    The difficulty the authors address is that detecting IPI requires both finding possible injections in heterogeneous tool outputs and judging whether they are authorized by the user's request. The authors believe small models perform worse mainly because these two steps are bound into a single full-observation inference.

    The approach is unsupervised chunking followed by local authorization with a small model. Chunking first uses sentence and line boundaries, then splits where the cosine between adjacent words is below a fixed threshold γ, then merges from left to right according to the NLL of the next unit's first token relative to threshold τ. τ is calibrated using only benign tool outputs, with a target false boundary rate of α=15%, without attack samples. In the main experiments, both localization and authorization use Qwen2.5-7B-Instruct, zero-shot, temperature 0. The authorization input is the user task, the block, and the source, split into two questions: "is this an instruction to the assistant" and "are the content and source authorized"; a block is deleted unless it can be explicitly cleared. Appendix A.1 gives the full prompt.

    • Table 1: This 7B guardrail's Overall ASR against GPT-4.1-mini is 0.32%, UA is 74.60%, BU is 70.53% (no-defense ASR 30.79%, BU 73.68%); against Llama-3.3-70B-Instruct, Overall ASR is 0.00%, UA is 62.86%, BU is 43.16% (no-defense ASR 25.08%, BU 44.21%). The authors state the utility loss is negligible.
    • On both victim models, ASR for important instructions and tool knowledge is 0.00%. For GPT-4.1-mini, direct and ignore previous remain at 0.95%.
    • Table 4: ASR is 0.0% under Greedy search and 12.9% under Evolutionary; the latter is higher than AttriGuard's 9.7% in the same table.
    • The authors state it remains effective on smaller guardrail models of different families. The authors' conclusion is that once localization and decision are separated, strong IPI defense need not depend on a strong LLM. In the reproducibility statement, the authors plan to release reproduction code and configurations anonymously. The paper does not specifically discuss limitations.

Related papers

Show 3 more papers
Read originalarxiv.org