Attenuable capability tokens for AI agents that act on a person's authority.
An agent should carry exactly the authority its task needs: this account, up to this amount, until this time, and it may (or may not) hand a narrower slice to a sub-agent. Today most agents carry a shared service account or a long-lived API key instead. Warrant is a small, dependency-free reference implementation of the alternative.
marketing-director -> planner-agent -> bidder-agent
spend <= 500/call (same limits) acct:google:123 only, <= 200/call, may not delegate further
total <= 2,000 revoking the planner also revokes the bidder
- Tokens are macaroon-style HMAC chains (Birgisson et al., NDSS 2014). Anyone holding a token can append a caveat to narrow it, without a key. Nobody can remove, edit or reorder a caveat: the verifier recomputes the chain from the issuer's root key.
- Caveats:
action,resource(with*prefixes),spend_per_call,spend_total,expires,may_delegate,max_depth, plusprincipalanddelegateto record whose authority it is and who holds it now. Unknown caveats fail closed. - Verification is offline apart from two pieces of state: a revocation list and a cumulative-spend ledger.
- Revocation covers descendants. Every prefix of a chain has a link id; revoking a token revokes everything derived from it and nothing else.
- Audit: every decision returns the delegation chain, so a log can say whose authority was exercised.
python3 examples/demo.py
python3 -m unittest discover -s tests
python3 eval/run_eval.py
Python 3.9+, standard library only.
eval/results.md, seeded and deterministic:
| Measure | Result |
|---|---|
| Legitimate requests allowed | 5 of 5 |
| Attacks denied, each for the expected reason | 16 of 16 (15 attack classes: tampering, looser caveats, reordering, use after revocation, delegating when closed, depth, per-call and cumulative spend, wrong resource or action, expiry, stolen and forged tokens, unknown issuer, principal swap) |
| Narrowing property: a narrowed token never allows what its parent denies | 0 violations over 10,000 random chains |
| Tampered tokens rejected on signature | 10,000 of 10,000 |
| Revocation hits exactly the revoked subtree | 2,000 of 2,000 random delegation trees |
Writing the eval caught two mistakes of mine, both in the tests rather than the library: a test that issued two separate grants and expected them to share a budget, and an attack case that was denied for the wrong reason (it broke the per-call cap, not the cumulative one). Every denial in the suite is now checked for the expected reason.
- Not audited. The construction is the published one; this code has had no security review.
- The spend ledger lives in one verifier's memory. Several verifiers need a shared ledger, and a crash loses the count.
- A narrower
spend_totalon a child counts spending by the whole grant, so it is stricter than intended. - Times are ISO strings compared as text, so every party must use UTC in the same format.
- There is no revocation distribution, no key rotation, no third-party caveats (the macaroon feature for "ask another service").
- Biscuit (Datalog policies, public-key signatures) is the more capable design for production. This is a reference for the delegation vocabulary, not a replacement.
Independent project, synthetic scenarios only. The brief's riskiest assumption, whether security leaders would take an agent-delegation spec seriously from an outsider, is untested.
MIT licence.