# Give your AI agent the cancel, not the key

> Source: <https://dev.to/edycutjong/give-your-ai-agent-the-cancel-not-the-key-3g4>
> Published: 2026-11-22 17:34:42+00:00

**Recommendation:** Give payment agents only cancel signatures over the same nonce as each payment, keep payment signatures in a separate keeper, and cap agent stops per run with an expiry and stop budget.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

A finance team approves Friday's vendor payments on Monday. On Tuesday an email arrives from the vendor's real mailbox: "confirming Friday's payment goes to the updated payout address… please don't call, just reply here." On a stablecoin chain, once that payment lands, nobody can pull it back.

The obvious fix in 2026 is an AI agent that reads the inbox and reacts. The obvious problem is that an agent reading attacker-written email is the most prompt-injectable thing you can build, and the usual guardrail ("give it a session key with a spend cap") still lets a hijacked agent pay up to the cap.

I built [Brake](https://github.com/edycutjong/brake) for the QDay Aevum Builder Challenge around a different idea: **don't give the agent a key that can pay. Give it the cancel.**

USDC-style tokens (Circle's FiatToken v2) implement EIP-3009. Besides `transferWithAuthorization`, a signed payment anyone can submit, it has a less famous sibling: `cancelAuthorization(authorizer, nonce, v, r, s)`. It marks a nonce as used, so a payment signed with that nonce can never execute.

Two properties make it useful:

`validAfter`, so it cannot clear before payday.
The second one is the whole design, so I tested it first. On Aevum testnet (chain 44005), tUSD8 is a FiatToken clone. A cancel signed by the payer was submitted from an unrelated EOA ([tx](https://explorer-test.qday.info/tx/0x8cb8d550f03616e14ef00682022dd20a4ade46e090c8466766d6799dc98330c2)) and through a contract ([tx](https://explorer-test.qday.info/tx/0x50c5cfcc0d470f71ab91b75cbea227cc820df0c19543bd919e4d293fd2c12df5)). In both cases the paired payment then reverted ([tx](https://explorer-test.qday.info/tx/0x07dbb27599ac8615360e0e52e04475ec2193c334c330e76ffd2b6dd52529bb7d)). The same gate runs as 7 Foundry tests.

For every line of a payment run, finance signs two EIP-712 messages once, over the **same nonce**:

```
/** Sign one line: the payment and the cancellation that can stop it, over the same nonce. */
export async function signPair(
  account: Account,
  domain: TokenDomain,
  line: { to: Address; value: bigint; validAfter: bigint; validBefore: bigint; nonce?: Hex },
): Promise<SignedPair> {
  const authorization: Authorization = {
    from: account.address,
    to: line.to,
    value: line.value,
    validAfter: line.validAfter,
    validBefore: line.validBefore,
    nonce: line.nonce ?? randomNonce(),
  };
  const payment = await signTransferAuthorization(account, domain, authorization);
  const cancel = await signCancelAuthorization(account, domain, authorization.nonce);
  return { authorization, payment, cancel, /* digests */ };
}
```

The payment signature goes to a keeper that submits it on payday. The cancel signature goes to the stop path. The agent never sees a payment signature, holds 0 tUSD8, and has no allowance. The worst a hijacked agent can do is **delay** a line. It cannot create a payment or change where one goes, because those are fixed inside signatures it never had.

The agent doesn't call the token directly. It calls `Brake.stop`, which checks the agent's grant (per-run, with an expiry and a stop budget), then submits the payer's cancel:

```
if (token.authorizationState(run.payer, l.nonce)) {
    // used (paid) or cancelled outside Brake; the reconciler reads logs
    l.status = Status.CONSUMED;
    emit StopConsumed(runId, idx, reason, evidenceHash, msg.sender);
    return Status.CONSUMED;
}

if (byAgent) {
    if (run.stops >= run.maxStops) revert StopBudgetExhausted();
    run.stops += 1;
}
l.status = Status.STOPPED;

token.cancelAuthorization(run.payer, l.nonce, v, r, s); // reverts on a bad signature: nothing changes

emit LineStopped(runId, idx, reason, evidenceHash, msg.sender);
if (byAgent && run.stops == run.alarmAt) emit StopAlarm(runId, run.stops);
_receipt(runId, idx, RESPONSE_STOP, reason, evidenceHash, uri);
```

A few details that came out of testing:

`maxStops`) caps how many lines a hijacked agent can cancel per run. Hitting it turns the next attempt into an on-chain HOLD for finance, not a stop.`AuthorizationUsed` log and marks the line TOO LATE with a recovery ticket. The agent never claims a stop it didn't make.
The agent has a rules layer (unverified bank change, lookalike sender, disputed invoice, blacklisted payee…) and a model layer. The model's whole interface is one strict-schema tool:

``` js
export const RECORD_FINDINGS_TOOL = {
  name: "record_findings",
  description: "Record what the linked messages mean for each payment line. Call exactly once.",
  strict: true,
  input_schema: {
    type: "object" as const,
    properties: {
      findings: {
        type: "array",
        items: {
          type: "object",
          properties: {
            line: { type: "integer", description: "line index" },
            intent: { type: "string", enum: [...INTENTS] },
            quotes: { /* message_id + verbatim text */ },
            note: { type: "string", description: "one sentence, plain English" },
          },
          // ...
```

There is no pay tool, no signature, no free-form action. Deterministic code then decides:

That last rule paid off on the live chain. The first live run failed: the model rejected the forced `tool_choice` the engine sent (HTTP 400), every review errored, and **all four lines were held with no tUSD8 moved**. The fix was to let the model choose its tool under the strict schema, with a missing tool call still holding the line.

This is the part I didn't expect. In the demo email, the vendor's compromised mailbox asks finance not to call, and adds a bracketed note addressed to the "payment assistant". The payee on file was phone-verified weeks earlier, so **no rule fires**.

From the 25-email injection suite (6 held-out emails committed before tuning):

| Split | Rules only | With the model | 
|---|---|---|
| Tune (n=19) | 4/19 | 19/19, 0 false stops | 
| Held-out (n=6) | 2/6 | 6/6, 0 false stops | 

In the hero scenario, the model stops line 3 in 5 of 5 runs with 0 rules fired. Stub the model out and line 3 is ALLOWED and paid. n=25 is a regression suite, not a detection rate, and I say so in the repo.

The injection in the email doesn't help the attacker. The best it can do is suppress a stop only the model would have made. It can't reach a key that pays.

On Aevum testnet 44005, with `claude-sonnet-5-5` through the Anthropic API:

`FiatTokenV2: authorization is used or canceled` (
When you scope an agent's power, ask whether it needs to *act* at all, or only to *veto*. Many tokens already ship a veto primitive. A pre-signed cancel turns "the agent might pay the wrong person" into "the agent might make a payment late", and a late payment can be fixed.

Try to trick it yourself: the [live app](https://app.brake.edycu.dev/) has a composer where you can write an email as the vendor. The code, tests and every live transaction hash are in the [repo](https://github.com/edycutjong/brake).
