EIPs Explained

EIP-3455 · Stagnant · Core · 2021-04-01

EIP-3455: SUDO Opcode

A tongue-in-cheek proposal for a SUDO opcode that makes a CALL from any sender address you choose, which would let anyone spend anyone else's funds.

What problem does it solve?

The proposal lists familiar pain points: tokens sent to the zero address, ERC-20 tokens accidentally sent to the token contract itself, funds lost to scams or forgotten private keys, and ether stuck in buggy contracts. Today none of these can be recovered, because only the holder of an account's key (or the contract's own code) can move its assets.

EIP-3455's answer is to let any caller pick the msg.sender of a call. With that power, recovering stuck funds becomes trivial. So does stealing every other balance on the network, which is the point worth understanding.

How it works

  • A new opcode SUDO at 0xf8.
  • It pops 8 stack items: the 7 parameters of CALL with a sender address inserted second.
# Parameter Meaning
1 gas Gas allowance for the call
2 sender Becomes CALLER inside the called frame
3 to Target address
4 value Wei taken from sender's balance
5–6 inStart, inSize Calldata in memory
7–8 outStart, outSize Where return data is written
  • It pushes 1 on success (STOP, RETURN, SELFDESTRUCT) and 0 on failure (REVERT, INVALID, other exceptional halts), like CALL.

In other words, any contract could impersonate any account, including moving its ether and calling token contracts as that account.

Sample code

What a "recovery" would look like in pseudo-assembly. The same few instructions work against any address, not just lost ones:

; SUDO(gas, sender, to, value, inStart, inSize, outStart, outSize)
PUSH1 0x00          ; outSize
PUSH1 0x00          ; outStart
PUSH1 0x44          ; inSize  (transfer(address,uint256) calldata)
PUSH1 0x00          ; inStart
PUSH1 0x00          ; value
PUSH20 <token>      ; to
PUSH20 <victim>     ; sender  <- arbitrary
GAS                 ; gas
SUDO                ; 0xf8, not a real opcode on Ethereum

Why every authorization check would break (Solidity):

function withdraw(uint256 amount) external {
    // With SUDO, msg.sender can be forged, so this check proves nothing.
    require(balanceOf[msg.sender] >= amount);
    // ...
}

Things to know

  • Status: Stagnant. It was never considered for inclusion, and 0xf8 is not a SUDO opcode on Ethereum.
  • It was filed on 1 April 2021, and its tone (the entire Security Considerations section reads "It will be fine.") suggests it was not intended as a serious proposal. Read it as a thought experiment about why msg.sender must be unforgeable.
  • Real approaches to delegated or recoverable control keep the owner's signature in the loop, for example smart-contract wallets with social recovery, or EIP-7702 delegation signed by the account itself.
  • The spec text has small errors worth noting if you read it: it says addresses are "truncated to lower 40 bytes", but Ethereum addresses are 20 bytes.

#evm #opcode #core #security

Details

Authors
William Morriss (@wjmelements), Baptiste Vauthey (@thabaptiser)
Status
Stagnant
Type
Standards Track / Core
Created
2021-04-01

Machine-readable: Markdown · JSON