Proving prompt injection defences: fence tools at the first untrusted read
A proof framework judges agent defences against a model that never obeys injected text. What it proves, what it refutes, and six rules for tool policies.
Most evidence about prompt injection defences comes from benchmarks: run known attacks, count how many succeed. That can show a defence is weak, but it can never show it is strong; the paper cites work in which adaptive attacks bypassed twelve recent defences, most of which had reported near-zero attack success. A paper submitted on 8 November 2026 takes the other route. It defines what it means for an agent to be secure against injection, proves which defences meet that definition against a worst-case model, and refutes the ones that don't. The headline result is easy to state and easy to apply: revoke the tools an injection could use at the first untrusted read, and don't grant them back.
The definition: secure relative to an agent that never obeys
The paper, On the Relative Security of Prompt Injection by Brijesh Dongol of the University of Surrey, starts from a practical problem. Classic information-flow security would forbid an agent from revealing anything about the user's data to an outsider. But a useful agent does that by design: a calendar assistant that replies to meeting requests with your availability is disclosing data to whoever asks.
So the framework, called PlanTERS, compares each agent with a reference agent: the same plan, under the same runtime monitor, with a model that never obeys untrusted content. An agent is relatively secure if every leak it has is a leak the reference already has. The task's own behaviour becomes the policy. If the injected instruction "send your calendar" only reveals what a genuine meeting request would reveal, that is not a new leak. If an injection gets the agent to add a password reset code the plan never sends, it is.
The model is treated as an adversary. The attacker chooses which content the model treats as an instruction and when it obeys. Results are proved in the Isabelle/HOL proof assistant, about 31,600 lines over 89 theories, covering 25 small example agents.
The fence theorem
The central result is about a fence: a runtime monitor, sitting between the agent and its tools, that revokes tools once untrusted content has been read. The theorem says that if the monitor revokes every tool an injection can call at the first untrusted read, and no trusted input grants them back, then every plan is relatively secure, under the paper's model of injection, which is one injected call at a time on a schedule fixed in advance.
The full paper works through small examples that make the placement point concrete. A fence after the agent has read an untrusted email and then a secret leaves a window in which an injected send can carry the secret. A fence after the email but before the secret still leaks what was already in memory. Only a fence before the first untrusted read leaves no window.
A fence has a cost, which the paper is careful to state. A task that must send a reply after reading an email loses that ability if the send tool is fenced. Relative security doesn't notice, because the reference loses it too, and a monitor that denies everything is trivially secure. Whether the task still works has to be checked separately.
What is refuted
The refutations are as useful as the proofs:
- Spotlighting, marking untrusted text and asking the model not to obey it, leaks for every marking under a worst-case model. It helps only if you assume the model honours the marking, which the proof cannot establish.
- Approving a tool is a budget of one that an injection can spend first. An injected send that happens after the user approves a reply, but before the plan sends it, goes out with the approval, and the real reply is then denied.
- Re-granting tools in the same context leaks. A loop that grants the send tool back for the next request, while the previous email is still in the model's context, gives the old injection a second chance.
- Budgets spent after untrusted content arrives can be consumed by the injection.
Approving the exact call, rather than the tool, is secure for messages at the level of what the attacker receives, but not if the attacker can also observe timing, because whether the injected copy went out early reveals whether it matched.
Six rules for tool policies
The paper distils its verdicts into six rules for designing a monitor, each holding under the assumptions of its theorem:
- Fence at the first untrusted read.
- Govern reads as well as calls.
- Approve exact calls rather than tools.
- Spend budgets before untrusted content arrives.
- Re-grant tools only with a fresh model session.
- Keep refusals from revealing arguments.
What it does not cover
The scope is narrow on purpose, and leaders should read it before citing the result. The framework covers plan-then-execute agents, where a trusted planner fixes the tool calls before any untrusted content is read. Agents whose model chooses every call, which describes most coding agents today, are explicitly out of scope because there is no fixed plan to compare against. It covers leaks, not hijacking that does damage without disclosing anything, and not tool poisoning or multi-agent systems. It assumes every tool call and every untrusted read pass through the monitor, which fails if an agent has an unmediated browser or shell.
So the fence theorem is not a proof that your coding agent is safe. It is a proof about a design pattern, and it tells you which parts of that pattern are load-bearing.
What it means for engineering and security leaders
The practical value is a vocabulary for reviewing tool policies. For any agent that reads outside content, ask three questions. Which tools can send data out, and are they still available after the first untrusted read? Are approvals scoped to a tool or to a specific call with specific arguments? When does the agent get a fresh context? Where the answers are "yes, still available", "tool", and "never", the paper gives a concrete attack for each.
It also argues for keeping these decisions in a monitor outside the model. Every secure verdict in the paper comes from something the monitor enforces, and every heuristic that depends on the model's cooperation fails under the worst-case model. It fits with our earlier pieces on what a low prompt-injection success rate doesn't tell you and what an agent approval actually approves.
Where SpanDock fits
For MCP tools, the SpanDock MCP gateway is a monitor of this kind for the organisation's connectors. A tool that needs approval doesn't run; an administrator sees who asked, which tool and the arguments with secrets removed, and Approve once lets exactly that call through, once, within 24 hours. Every connector starts read-only for everyone, and read-only access hides write tools completely. The MCP gateway is on the Premium and Enterprise plans.
Practical takeaways
- Map send-capable tools for each agent: email, chat, web fetch with arbitrary URLs, issue creation, write access to shared systems.
- Revoke or require approval for them after untrusted reads, rather than relying on instructions to the model.
- Prefer approvals bound to exact arguments over approvals for a whole tool.
- Start a fresh session per untrusted item in loops that process inboxes, tickets or pull requests.
- Don't treat spotlighting or delimiters as a control. They may reduce attack rates; they don't bound them.
- Check refusals don't echo arguments back to a place an outsider can read, such as a public log or an issue comment.