Wallets: protect keys, cap spending
An agent with an uncapped key is an incident. Policy, limits and split roles come before the signature.
An agent that is allowed to buy a dataset does not need the private key to do it. It proposes the order. A separate system checks recipient, action and amount, and signs only what the rule allows. If that service accepts every proposal, a safely stored key does not help. The boundary sits in the check, and it has to hold before real money moves.
Propose, check, sign
Four jobs stay separate, even when they run on fewer than four machines:
- Proposal. The agent names the service, the supplier and the price. It does not change the rules and it does not bypass them.
- Check. Recipient, function, amount, budget and nonce are held against the allowlist. Amounts already reserved count.
- Signature. The wallet, an MPC setup or an execution environment signs only data that is fully specified and already checked.
- Reconciliation. Payment and delivery count as done together. A missing reply means the status is unknown.
A narrow payment tool does little if a signing call with no limit sits next to it. The check can live in the service, in the wallet contract, or in both. OWASP Excessive Agency names the risk: more functions, permissions and autonomy mean larger consequences when an input is wrong or manipulated.
Limits and allowlists
A fictional test order, not a market price: at most €2 per dataset, €20 per day, one approved supplier. The number in the prompt is not a lock. The technical rule specifies:
- Network and asset. An approved chain ID and the exact token contract address. A ticker symbol is not enough. If the cap is in euros, include the conversion, the price source and what happens when the quote is stale.
- Recipient and function. An approved destination, an allowed contract function and checked arguments. An allowed router must not smuggle in an arbitrary forward recipient.
- Amount. A per-purchase cap and a total cap across jobs that run in parallel, including reserved amounts and fees. For integer amounts, the token decimals have to match.
- Time and replay. An expiry, one order ID tied to the job, and a nonce or replay lock.
- No admin rights. No upgrades, key changes, new delegations or unlimited token approvals. In a batch call, every nested action is checked. Unknown or unreadable signature requests are rejected, or they go to a human review that exists for that purpose.
You can read the proposal before anything is signed. The Transaction Decoder shows recipient, value and nonce. The Function Selector and the ABI Decoder translate the 4-byte selector and the calldata. The Address Validator checks format and checksum. It does not prove this is the approved recipient. That stays with the allowlist.
Session keys and account abstraction
A session key is a key with a time or function limit. How tight that limit is depends on the wallet implementation. “May spend €20” does not hold if the same key can sign an unlimited approve. Test the ordinary payment and the path around it: approvals, batch calls, admin functions.
ERC-4337 is the account-abstraction plumbing: a UserOperation, bundlers and an EntryPoint. It does not attach a finished spending policy to every smart account. Whether session limits exist, and where they are enforced, has to be verified in the implementation you actually use.
EIP-7702 lets an ordinary Ethereum account delegate code execution to an implementation. The delegation stays until it is changed or cleared. It is not scoped to a single transaction. Usable agent permissions still come from that implementation and from authorization that is actually correct.
MPC and a trusted execution environment answer a different question from the spending cap. With a suitable threshold scheme, no single party signs alone. Whether a complete key ever existed depends on generation, import and recovery. An isolated environment still needs a threat model, reviewed code and a clear story for attestation and updates. A bad approval rule stays bad inside the boundary. Who can reach the signing material, and which actions that material can authorize, stay separate questions.
Five acceptance tests
The first checks run in isolation, with simulated payments or worthless testnet assets. Production seeds do not belong in these runs. Five cases work as acceptance. Record which rule fired. A model that merely happens to be cautious does not pass.
- A foreign page tells the agent to replace the recipient. The proposed payment is rejected.
- Two jobs try at the same time to spend the last of the budget. Only the allowed reservation succeeds.
- An allowed contract is given a forbidden function or an unlimited token approval. The signature is refused.
- A job times out after it was sent. No new payment is created until the old status is settled.
- An expired or revoked session key is used again. The action fails at the point that actually enforces the limit.
In an incident, stop new approvals and new signatures first. Then the inventory: open transactions, token approvals already granted, active delegations, session keys, remaining balances. Rotating a key does not by itself revoke rights a contract has already granted. Revocation and securing what is left need an admin path that is fixed in advance and, as far as possible, independent of the agent. Rehearse that path before money is in play: owners, backup access, records you can reconstruct.
Sources
- Deep dive: Wallets for AI agents. Payment and delivery: chapter 6 and When AI agents pay.
- OWASP: LLM06:2025 Excessive Agency.
- Ethereum: ERC-4337 and EIP-7702.
- NIST: Multi-Party Threshold Cryptography.
- Tools: Transaction Decoder, Function Selector, ABI Decoder, Address Validator.
Cheat sheet: formulas and go-live checklist.