ERC-8481: Agent Pre-Sign Risk Report

AI agents now prepare and sign transactions with no person reading each one. the losses that follow are mostly not exotic, and each is visible before signing to anyone who reads the chain and the request:

· an unlimited approval to a spender that is a plain wallet or a week-old contract
· a transfer to an address that shares its first and last characters with one the signer used before
· a buy of a copy of a real token (on robinhood chain there are 3,148 copies of robinhood’s own stock tokens) or through a pool priced far from its oracle
· an x402 payment to a payTo that is not the paid agent’s registered wallet
· an instruction hidden in a token’s name that the agent reads as a command

the Prepared Transaction Envelope proposal (ERC-8265 thread) already gives the consumer a risk slot: an action (ALLOW / WARN / BLOCK), an optional score, free-form warnings and scanner verdicts. what it doesn’t define is what a risk source says, so a consumer that gets WARN can’t see what was read, can’t apply its own thresholds, and can’t tell “found nothing” from “couldn’t read it”.

the draft

a report a risk source returns about one prepared, unsigned request:

· binds to the exact request by a digest (for an envelope: the same pre-image its coverage uses, so writing the report into risk doesn’t move it)
· names its source by an ERC-8004 identity and is EIP-712 signed; the consumer rechecks the signer is that identity’s agentWallet or owner
· carries typed findings in five groups:
· tokens: launch facts read from a Launch Observations registry; a token that copies an issuer’s listed token; a pool’s deviation from a price feed
· approvals: amount, unlimited, share of supply, expiry, current allowance
· addresses: code (none / contract / 7702-delegated), first seen, verified source, prior transfers, lookalikes
· payments: x402 payTo against the payee’s registered agentWallet, with the outcomes of x402 Payee Verification (ERC-8478)
· texts: control characters, mixed scripts, addresses and instruction patterns in text the agent read
· every finding states the block it holds at and its evidence, and is read or not read. not read is never zero or false
· no score, no verdict, no recommended action: the consumer applies its own policy, and MAY project findings into the envelope’s warnings

it runs today

