Skip to content
QORECHAIN
Register

Post-Quantum AI Agents

Invoice Leash

An invoice-paying AI agent that stays safe when its model does not — every limit lives on QoreChain.

Share on X

About

Invoice Leash is an AI agent that reads a mailbox and pays vendor invoices for its owner. It is built on one assumption: sooner or later the model will be fooled, by a prompt injection, a forged invoice or a stolen key. So the agent's own code has no safety checks at all. Every limit lives on QoreChain: - Call scope: the agent's key may call InvoiceDesk.pay and nothing else. This is a selector-level allowed_evm_calls rule, not a whole-contract allowlist. - Value limits: 1 QOR per payment, 2.5 QOR per day and an expiry, enforced by account abstraction on the owner's own account. There is no vault: the money never leaves the owner's account, so there is no vault balance to drain. - Authenticated invoices: every invoice must carry an ML-DSA-87 signature from an approved vendor whose key is registered and proven on chain. InvoiceDesk checks it with the PQC precompiles 0x…0a02 (key status) and 0x…0a01 (verify). - Revocation: one owner transaction switches the agent off. Anything over the limits goes to a human, who pays it directly after a dry run of the same contract checks. To test it, we made the decider fully compromised: it obeys every instruction in a 10-email inbox, the attacker's included. The attacks cover prompt injection, fake vendor registration, forged signatures, an edited amount, replay, and oversized and over-budget invoices. On qorechain-diana it made 11 attempts. 3 genuine invoices were paid (2.2 QOR), 8 attempts were refused by the chain, and 0 QOR reached the attacker. After a revoke, the chain rejects the agent's key outright. With Claude as the decider, the model still paid a forged invoice and an over-budget one, and the chain refused both. A minute earlier, the same model had skipped the same forgery. Model decisions vary from run to run; the chain's do not. Any agent can hold the leash. An MCP server exposes it as tools holding only the agent's key, with dangerous tools (send, approveVendor) included on purpose. Claude Code used it to pay exactly the 3 genuine invoices after dry-running all ten. An obey-everything MCP client then tried 11 actions, and the chain refused all 11. Judges: `npm install && npm run verify` checks all of this against the live testnet in about a minute: 37 checks, no keys, no test QOR. CI re-runs it daily. Every email and transaction: https://eltociear.github.io/invoice-leash/ Try to break it in your browser (tamper with a real ML-DSA-87 invoice and ask the real contract): https://eltociear.github.io/invoice-leash/lab.html

How it's made

Architecture - owner (human): holds the funds, approves vendors, links the agent's ed25519 key with linkAuthenticatorMsgs, and writes a spendingRule (perTxLimit, dailyLimit, allowedDenoms, allowedEvmCalls = ["<InvoiceDesk>/0x38e5ab6a"]). - agent: a decider (a compromised "obey everything" mode, or Claude) plus an executor that has no checks. It builds MsgExecuteEVM with buildPhantomExecuteEvm. A separate gas wallet relays it, so the agent never holds the money. - InvoiceDesk.sol (0x0027431D3314e672927eBfd9de57b1003198413b): keeps approved vendors and paid invoices per payer. pay() checks UnknownVendor → BadSignature (pqcKeyStatus: registered + possession proven + ML-DSA-87, then pqcVerify over a domain-separated message that binds chain id, desk, payer, vendor, amount, id and due date) → AlreadyPaid → PastDue → WrongAmount, then transfers. - Vendors sign invoices off-chain with ML-DSA-87 (pubkey 2592 B, signature 4627 B). All accounts send hybrid secp256k1 + ML-DSA-87 transactions; PQC keys are registered with proof of possession. Kits and network features @qorechain/sdk 0.14 (hybrid signing, PQC key registration, account abstraction authenticators and spending rules, phantom EVM execution, auth nonce / digest version, EVM windows), the PQC precompiles 0x0a01 and 0x0a02, and the EVM (chain 9800, solc 0.8.30). Built on the build-before-qday workshop-2 example (Apache-2.0). What was hard - The agent acts AS the owner, so inside the contract msg.sender is the owner, and onlyOwner can't tell them apart. Allowlisting the whole contract would let an injected agent call approveVendor(attacker). The scope therefore has to be a function selector. - The gasLimit inside a signed MsgExecuteEVM must fit within the gas the relaying transaction provisions (a 1.0M relay gives about 762k for the call). At 800k, every call was refused; 650k works. pqcVerify alone costs about 312k. - Refused executions still land as code 0 (abstractaccount_execution_failed) and use up the nonce, so results are read with decodeAuthenticatorExecutions. They don't count toward the daily limit. - Ordering matters. In our first run, the daily limit caught the edited and replayed invoices before the contract could, so we raised it to 2.5 QOR to show every layer. The signature check runs before the replay check on purpose. - Daily spend and paid invoices persist per payer, so each clean re-run rotates in a fresh owner account. Verification and limits - npm run verify (read-only): deployed bytecode == source; sign-bytes parity with invoiceMessage(); vendor keys via pqcKeyStatus; the agent's stored rule; every attack replayed with eth_call against the real contract (the PQC precompile runs in eth_call), plus six tamperings the demo never sent; where every QOR went; every recorded tx re-read. Phantom EVM executions don't appear in eth_getLogs, so it reads the desk's paid() state instead. - Over-limit invoices escalate to a human: `approve <email>` dry-runs pay, then the owner pays through a capped EVM window (done for the 5 QOR invoice). - THREAT_MODEL.md: QoreChain links only ed25519/secp256k1 agent keys, so Invoice Leash treats the agent key as already stolen; changing the leash (rules, vendors, invoices) stays behind ML-DSA-87.

Timeline

Invoice LeashPost-Quantum AI Agents

Newly verified on chain: MCP server or qore CLI, QoreScan, Test tokens fUSD, fETH, fBTC

Invoice LeashPost-Quantum AI Agents

Pushed 12 commits to main

  • e95b275 Pages: v2 (fUSD) first: inbox replay, the probe finding, a v2 attack lab (send as agent/company/stranger); v1 lab kept as lab-v1.html · eltociear
  • 53311ad v2 live on diana: fUSD invoices, the agent's own empty account; README/THREAT_MODEL rewritten · eltociear
  • e2fff07 v2 redesign: the agent gets its own empty account; limits move into InvoiceDeskV2 · eltociear
  • c2a19e3 v2 (not deployed yet): InvoiceDeskV2 pays fUSD (ERC-20) or QOR, currency signed · eltociear
  • 677dedb Foundry tests with real ML-DSA-87 fixtures, QoreScan CBOM, MCP audit via @qorechain/mcp · eltociear

and 7 more commits

Invoice LeashPost-Quantum AI Agents

Pushed 7 commits to main

  • e4cd041 Rename to Invoice Leash (two other QoreChain entries are already called Leash) · eltociear
  • 38a2fb6 README: add the Built on QoreChain badge · eltociear
  • f8ac59e README: link the narrated demo video · eltociear
  • db053f5 README: link the demo video · eltociear
  • 0aae0a7 Add the cover image · eltociear

and 2 more commits

Comments and questions

  • No comments yet.