
SpanGuard: Decoupling Instruction Localization from Authorization for Lightweight IPI Defense
SpanGuard is an indirect prompt injection (IPI) guardrail that splits detection into two steps. Lightweight unsupervised segmentation first locates candidate instruction blocks in tool outputs, then a small LLM judges whether each block is authorized by the user's request. The authors report a 0.32% attack success rate with negligible benign utility loss, and the guardrail still works with substantially smaller models.
What it is
SpanGuard is an external, black-box guardrail against indirect prompt injection (IPI), from Yinxiang Wang and colleagues at USTC (arXiv 2610.26013v1, October 2026, ICLR 2027 paper). It intercepts each tool output before the agent sees it, removes blocks judged to contain unauthorized instructions, and passes on the rest. It needs only the user's instruction and the tool output, not access to the agent's weights or reasoning.
How it works
The paper's claim is that small models fail as guardrails because they must find the injected text and judge its authorization in one pass. SpanGuard splits these.
Localization (no judge LLM, no attack data).
- The input is split at sentence and line boundaries. Adjacent words are also split where the cosine similarity of their mean-pooled contextual embeddings falls below a fixed threshold γ.
- Units are merged greedily left to right. The boundary score is the negative log-likelihood of the next unit's first token given the current block. If the score is below τ the unit joins the block, otherwise it starts a new block.
- τ is calibrated only on benign tool outputs. A search finds the τ whose false-boundary rate on benign data is close to a target α.
Authorization (small LLM, per block). Each block is judged on its own, with the user task and the block's provenance (the tool call and field it came from). The prompt asks two questions in order: does the block contain a directive to the assistant, and are that directive's content and source authorized by the user's task? The output is 0 or 1, and blocks marked 1 are removed.
Results (AgentDojo)
The headline run uses gpt-4.1-mini as the victim and a 7B guardrail model. The page does not say which 7B model.
| Defense (gpt-4.1-mini) | Overall utility under attack | Overall ASR |
|---|---|---|
| No defense | 73.81% | 30.79% |
| SpanGuard | 74.60% | 0.32% |
| MELON | 53.49% | 0.63% |
| PromptArmor | 83.97% | 2.54% |
| CausalArmor | 83.02% | 3.33% |
| AttriGuard | 71.90% | 2.86% |
| Tool filter | 77.30% | 5.87% |
- Benign utility with no attack is 70.53% for SpanGuard against 73.68% with no defense, a drop of about 3 points. PromptArmor scores 66.32% and CausalArmor 72.63% on the same measure.
- The attacks tested are direct, ignore-previous, system-message, InjecAgent, important-instructions and tool-knowledge. SpanGuard has 0.00% ASR on four of them. The other two are direct and ignore-previous, at 0.95% each.
- Several baselines look strong on ASR only by wrecking utility. PIGuard and Llama Guard 3 drop utility under attack to 28.10% and 30.63%.
Caveats
- The fetched text cuts off in the llama-3.3-70b rows, so the claim that smaller guardrail models still work has no numbers here. Check the full paper for the model sweep.
- The reported 0.32% is from one benchmark and one victim model in the visible table. The page shows no tests against attacks written to evade the segmentation.
- The method assumes injected text is semantically discontinuous from its surroundings. The paper describes this as typical ("often"), not guaranteed.
- The values of γ and α, and the segmentation model, are not given in the fetched text.
Technologies named here
- LLM-based guardrails for indirect prompt injection defense
- LLM
Techniques named here
- Decoupling localization from authorization
- Lightweight unsupervised segmentation
- Indirect prompt injection
- Prompt Injection
Related in AI Security
