---
eip: 3455
label: EIP-3455
title: SUDO Opcode
status: Stagnant
type: Standards Track
category: Core
created: 2021-04-01
official: https://eips.ethereum.org/EIPS/eip-3455
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3455.md
canonical: https://eips.huatuo.xyz/zh/eip-3455/
lang: zh
tldr: 一个半开玩笑的提案：新增 SUDO opcode，可以用你选定的任意发送者地址发起 CALL，这会让任何人都能花掉别人的资金。
tags: [evm, opcode, core, security]
---

# EIP-3455: SUDO Opcode

> A new opcode is introduced to allow calling from an arbitrary sender address.

**TL;DR:** 一个半开玩笑的提案：新增 SUDO opcode，可以用你选定的任意发送者地址发起 CALL，这会让任何人都能花掉别人的资金。

## 它解决什么问题？

该提案列出了一些常见的痛点：发送到零地址的代币、不小心发送到代币合约自身的 [ERC-20](/eip-20/) 代币、因诈骗或遗忘私钥而丢失的资金，以及卡在有漏洞合约中的以太币。如今这些都无法找回，因为只有账户密钥的持有者（或合约自身的代码）才能移动其资产。

EIP-3455 给出的办法是让任何调用者都能**选定调用的 `msg.sender`**。有了这种能力，找回卡住的资金就变得轻而易举。偷走网络上其他所有余额也同样轻而易举，这才是值得理解的重点。

## 它如何运作

- 新增 opcode `SUDO`，位于 `0xf8`。
- 它从栈中弹出 **8** 个项：即 `CALL` 的 7 个参数，并在第二个位置插入一个 `sender` 地址。

| # | 参数 | 含义 |
| --- | --- | --- |
| 1 | gas | 本次调用的 gas 额度 |
| 2 | sender | 在被调用的帧内成为 `CALLER` |
| 3 | to | 目标地址 |
| 4 | value | 从 **sender** 的余额中扣除的 wei |
| 5–6 | inStart, inSize | 内存中的 calldata |
| 7–8 | outStart, outSize | 返回数据的写入位置 |

- 与 `CALL` 一样，成功（`STOP`、`RETURN`、`SELFDESTRUCT`）时压入 `1`，失败（`REVERT`、`INVALID`、其他异常终止）时压入 `0`。

换句话说，任何合约都可以冒充任何账户，包括转走它的以太币，并以该账户的身份调用代币合约。

## 示例代码

"找回"用伪汇编写出来是什么样子。同样的几条指令对任何地址都有效，而不只是针对丢失的地址：

```
; 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
```

为什么所有授权检查都会失效（Solidity）：

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

## 需要注意

- **状态：Stagnant。** 它从未被考虑纳入，`0xf8` 在以太坊上并不是 `SUDO` opcode。
- 它提交于 2021 年 4 月 1 日，其语气（整个“安全考虑”部分只有一句 "It will be fine."）表明它并非认真的提案。请把它当作一个思想实验，用来理解为什么 `msg.sender` 必须不可伪造。
- 真正可行的委托或可恢复控制方案都会让所有者的签名参与其中，例如带社交恢复的智能合约钱包，或由账户本身签名的 [EIP-7702](/eip-7702/) 委托。
- 如果你阅读规范文本，值得注意其中有一处小错误：它说地址被"截断为低 40 字节"，但以太坊地址是 20 字节。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-3455
