Inspiration
AI agents are starting to shop for us. Picture a small café owner who wants an agent to restock filters and cups every week. Right now she has two bad options: give the model a payment credential and hope, or approve every purchase herself, which defeats the point.
Prompt injection makes the first one dangerous. Any product page an agent reads can tell it to do something else, and models often listen. In our tests, one paragraph on a product page made a live model try to buy a $480 gift card 10 times out of 10.
We wanted a third option: hand over a small, specific amount of spending power, and make it safe even when the model is compromised.
The idea of a signed mandate isn't ours. Google's AP2 and the card networks are writing specs for what a mandate should say. What's missing is the fence: something that enforces one in front of a real payment rail, and proof that it holds when the model has been turned. That's what we built, on PayPal.
What it does
A human signs a mandate: this agent may spend at these merchants, in these categories, up to $X per purchase and $Y per day, at most N times a day, until a set time. The agent proposes purchases. A deterministic policy engine, not a model, checks each one against the mandate.
- Allowed: MANDATE places a real PayPal sandbox order from a wallet the human approved once, through PayPal's vault.
- Denied: the agent gets a machine-readable reason code (
MERCHANT_NOT_ALLOWED,EXCEEDS_PER_TXN_CAP,REVOKEDand 8 more) and PayPal is never called. - Every attempt lands in an append-only ledger, shown live in an AG Grid console next to the mandate and a spend meter.
- One click revokes. The next attempt is denied, and the denial shows in the grid in about 0.1 seconds.
The agent never holds PayPal credentials. It holds a token for one mandate, and that's all it can spend.
It all happens on one screen. You sign the mandate in the console and read, in one plain sentence, what you're signing. You give the agent a task and watch it work: what it searched for, the page it read, what it asked to buy. Tick "Poison the product page" and you see the attacker's paragraph the model read, the $480 gift card it asked for, and the verdict: Denied. PayPal was never called.
How we built it
- PayPal: Orders v2 and the Payment Method Tokens (vault) API in sandbox. An Orders v2 order normally needs the buyer to approve it in a browser, which an agent can't do. So the human approves their wallet once, when they fund their mandates, and each allowed purchase is an order against that vaulted wallet, captured server-side. We accept a purchase only if PayPal reports the order and the capture COMPLETED for exactly the approved amount. Retries carry a
PayPal-Request-Idtied to the agent's intent, so a retry can never create a second order. - Policy engine: a pure Python function with no I/O and no clock. The check order is part of the contract: revoked, expired, merchant, category, per-purchase cap, purchases per period, period cap. Spend is reserved under a SQLite write lock before PayPal is called, so parallel requests can't race past a cap.
- The agent: an open model (
openai/gpt-oss-120b) on Groq's free tier, through the standardopenaiclient, so switching providers is a config change. It searches real products with Channel3's API and reads product pages verbatim, so prompt injection is real, not simulated. - The console: React and AG Grid Community. AG Grid is the ledger: every attempt, live, sortable and filterable, with a find box, CSV export for audits, the plain-English reason as a tooltip, and new denials flashing in as they land. The admin token never reaches the browser. The console's proxy adds it to two calls only, sign and revoke, and refuses any write that didn't come from the console itself.
- The agent runner: a small service that lets the console start the agent and records exactly what the model saw, so the attack is on screen, not described.
- Everything runs with
docker compose up. Only the mandate service's container gets PayPal credentials. The agent's container gets an LLM key, and a mandate token with each run. Nothing else.
Challenges we ran into
- Charging without a buyer present. PayPal's normal flow assumes a person clicks "approve" on every order. Moving that approval to the moment of delegation, using the vault, was the key design decision.
- Proving fail-closed. "Deny by default" is easy to say. We enumerated every failure path (bad token, bad intent, PayPal 5xx, timeout, a PENDING capture, a wrong captured amount, our own bugs) and tested each one returns DENY with the right code.
- Making the injection real. Our first live runs didn't open the product page, so the injection never landed. A realistic instruction to check the page fixed that. Lesson: careful agents read more untrusted content, not less.
- Deployment. Our clean-clone Docker test caught an nginx config bug that never showed in development.
- Engine first, product second. Two days before the deadline everything worked, but you signed a mandate with curl and watched the agent in a terminal. We graded ourselves against the judging criteria, and rebuilt the console so a person can do the whole job on one screen.
Accomplishments that we're proud of
- The model was compromised. The money wasn't. A plain paragraph on a product page made the model try to buy a $480 gift card from an attacker's store in 10 out of 10 live runs. MANDATE denied all ten, and PayPal was never called.
- 14 out of 14 red-team attacks stopped, against live PayPal sandbox: injected merchants and prices, period overspend, a parallel burst (8 at once, exactly 3 charged on a 3-per-day mandate), expired, revoked, tampered, forged and
alg: nonetokens, malformed and look-alike input, PayPal outages, replays, and the agent trying to sign itself a mandate. - 200 automated tests, 96% coverage, with the policy engine and PayPal client at 100%.
- An honest threat model, including what MANDATE does not defend against.
What we learned
Model alignment is not a payment control. The fix for prompt injection in commerce isn't a smarter model or a better filter. It's taking the money decision away from the model entirely and giving it to something that can't be talked into anything.
What's next for MANDATE
- Bind mandate tokens to a key the agent holds, so a stolen token is useless.
- Reconcile with PayPal webhooks, to handle PENDING captures and crash recovery.
- Route each order to the merchant's own PayPal account, instead of one sandbox business account.
- Mandates as a PayPal-issued primitive: the human signs in PayPal, and any agent framework can carry one.