toll (ERC-8004 agent #20030) runs this as a live pre-sign check on robinhood chain: send a prepared tx, an EIP-712 request or an x402 requirement and get ALLOW / WARN / BLOCK with typed reasons, free over HTTP and MCP. a one-line client (@tollxyz/guard) puts it in front of a viem or ethers wallet. examples it blocks today: an unlimited approval to a plain wallet, a copy of an official stock token, an x402 payTo that is not the seller’s wallet.

it’s the third piece of one stack: Launch Observations (ERC-8470, what happened at a coin’s launch, on chain), x402 Payee Verification (ERC-8478, is this payee the agent you mean to pay), and this one, the format a wallet or agent reads before it signs.

questions for this thread

  1. reports as a member of the envelope’s risk slot, or a separate consumer-written field?
  2. is a fixed list of finding kinds right for v1, or should kinds be open from the start (namespaced, like Launch Observations)?
  3. should a signed report be anchorable on chain (a hash in a registry), or is off-chain EIP-712 enough?
1 Like

PR: Add ERC: Agent Pre-Sign Risk Report by soli0x · Pull Request #2134 · ethereum/ERCs · GitHub

1 Like

On the addresses group: you already list code, first seen and verified source. For a 7702-delegated address I would add what the delegate lets whom do, because “7702-delegated” reads the same for a delegate with limits and for one without. A concrete case from 29 October (UTC) on Ethereum, all public data: the delegate at 0x63e842b054bd624a465454d533c33f573e9c6fae. I simulated calls (eth_call) against the deployed code: its four value-moving functions (sweep, withdrawETH, withdrawToken, callExecute) revert with NotAuthorized for any caller except one hard-coded address, and that address can withdraw a whole balance to any recipient in one call: no limit, allowlist, delay or pause. The type-4 transaction 0xad99264d5532ae0dd04b2004eebda05f25657e70dacb764f7ac8d4ccd051298b (block 26300753) carried 50 authorizations for this delegate with consecutive nonces, and its sender was that same hard-coded address.

Findings a report could carry for a delegated address, each at the block it holds at:

  1. whether any value-moving function is gated by a single constant or storage address
  2. whether value can leave to any recipient without a per-call limit or delay
  3. how many authorizations for that delegate were seen in recent blocks from the same signer, and whether the transaction sender is the delegate’s only allowed caller

Items 1 and 2 need verified source or bytecode analysis, so they should be allowed to be “not read” with a reason instead of false, which is what your rule that not read is never zero or false asks for.

On your second question, I would open the kinds from the start, namespaced: delegate patterns will change faster than a fixed list.

agreed, “delegated” alone hides the part that matters. added three kinds to the addresses group, each for a delegated address only and at the report’s block:
· delegate-single-caller: every value-moving function is callable by one fixed address (constant or one storage slot) and nobody else
· delegate-unbounded-outflow: the whole balance can go to a caller-chosen recipient in one call, no per-call limit, allowlist or delay
· delegate-authorizations { blocks }: 7702 authorizations for the same delegate seen in the last N blocks, how many came from one sender, and whether that sender is the delegate’s only allowed caller the first two need source or bytecode analysis, so the draft says a source that didn’t finish it reports not read, never false. our implementation lists all three as not read for now.
on kinds: they’re already open. erc.presign. is reserved for ERC-defined kinds, anyone can report others under a prefix they control, and a consumer treats an unknown kind as informational. so delegate patterns can move faster than the draft

thanks, the three kinds read right. Two precision points from running them against the delegate I tested.

  1. The account itself. An ordinary smart-account delegate lets the account call itself or accepts a signature of the account, and that matters for both wordings. For delegate-single-caller, “one fixed address and nobody else” can be defeated by one extra path in a sweeper (the account itself, or a signature of the account): that counts as another caller, so the kind reads false while the fixed address can still empty the account. For delegate-unbounded-outflow, almost every ordinary delegate reads true, because the account can send its whole balance wherever it chooses. I would word both as “a caller other than the account itself and not authorized by a signature of the account”.

  2. My item 3 said “from the same signer”, which was ambiguous, and the draft now reads it as the transaction sender. Those are two signals: one account signing many consecutive nonces (the 29 October case: 50 authorizations, all signed by one account, with consecutive nonces, sent by the delegate’s only allowed caller) versus one sender carrying authorizations from many accounts (a sponsor sweeping many wallets). I would report both: sameSender and distinctAuthorities, the number of distinct accounts that signed.

both right, thanks for running them against the real delegate. pushed to the PR:
· delegate-single-caller and delegate-unbounded-outflow now count outside callers only: a caller other than the account itself and not authorized by a signature of the account. so an ordinary smart-account delegate no longer reads true just because the account can spend its own balance, and an extra account path in a sweeper no longer flips single-caller to false
· delegate-authorizations is now { count, sameSender, distinctAuthorities, senderIsOnlyCaller }: one account signing many consecutive nonces and one sponsor carrying many accounts’ authorizations are reported as the two signals they are

The Test Cases section has no case for the three delegate kinds yet, so here are vectors for them. V1 to V6 are simulated calls against delegated code (account code = 0xef0100 plus the delegate address, 100 ETH on the account). Every caller tries 1 wei, and the whole balance to each of two different recipients. The account itself and a signature of the account are not counted as outside callers, as in the new wording.

Results as (delegate-single-caller, delegate-unbounded-outflow):

  • V1, delegate callable only by the account itself: false, false
  • V2, delegate that only accepts a signature of the account: false, false (a random caller that brings the signature gets through, and is excluded by the definition)
  • V3, one hard-coded caller, no limits: true, true
  • V4, V3 plus a path for the account itself: true, true
  • V5, V3 with a 1 ether cap per call: true, false
  • V6, two hard-coded callers, no limits: false, true
  • V7, the real delegate from the 29 October case (0x63e842B054Bd624a465454D533C33F573e9c6fAe, deployed runtime code, 1674 bytes). Same idea against all four of its value-moving functions (sweep, withdrawETH, withdrawToken, callExecute): random callers and the account itself revert on every one, and the one hard-coded caller succeeds on every one. withdrawETH moves the whole 100 ETH to either recipient, withdrawToken the whole balance of a test token: true, true.

For delegate-authorizations, real chain data. Report block 26300754, blocks = 1: block 26300753 holds one type-4 transaction (0xad99264d5532ae0dd04b2004eebda05f25657e70dacb764f7ac8d4ccd051298b) with 50 authorizations for the V7 delegate, sent by the hard-coded caller. Block 26300754 holds none for it, and neither does 26300752, so blocks = 2 gives the same numbers. count 50, sameSender 50, distinctAuthorities 1 (one account signed all 50, nonces 18914775 to 18914824), senderIsOnlyCaller true. This is the case the split into count and distinctAuthorities is for.

V1 to V6 are small contracts I wrote; V7 and the authorizations case are real code and real data. The harness is handed the fixed caller (for V7 I read it from the contract). Finding such addresses in bytecode and storage is the hard part: until a source can do that, a false here only means no outside caller was found among the ones tried, so it should read not read when the analysis is incomplete. I can paste the Foundry test if it helps.

thanks, these are exactly what the section was missing. added all seven and the 29 october authorizations case to the test cases, with credit, in the PR.

and agreed on the last point: a false from a partial analysis is only “no outside caller among the ones tried”, so it reads not read until the source can find every caller. that’s how ours reports them today.

yes please on the foundry test. if you’re ok with it we’d add it to the assets folder under your name, so implementers can run the same vectors

The new delegate findings describe code at the report’s block. In the draft’s calls binding, though, subjectDigest covers chainId, from, calls and typedData, with no field for an EIP-7702 authorization list. This appears to leave a gap for transactions that install or replace a delegate: EIP-7702 processes authorizations before execution, so the same calldata could run against a different delegate without changing that digest.

I’d include the ordered authorization list in the subject and its digest, and distinguish the existing delegation from the one the transaction would install. Sources unable to evaluate that transition should mark the relevant findings not-read. A useful test would change only the authorized delegate and require a different digest; another would cover delegation persisting when execution reverts. Could the draft cover this path or explicitly exclude transactions carrying authorizations until it does?

1 Like

good catch, that’s a real hole. the delegate findings read code at the report’s block, but a type-4 tx changes that code before its calls run, and the digest couldn’t tell.

fixed in the PR:
· the subject carries the authorizationList, in order, and subjectDigest covers it
· new finding address.delegation {before, after}: the delegate in place at the block and the one the tx would leave
· the delegate findings read the code after the list is applied. a source that can’t apply it reports them not read, never the old code
· none of it depends on the simulation succeeding, since 7702 keeps the delegation when execution reverts
· both your tests are in: change only the authorized delegate and the digest changes, and a reverting tx still reports the new delegation

ours doesn’t apply authorization lists yet, so it refuses a request that carries one rather than report on code the tx would replace.

1 Like

Here is the Foundry test, inline below so it stays with the thread.

Fourteen tests, Foundry 1.5.1 with solc 0.8.28, evm_version = “prague” and forge-std at commit bd8c870, forge test -vv, all pass. It needs no RPC: the runtime code of the real delegate (1674 bytes, 0x63e842B054Bd624a465454D533C33F573e9c6fAe, read from mainnet) is embedded, and its hash matched what the chain returned when I read it. The first nine are the vectors from my earlier post, and the lines starting with VECTOR give the same results, so implementers can compare them case by case. V1 to V6 are small contracts I wrote for the test; V7 and V7b run the real code. The other five check the test itself: x1 runs the same delegation through Foundry’s native EIP-7702 path and gets the same code as the vm.etch shortcut, x4 fuzzes callers of the real delegate (any address other than the hard-coded one reverts on all four functions).

Two of those checks are worth a line in the text. V5 reads false for delegate-unbounded-outflow because the kind is per call, and x3 shows the 1 ether cap still lets the caller take 100 ether in 100 calls, so a false is not a bound on total outflow. And x2: a delegate whose fixed caller is not among the addresses the harness tries reads false for both kinds even though that caller can take everything, so a false should read not read when the analysis is incomplete.

Yes please, go ahead and add it to the assets folder under my name.

PreSignDelegateVectors.t.sol (MIT)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "forge-std/Test.sol";
import {VmSafe} from "forge-std/Vm.sol";

// Test vectors for the delegate-* finding kinds of the Agent Pre-Sign Risk Report
// (delegate-single-caller, delegate-unbounded-outflow). Foundry, EVM prague.
// An account is simulated as code = 0xef0100 || delegate address (EIP-7702) with 100 ETH on it.
// For every delegate, each candidate caller tries: 1 wei, and the whole balance to each of two recipients.
// The account itself, and a caller that brings a signature of the account, are not counted as outside callers.
// V1 to V6 are small contracts written for this test. V7 is the deployed runtime code of a real delegate
// (0x63e842B054Bd624a465454D533C33F573e9c6fAe, 1674 bytes, read from Ethereum mainnet), embedded below so that
// the test runs without an RPC. The harness is handed the fixed caller; finding such addresses in bytecode and
// storage is the hard part and is not done here: a false only means "no outside caller found among those tried".
// Tests x1 to x5 are checks on the test itself (native 7702 path vs vm.etch, a fixed caller outside the candidate list,
// per-call cap vs total outflow, fuzzing the real delegate's callers, and its ETH sweep branch).

// ---- delegates (what a 7702 account's code points at) ----
contract Who { function who() external view returns (address) { return address(this); } }

// ordinary smart-account style: only the account itself may call
contract SelfOnly {
    function execute(address to, uint256 v, bytes calldata d) external {
        require(msg.sender == address(this), "NotSelf");
        (bool ok,) = to.call{value: v}(d); require(ok, "fail");
    }
}
// anyone may call, but only with a signature of the account
contract SigOnly {
    uint256 public nonce;
    function executeSigned(address to, uint256 v, bytes calldata sig) external {
        require(sig.length == 65, "NoSig");
        bytes32 h = keccak256(abi.encode(block.chainid, address(this), to, v, nonce));
        bytes32 r = bytes32(sig[0:32]); bytes32 s = bytes32(sig[32:64]); uint8 vv = uint8(sig[64]);
        require(ecrecover(h, vv, r, s) == address(this), "BadSig");
        nonce++;
        (bool ok,) = to.call{value: v}(""); require(ok, "fail");
    }
}
// sweeper shape: one hard-coded caller, no limits
contract FixedCaller {
    address constant C = address(0xC0FFEE);
    function withdrawETH(address to, uint256 amt) external {
        require(msg.sender == C, "NotAuthorized");
        (bool ok,) = to.call{value: amt}(""); require(ok, "fail");
    }
}
// same sweeper plus an extra path for the account itself (the evasion case)
contract FixedCallerOrSelf {
    address constant C = address(0xC0FFEE);
    function withdrawETH(address to, uint256 amt) external {
        require(msg.sender == C || msg.sender == address(this), "NotAuthorized");
        (bool ok,) = to.call{value: amt}(""); require(ok, "fail");
    }
}
// one fixed caller, but a per-call cap of 1 ether
contract CappedFixed {
    address constant C = address(0xC0FFEE);
    function withdrawETH(address to, uint256 amt) external {
        require(msg.sender == C, "NotAuthorized");
        require(amt <= 1 ether, "Cap");
        (bool ok,) = to.call{value: amt}(""); require(ok, "fail");
    }
}
// two fixed callers, no limits
contract TwoCallers {
    address constant C = address(0xC0FFEE);
    address constant D = address(0xD00D);
    function withdrawETH(address to, uint256 amt) external {
        require(msg.sender == C || msg.sender == D, "NotAuthorized");
        (bool ok,) = to.call{value: amt}(""); require(ok, "fail");
    }
}

// ---- helpers for the V7b probe ----
contract MockTok {
    mapping(address => uint256) public balanceOf;
    function mint(address a, uint256 v) external { balanceOf[a] = v; }
    function transfer(address to, uint256 v) external returns (bool) { balanceOf[msg.sender] -= v; balanceOf[to] += v; return true; }
}
contract Exec { function execute(address, uint256, bytes calldata) external payable {} }


struct VmSignedDelegation { uint8 v; bytes32 r; bytes32 s; uint64 nonce; address implementation; }
// fixed caller that is not in the harness's candidate list
contract HiddenCaller {
    address constant C = address(0xABCDEF);
    function withdrawETH(address to, uint256 amt) external {
        require(msg.sender == C, "NotAuthorized");
        (bool ok,) = to.call{value: amt}(""); require(ok, "fail");
    }
}

struct caller_t { address a; bool isSelf; }

contract PreSignDelegateVectorsTest is Test {
    uint256 constant PK = 0xA11CE;
    address acct;
    address constant REC1 = address(0xBEEF01);
    address constant REC2 = address(0xBEEF02);
    address constant RAND1 = address(0x1111111111111111111111111111111111111111);
    address constant RAND2 = address(0x2222222222222222222222222222222222222222);
    address constant FIX1 = address(0xC0FFEE);
    address constant FIX2 = address(0xD00D);
    // the one hard-coded caller inside the real delegate's code (it also answers authorizedCaller())
    address constant CASE_CALLER = 0x7C8601d4645b93cea45F71e118A729332e6B5CA0;
    address constant REAL_DELEGATE = 0x63e842B054Bd624a465454D533C33F573e9c6fAe;
    // deployed runtime code of REAL_DELEGATE, Ethereum mainnet, 1674 bytes
    bytes constant REAL_DELEGATE_CODE = hex"6080604052600436101561001a575b3615610018575f80fd5b005b5f3560e01c806301e336671461049f578063043ff9d2146103375780634782f779146102f65780638a179be414610087576397dc97cb0361000e5734610083575f366003190112610083576020604051737c8601d4645b93cea45f71e118a729332e6b5ca08152f35b5f80fd5b34610083576040366003190112610083576100a06104e9565b60243567ffffffffffffffff811161008357366023820112156100835780600401359067ffffffffffffffff8211610083573660248360051b8301011161008357737c8601d4645b93cea45f71e118a729332e6b5ca033036102e7575f5b82811015610018576024600582901b830101356001600160a01b038116919082810361008357826101be57504791670de0b6b3a76400008311610148575b50600191505b016100fe565b670de0b6b3a763ffff1983019283116101aa575f808080600196878060a01b038b165af161017461056f565b5061013c577f394e1e4ba4d16d4e4c835649c554cd62437474ccefbb493591e6af3ce7c6c479602060405160038152a28561013c565b634e487b7160e01b5f52601160045260245ffd5b915f8060405160208101906370a0823160e01b8252306024820152602481526101e8604482610539565b5190865afa926101f661056f565b931580156102dc575b6102a857602084805181010312610083576020600194015180610225575b505050610142565b5f91829182604051602081019263a9059cbb60e01b8452898060a01b038d16602483015260448201526044815261025d606482610539565b51925af161026961056f565b5015610277575b808061021d565b7f394e1e4ba4d16d4e4c835649c554cd62437474ccefbb493591e6af3ce7c6c479602060405160028152a285610270565b50600192507f394e1e4ba4d16d4e4c835649c554cd62437474ccefbb493591e6af3ce7c6c4796020604051858152a2610142565b5060208451106101ff565b63ea8e4eb560e01b5f5260045ffd5b346100835760403660031901126100835761030f6104e9565b737c8601d4645b93cea45f71e118a729332e6b5ca033036102e7576100189060243590610618565b60803660031901126100835761034b6104e9565b6103536104ff565b60643567ffffffffffffffff811161008357366023820112156100835780600401359167ffffffffffffffff831161008357366024848401011161008357737c8601d4645b93cea45f71e118a729332e6b5ca033036102e757833b1561048157602461041a60a45f95948587966040519586936020850198635b0e93fb60e11b8a5260018060a01b031682860152604435604486015260606064860152826084860152018484013786838284010152601f801991011681010301601f198101835282610539565b519034855af19061042961056f565b9115610449576040516020808252819061044590820185610515565b0390f35b604080516373c78f0360e11b81526001600160a01b039092166004830152602482015290819061047d906044830190610515565b0390fd5b63ca05110160e01b5f9081526001600160a01b038516600452602490fd5b34610083576060366003190112610083576104b86104e9565b6104c06104ff565b90737c8601d4645b93cea45f71e118a729332e6b5ca033036102e75761001891604435916105ae565b600435906001600160a01b038216820361008357565b602435906001600160a01b038216820361008357565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b90601f8019910116810190811067ffffffffffffffff82111761055b57604052565b634e487b7160e01b5f52604160045260245ffd5b3d156105a9573d9067ffffffffffffffff821161055b576040519161059e601f8201601f191660200184610539565b82523d5f602084013e565b606090565b9190918115610613575f9283809360405190602082019363a9059cbb60e01b855260018060a01b031660248301526044820152604481526105f0606482610539565b51925af16105fc61056f565b501561060457565b63022e258160e11b5f5260045ffd5b505050565b8115610650575f918291829182916001600160a01b03165af161063961056f565b501561064157565b63b12d13eb60e01b5f5260045ffd5b505056fea2646970667358221220344569a8498384617633b23a4eac46a7f371fa5f36b3cda0cfc3f8bc3855085564736f6c634300081c0033";

    function setUp() public { acct = vm.addr(PK); }

    function _signNative(address d) internal returns (VmSignedDelegation memory out) {
        VmSafe.SignedDelegation memory sd = vm.signDelegation(d, PK);
        out = VmSignedDelegation(sd.v, sd.r, sd.s, sd.nonce, sd.implementation);
    }

    function _delegate(address d) internal { vm.etch(acct, abi.encodePacked(hex"ef0100", d)); vm.deal(acct, 100 ether); }

    function _cd(uint8 k, address to, uint256 amt) internal pure returns (bytes memory) {
        if (k == 0) return abi.encodeWithSignature("execute(address,uint256,bytes)", to, amt, bytes(""));
        if (k == 1) return abi.encodeWithSignature("executeSigned(address,uint256,bytes)", to, amt, bytes(""));
        return abi.encodeWithSignature("withdrawETH(address,uint256)", to, amt);
    }

    function _try(address caller, uint8 k, address to, uint256 amt) internal returns (bool ok) {
        vm.deal(acct, 100 ether);
        vm.prank(caller);
        (ok,) = acct.call(_cd(k, to, amt));
    }

    // returns (singleCaller, unboundedOutflow); logs every probe
    function _classify(string memory name, uint8 k, address[] memory cands) internal returns (bool single, bool outflow) {
        bool selfOk = _try(acct, k, REC1, 1);
        uint256 working; uint256 workingFixed; bool fullToBoth = false;
        for (uint256 i = 0; i < cands.length; i++) {
            bool tiny = _try(cands[i], k, REC1, 1);
            bool full1 = _try(cands[i], k, REC1, 100 ether);
            bool full2 = _try(cands[i], k, REC2, 100 ether);
            console2.log(string.concat("PROBE ", name, " caller=", vm.toString(cands[i]), " 1wei=", tiny ? "ok" : "revert", " full->A=", full1 ? "ok" : "revert", " full->B=", full2 ? "ok" : "revert"));
            if (tiny || full1) { working++; if (cands[i] != RAND1 && cands[i] != RAND2) workingFixed++; }
            if (full1 && full2) fullToBoth = true;
        }
        single = (working == 1 && workingFixed == 1);
        outflow = fullToBoth;
        console2.log(string.concat("PROBE ", name, " caller=account-itself 1wei=", selfOk ? "ok" : "revert", " (not counted)"));
        console2.log(string.concat("VECTOR ", name, ": delegate-single-caller=", single ? "true" : "false", " delegate-unbounded-outflow=", outflow ? "true" : "false"));
    }

    function _c(bool withSecond) internal pure returns (address[] memory a) {
        a = new address[](withSecond ? 4 : 3);
        a[0] = RAND1; a[1] = RAND2; a[2] = FIX1;
        if (withSecond) a[3] = FIX2;
    }

    function test_00_sanity_delegation_runs_as_account() public {
        address w = address(new Who()); _delegate(w);
        (bool ok, bytes memory r) = acct.call(abi.encodeWithSignature("who()"));
        console2.log(string.concat("SANITY delegated call ok=", ok ? "true" : "false", " returned=", ok ? vm.toString(abi.decode(r, (address))) : "-", " account=", vm.toString(acct)));
        assertTrue(ok);
        assertEq(abi.decode(r, (address)), acct);
    }

    function test_v1_self_only_ordinary_smart_account() public {
        _delegate(address(new SelfOnly()));
        (bool s, bool o) = _classify("V1 self-only delegate", 0, _c(false));
        assertTrue(!s && !o);
    }

    function test_v2_signature_of_account_only() public {
        _delegate(address(new SigOnly()));
        (bool s, bool o) = _classify("V2 signature-of-account delegate", 1, _c(false));
        // a random caller WITH the account's signature succeeds, and is excluded by definition
        bytes32 h = keccak256(abi.encode(block.chainid, acct, REC1, uint256(1), uint256(0)));
        (uint8 v, bytes32 r, bytes32 ss) = vm.sign(PK, h);
        vm.deal(acct, 100 ether);
        vm.prank(RAND1);
        (bool ok,) = acct.call(abi.encodeWithSignature("executeSigned(address,uint256,bytes)", REC1, uint256(1), abi.encodePacked(r, ss, v)));
        console2.log(string.concat("PROBE V2 random caller WITH account signature 1wei=", ok ? "ok" : "revert", " (excluded: authorized by a signature of the account)"));
        assertTrue(ok);
        assertTrue(!s && !o);
    }

    function test_v3_fixed_caller_sweeper() public {
        _delegate(address(new FixedCaller()));
        (bool s, bool o) = _classify("V3 fixed-caller sweeper", 2, _c(false));
        assertTrue(s && o);
    }

    function test_v4_fixed_caller_plus_self_path_evasion() public {
        _delegate(address(new FixedCallerOrSelf()));
        (bool s, bool o) = _classify("V4 fixed caller + account self path", 2, _c(false));
        assertTrue(s && o);
    }

    function test_v5_fixed_caller_with_cap() public {
        _delegate(address(new CappedFixed()));
        (bool s, bool o) = _classify("V5 fixed caller, 1 ether cap per call", 2, _c(false));
        assertTrue(s && !o);
    }

    function test_v6_two_callers() public {
        _delegate(address(new TwoCallers()));
        (bool s, bool o) = _classify("V6 two fixed callers", 2, _c(true));
        assertTrue(!s && o);
    }

    function test_v7_real_delegate_runtime_code() public {
        vm.etch(REAL_DELEGATE, REAL_DELEGATE_CODE);
        _delegate(REAL_DELEGATE);
        address[] memory a = new address[](3);
        a[0] = RAND1; a[1] = RAND2; a[2] = CASE_CALLER;
        console2.log(string.concat("V7 code length=", vm.toString(REAL_DELEGATE_CODE.length)));
        (bool s, bool o) = _classify("V7 real delegate 0x63e8...6fae (deployed runtime code)", 2, a);
        assertTrue(s && o);
    }

    // V7b: every value-moving function of the real delegate, native and token, all callers
    function _nm(uint256 f) internal pure returns (string memory) {
        if (f == 0) return "sweep(to,[token])";
        if (f == 1) return "withdrawETH(to,100 ether)";
        if (f == 2) return "withdrawToken(token,to,1000)";
        return "callExecute(exec,to,1,0x)";
    }

    function _v7bCall(uint256 f, MockTok tok, address exec, caller_t memory who) internal returns (bool ok) {
        vm.deal(acct, 100 ether); tok.mint(acct, 1000); vm.deal(REC1, 0); tok.mint(REC1, 0);
        bytes memory cd;
        if (f == 0) {
            address[] memory toks = new address[](1); toks[0] = address(tok);
            cd = abi.encodeWithSignature("sweep(address,address[])", REC1, toks);
        } else if (f == 1) {
            cd = abi.encodeWithSignature("withdrawETH(address,uint256)", REC1, 100 ether);
        } else if (f == 2) {
            cd = abi.encodeWithSignature("withdrawToken(address,address,uint256)", address(tok), REC1, 1000);
        } else {
            cd = abi.encodeWithSignature("callExecute(address,address,uint256,bytes)", exec, REC1, 1, bytes(""));
        }
        vm.prank(who.a);
        (ok,) = acct.call(cd);
        string memory label = who.isSelf ? "account-itself" : vm.toString(who.a);
        console2.log(string.concat("PROBE V7b ", _nm(f), " caller=", label, " ", ok ? "ok" : "revert", " recipientEth=", vm.toString(REC1.balance), " recipientTok=", vm.toString(tok.balanceOf(REC1))));
    }

    function test_v7b_all_functions_real_delegate() public {
        vm.etch(REAL_DELEGATE, REAL_DELEGATE_CODE);
        _delegate(REAL_DELEGATE);
        MockTok tok = new MockTok();
        address exec = address(new Exec());
        uint256 outsideOk = 0; uint256 caseOk = 0;
        for (uint256 f = 0; f < 4; f++) {
            if (_v7bCall(f, tok, exec, caller_t(RAND1, false))) outsideOk++;
            if (_v7bCall(f, tok, exec, caller_t(RAND2, false))) outsideOk++;
            _v7bCall(f, tok, exec, caller_t(acct, true));
            if (_v7bCall(f, tok, exec, caller_t(CASE_CALLER, false))) caseOk++;
        }
        console2.log(string.concat("VECTOR V7b real delegate: random outside callers that succeeded=", vm.toString(outsideOk), " ; hard-coded caller successes (of 4 functions)=", vm.toString(caseOk)));
        assertEq(outsideOk, 0);
        assertGe(caseOk, 3);
    }

    // ---------- extra checks (attacks on the test itself) ----------

    // The vectors use vm.etch(0xef0100 || delegate). Cross-check against Foundry's native EIP-7702 path:
    // the account signs a delegation, it is attached to a transaction, and the resulting code is used.
    function test_x1_native_7702_matches_etch() public {
        address d = address(new FixedCaller());
        VmSignedDelegation memory sd = _signNative(d);
        vm.attachDelegation(VmSafe.SignedDelegation(sd.v, sd.r, sd.s, sd.nonce, sd.implementation));
        vm.deal(acct, 100 ether);
        vm.prank(FIX1);
        (bool okFixed,) = acct.call(_cd(2, REC1, 100 ether));
        console2.log(string.concat("X1 native 7702: code=", vm.toString(acct.code), " fixed caller ok=", okFixed ? "true" : "false"));
        assertEq(acct.code, abi.encodePacked(hex"ef0100", d));
        assertTrue(okFixed);
        vm.deal(acct, 100 ether);
        vm.prank(RAND1);
        (bool okRand,) = acct.call(_cd(2, REC1, 1));
        assertTrue(!okRand);
    }

    // A delegate whose fixed caller is NOT among the candidates reads false/false: a false is "not found", not "safe".
    function test_x2_fixed_caller_outside_candidate_list_reads_false() public {
        _delegate(address(new HiddenCaller()));
        (bool s, bool o) = _classify("X2 fixed caller not among candidates", 2, _c(false));
        assertTrue(!s && !o);
        // and it really is drainable by that caller:
        vm.deal(acct, 100 ether);
        vm.prank(address(0xABCDEF));
        (bool ok,) = acct.call(_cd(2, REC1, 100 ether));
        assertTrue(ok);
    }

    // delegate-unbounded-outflow is per call by definition: a per-call cap reads false, yet repeated calls drain everything.
    function test_x3_per_call_cap_does_not_bound_total_outflow() public {
        _delegate(address(new CappedFixed()));
        vm.deal(acct, 100 ether);
        for (uint256 i = 0; i < 100; i++) {
            vm.prank(FIX1);
            (bool ok,) = acct.call(_cd(2, REC1, 1 ether));
            require(ok, "cap call failed");
        }
        console2.log(string.concat("X3 after 100 calls of 1 ether: account balance=", vm.toString(acct.balance), " recipient=", vm.toString(REC1.balance)));
        assertEq(acct.balance, 0);
        assertEq(REC1.balance, 100 ether);
    }

    // Real delegate: any caller other than the hard-coded one reverts, on every value-moving function.
    function testFuzz_x4_real_delegate_only_hardcoded_caller(address caller, uint8 f) public {
        vm.assume(caller != CASE_CALLER && caller != acct && caller != address(vm) && caller.code.length == 0);
        vm.etch(REAL_DELEGATE, REAL_DELEGATE_CODE);
        _delegate(REAL_DELEGATE);
        MockTok tok = new MockTok();
        address exec = address(new Exec());
        bool ok = _v7bCall(uint256(f % 4), tok, exec, caller_t(caller, false));
        assertTrue(!ok);
    }

    // Real delegate: authorizedCaller() getter, and what the ETH branch of sweep (token = address(0)) moves.
    function test_x5_real_delegate_getter_and_eth_sweep() public {
        vm.etch(REAL_DELEGATE, REAL_DELEGATE_CODE);
        _delegate(REAL_DELEGATE);
        (bool g, bytes memory r) = acct.staticcall(abi.encodeWithSignature("authorizedCaller()"));
        assertTrue(g);
        assertEq(abi.decode(r, (address)), CASE_CALLER);
        address[] memory toks = new address[](1); toks[0] = address(0);
        vm.deal(REC1, 0);
        vm.prank(CASE_CALLER);
        (bool ok,) = acct.call(abi.encodeWithSignature("sweep(address,address[])", REC1, toks));
        console2.log(string.concat("X5 sweep ETH branch ok=", ok ? "true" : "false", " recipient=", vm.toString(REC1.balance), " left on account=", vm.toString(acct.balance)));
        assertTrue(ok);
    }
}

thanks, added to the PR under your name: assets/erc-8481/PreSignDelegateVectors.t.sol (MIT). checked the embedded delegate code against mainnet, same 1674 bytes.
both points are in the text now:
· delegate-unbounded-outflow is per call, so false is not a bound on total outflow (your x3: 100 calls of 1 ether)
· a fixed caller outside the tried set reads false for both kinds (your x2), so a false from an incomplete analysis is not read

Thanks, TOLL, and thanks for checking the embedded code against mainnet. I’m glad both caveats made it into the text. If you can share the PR link, I’ll follow the review and flag anything in the vectors that needs an update.

here it is: Add ERC-8481: Agent Pre-Sign Risk Report by soli0x · Pull Request #2134 · ethereum/ERCs · GitHub
your vectors are in assets/erc-8481/PreSignDelegateVectors.t.sol, anything you flag there I’ll fix

On question 3: off-chain EIP-712 is enough for the pre-sign decision, and the optional anchoring section in the PR reads right to me. One thing sits between that section and the verification steps.

Step 3 reads the signer binding at the time of verification, so removing a key from signers revokes it, and the rationale makes the same choice on purpose for transfers. Anchoring is there so anyone can count a source’s reports against what happened later. Those two pull apart: once a key leaves signers, or the agentWallet changes or is cleared on transfer as ERC-8004 does, every earlier report under that key fails step 3 and is treated as unsigned, anchored or not. The same goes for an ERC-1271 signer whose isValidSignature later stops accepting the key. A source can drop a key and its record goes with it, including the reports that turned out wrong.

I’d split the check. Before signing, keep it as written, so revocation works. For counting reports later, read the binding as of the anchoring time: a report anchored before the key was removed was signed while the key was listed, and one anchored after can’t be credited to the source. Anchoring fixes when, and says nothing about who held the key, so reports from a stolen key anchored before removal still count against the source, which seems right for a record.

For getAgentWallet and ownerOf that is an archive read on the registry’s chain. anchoredAt returns a block on the anchor’s own chain, so where the anchor sits on another chain the draft could say how to map it, for example the last registry block at or before the anchor’s timestamp. For a signers list it also needs the old registration file: tokenURI at that block is an archive read, but an https file may have changed since. The draft could require a content-addressed or data: URI for a registration file that lists signers, or say that reports signed by a key listed only in a mutable file can’t be audited once the key is removed.

Douglas

1 Like

thanks, all three are in the PR now (96b4efc):
· step 3 at verification time stays the check before signing. counting anchored reports later evaluates the binding as of the anchoring: getAgentWallet / ownerOf / signers at the last block of the registry’s chain at or before the anchoring’s timestamp, which also covers an anchor on another chain
· a report anchored while its key was bound counts against the source’s agentId even after the key is removed, stolen keys included. removing a key doesn’t remove anchored reports from the record
· a registration file that lists signers SHOULD be content-addressed (ipfs:// or data:). a key listed only in an https:// file can’t be attributed once it’s removed from it added a security line on revoked and stolen keys and a test case for the anchoring-time binding

1 Like

Added an anchor + tests in a draft PR. Douglas’s ERC-1271 case reproduces with an unchanged registry binding: rotating the contract’s internal key makes it reject the old signature. For historical audits, should step 2’s signature call use the same block as step 3?

yes, same block. step 2 runs at the block step 3 reads: whether the signer has code at all (7702 can change that) and the 1271 call, otherwise a contract that rotates its key or gets upgraded wipes reports it already signed, which is what anchoring is there to prevent

pushed to the PR: historical audits run step 2 at the anchoring block, a verifier without archive state treats the report as not read (not unsigned), and your rotation case is a test case

ran your draft PR, 31/31 pass, anchor + arbsys variant + vectors match the spec. merged it. thanks

We run pre-sign rule gates on the consumer side (an agent’s order or payment is checked against the owner’s rules and comes back Allowed, Blocked, or held for the owner’s OK), so we read this from the consumer end. Facts-not-verdicts and “not read is a status” match how our gates already work: an unknown mark price or unreadable payment requirements blocks, it never passes. Notes from mapping our checks onto the draft, mostly on address.on-list:

1. On-list in practice. This week we pinned the FBI’s 31 Oct TraderTraitor address list (608 ETH, 19 BTC, 1 SOL) as a candidate list for this kind. Four things came up:

  • Stable bytes. The advisory page changes on every fetch (the list doesn’t), so keccak256 of the page at uri can’t be reproduced. Could the draft say that uri/hash name a pinned list document, and that the upstream publication goes in a document evidence entry? A minimal list format (source URI, retrieval time, inclusion criteria, entries) would also let two sources produce the same hash for the same list.
  • Per-entry evidence. Official advisories give one inclusion statement for all entries and no per-entry transactions. As written (“for each entry, the evidence it was listed on”) such lists can’t conform. Could a publisher’s attestation covering every entry count as each entry’s evidence, as long as the list says so?
  • Chain scope and matching. The FBI lists “ETH addresses”, but the same key holds the same address on every EVM chain. Entries as CAIP-10, or a declared scope such as eip155:*, would make that explicit. It would also help to fix how addresses are compared (EVM case-insensitive, bech32 lowercase, base58 exact) and to have value name the matching entry, not just true.
  • Asking for a list. kinds is string[], so a consumer can’t ask for on-list against a list it chose (same for pattern-match). Allowing { kind, param } entries in kinds would cover it.

2. Small fix. Under Entities, authorization-list authorities get role authority, but type Role doesn’t include 'authority'.

3. On the open questions.

  • (a) Risk slot: risk.reports works for us. One addition: let a projected warning point back to the finding it came from (reportHash plus the finding’s index), so an audit can tie the consumer’s action to the exact fact.
  • (c) Anchoring: off-chain EIP-712 is enough for v1. What we need is to store reportHash next to our own decision record, and the optional anchor doesn’t get in the way of that.
  • One mapping note: our third outcome (“hold for the owner’s OK”) is stricter than WARN, which usually means “proceed with a warning”. That’s an ERC-8265 question rather than this draft’s, but consumers mapping onto action will hit it.

4. Orders. Some of what we check is EIP-712 perp orders: limit price against mark, notional, leverage, reduce-only. oracle-deviation is defined for pools. We’d report these under our own prefix for now. If other consumers need the same facts, a shared order group could follow later.

Happy to share the normalization and diff test vectors from the list work if that helps the assets folder.

thanks, this is the kind of read we wanted from the consumer side. pushed to the PR (1810662):

  1. on-list
    · uri/hash now name a pinned list document, not the page. the upstream publication goes in the list’s source and in a
    document evidence entry with retrievedAt
    · minimal list format: version, source, criteria, optional attestation, entries. retrieval time stays out of the
    document, so two sources pinning the same upstream list get the same hash
    · an attestation covering every entry counts for entries without their own evidence, as long as the list carries it.
    so the FBI list conforms as one attested list
    · entries are CAIP-10, and the chain ref may be * (eip155:*:0x…) for “same key on every EVM chain”. addresses are
    normalized before hashing (EVM lowercase hex, bech32 lowercase, base58 exact), sorted, and deduped. matching follows
    the same rules
    · value is now the matching entry as written in the list, or null. no longer true/false
    · kinds accepts { kind, param }, so a consumer can ask for on-list (or pattern-match) against a list it chose. a
    source that won’t read that list reports not read / unsupported. it never swaps in its own list

  2. Role now includes ‘authority’. good catch

3a. a projected warning may carry finding: { reportHash, index }
3c. agreed, anchoring stays optional
on hold-for-owner vs WARN: agreed, that’s a question for 8265 rather than this draft

  1. orders: your own prefix is right for now. if a second consumer needs the same facts, a shared order group is a
    follow-up ERC, not this one

yes please on the normalization and diff vectors. if you open a PR against the assets folder we’ll run them and credit
you in test cases