If you give a model your mailbox, an email can try to tell it what to do. This post is about
Cordon, a small research prototype of one defense, and about
an evaluation whose honest headline is that on real model runs I could not show the defense helped. I
built it as one person directing AI coding agents, with tests and a review by a separate AI agent as the checks.
The problem
An agent that reads mail and writes mail can be steered by the mail it reads. "Forward the invoice to
this address" inside a message is text the model may treat as an instruction. Cordon asks whether you
can structure the agent so that untrusted text cannot decide what it does. It is not novel: the README
credits AgentDojo, Google DeepMind's CaMeL and the Dual LLM pattern, and calls Cordon a small, readable
implementation of the same family of ideas.
What it does
Four parts, in this order:
- A planner model sees only your request and the tool schemas, and emits a typed plan. It never sees tool output, so control flow is fixed before any email is read.
- An executor runs the plan. Every value from a read tool is wrapped as
Tainted[T]with its source, trust level and sensitivity. - A quarantined model with no tools turns untrusted text into schema-constrained values. Those stay tainted.
- A policy engine (plain Python, no model) checks every side-effecting call against argument provenance. Rules P1 to P6 cover recipients, private data, destructive actions, calendar fields, budgets, and untrusted content in an email body.
The design decision I want to point at is the fixed one-shot plan. It is what makes the defense
structural: the attacker's goal rarely appears in a plan made from your request alone. The trade-off is
utility. A fixed plan cannot retry a query or ask a clarifying question when a result is not what it
assumed. Benign task success fell from 14/16 for the undefended baselines to 9/16 for Cordon, with wide
intervals (README, "Reading the results honestly").
How it is tested
The offline suite needs no API key and no network. On a fresh clone, 378 tests pass (one is
deselected), and ruff, mypy and the corpus-integrity checks pass.
uv sync uv run pytest # offline: mock environment, policy engine, executor, harness make worst-case # reproduces the worst-case table without any model call make check # lint, format, types, tests, corpus integrity, worst-case table The corpus is 80 scenarios (16 benign, 64 attacks, in English, Turkish and German) with deterministic
success predicates, so no model judges the outcome. A 15-scenario holdout corpus and two small
follow-up sets were added later; the follow-up predictions were written down and tagged before any
real run (docs/preregistration-v0.2.1.md).
What the numbers do not show
This is the part that matters most, and the README says it first.
- Real runs showed no before/after improvement. The undefended baseline was fooled by 2 of 64 attacks on the main corpus and 0 of 15 on the holdout. With Claude Haiku 4.5 there was almost nothing for the policy engine to catch. Most measured protection comes from planner isolation.
- The policy engine's evidence is a worst-case analysis, where you assume the model was completely fooled. Then P1 to P5 block 22 of 37 write-tier attacks and P1 to P6 block 33 of 37. That shows the mechanism does what it was written to do. It is not a test against an adaptive attacker.
- The author of the attacks wrote the policy's specification. The holdout corpus came from a separate chat session, but that session wrote P6's spec and knew the known gaps. Only the implementer was kept from seeing the attacks. A jump from 2/6 to 6/6 on the targeted group reads as "matches its own specification", not generalization.
- P6's real cost is not established. In a 10-task follow-up only one new confirmation prompt appeared, but five of the ten tasks never reached a write step because of small-model failures.
- A known gap stays open: content planted by a compromised contact account and sent on to an allowlisted recipient is not gated. Measured worst case: 3 of 4 scenarios get through.
Everything is small and self-authored: one run per system, one model family, one mock environment.
What the security audit found
A code security audit before publication found no code vulnerability. That is a weak statement worth
reading narrowly: Cordon only runs against an in-memory mock mailbox and calendar on *.example
domains, so it has no real credentials, network mail access or user data to attack. The cleanup that did
matter was in the git history: I removed local file paths and a personal email address from old
commits before opening the repository.
Limits and what is not done
- No real Gmail or Calendar mode (OAuth, read-only plus draft scopes is the plan).
- No AgentDojo adapter, no model other than Haiku 4.5, one run per baseline.
- No independent red team. The attack corpus, including attacks aimed at the policy engine, came from the same model family that wrote the policy.
- Auto-deny and auto-approve are the two extremes of human behavior. Neither models confirmation fatigue.
- P1 trusts recipients the planner wrote literally, so a planner that invents an address outside the allowlist sends without a prompt. Not an injection vector, since the planner never sees untrusted text, but a wrong-recipient risk.
This is a research prototype, not production security software, and it does not solve prompt
injection. If you reproduce the tables and get different numbers, open an issue.
Code: https://github.com/basartuncay/Cordon
Originally published at https://basartuncay.github.io/notes/cordon-results/.
This article was written with AI assistance. I directed the work, and the numbers and findings in it were checked against the repository before publishing.