EIP-3455 The SUDO opcode (SUDO Opcode)
No call decision · EVM & execution · EIP status Stagnant · created 2021-04-01
A proposal to add a new opcode, SUDO (0xf8), nearly identical to CALL except that the caller can directly specify the sender address, allowing a call to be impersonated under any identity.
Why it is needed
With today's CALL-family opcodes, only the account that executed the call can be recorded as CALLER (msg.sender). As a result, there is no way to recover funds locked due to a lost private key, tokens accumulated at an ownerless address (such as address 0), ERC-20 tokens mistakenly sent to a token contract's own address instead of a person, funds stolen through fraud, or contract funds locked by a bug. This proposal argues that a new opcode called SUDO, which lets a call directly specify the sender address, would let anyone withdraw such funds. However, this simultaneously breaks the access-control assumption that every contract relies on, namely that CALLER can be used as a means of identity verification.
What changes
Today
- Existing call opcodes such as CALL can only set CALLER (msg.sender) to the account executing the call itself
- There is no way to recover funds locked by a lost private key, a misdirected transfer, fraud, or a bug
- Contract access control operates on the assumption that CALLER cannot be forged
After EIP-3455
- The new opcode SUDO (0xf8) takes a Sender parameter and sets CALLER, ADDRESS, and CALLVALUE to values specified by the caller
- The caller becomes able to call other contracts under the identity of an arbitrary account
- Access control that uses CALLER as an identity check loses its effectiveness
- The proposal has stalled in Stagnant status and was never actually adopted
Who is affected
- Wallet & app developers: Any contract logic that uses msg.sender as the basis for ownership or authorization could be rendered ineffective.
- Client and EVM implementation teams: A new opcode 0xf8 and logic to handle its 8 stack parameters would need to be added, but since the proposal is Stagnant it is not actually implemented.
- Ordinary users: While presented as a way to recover lost keys or misdirected funds, it simultaneously exposes everyone to the risk of having calls made under their own identity by anyone else.
In depth
Opcode number and parameter composition
SUDO has the opcode number 0xf8 and pops 8 parameters from the stack. In order, they are Gas, Sender, To, Value, InStart, InSize, OutStart, OutSize, and apart from Sender all carry the same meaning as in CALL. Sender and To use the lower 40 bytes of the given value as the address.
The Gas parameter
Gas is an integer indicating the maximum amount of gas allowed for the message call. If the remaining gas counter at call time is less than the specified value, the specification states only that 'the current gas counter is used safely.'
Handling of Sender and Value
Sender is set as the CALLER value within the call frame. Value is an integer, and if the Sender account's balance is less than the specified Value, an exception occurs. If sufficient, Value is transferred to To's balance and set as the call frame's CALLVALUE. To is set as the call frame's ADDRESS.
Handling of CALLDATA and RETURNDATA
InStart and InSize specify the starting position and length of the memory region used as CALLDATA. OutStart and OutSize specify the starting position and maximum length of the memory region to be overwritten with the RETURNDATA returned by the call.
Execution result code
After the call ends, SUDO leaves a single value on the stack indicating success or failure. It leaves 1 if the call ends in STOP, RETURN, or SELFDESTRUCT, and 0 if it ends in REVERT, INVALID, or an EVM-level exception (assertion).
Rationale for the parameter order
According to the Rationale, GAS is placed first so that the caller can precisely calculate the remaining gas and decide how much to send as late as possible. The remaining parameters keep the same order as CALL, with Sender inserted among them.
Motivation for the proposal
The Motivation argues that SUDO can recover tokens and ether locked at ownerless accounts such as address 0, ERC-20 tokens mistakenly sent to a token contract's own address instead of a person, funds stolen through fraud, assets locked by a lost private key, and contract funds locked by a bug. It notes that, per Etherscan at the time of writing, address 0 held assets worth approximately $17 billion.
Status and security considerations
The status is Stagnant, with a created date of 2021-04-01. The entire Security Considerations section consists of a single sentence, 'It will be fine,' with no separate risk analysis. Because SUDO lets the caller specify CALLER arbitrarily, it disables the access control of every contract that is built on the assumption that msg.sender cannot be forged.