---
eip: 5437
label: ERC-5437
title: Security Contact Interface
status: Stagnant
type: Standards Track
category: ERC
created: 2022-08-09
requires: 165
official: https://eips.ethereum.org/EIPS/eip-5437
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5437.md
canonical: https://eips.huatuo.xyz/zh/eip-5437/
lang: zh
tldr: 一种合约接口，用于发布官方的加密安全联系方式（GPG 公钥加电子邮件），让研究人员知道如何私下报告漏洞。
tags: [security, disclosure, interface, contact]
---

# ERC-5437: Security Contact Interface

> An interface for security notice using asymmetric encryption

**TL;DR:** 一种合约接口，用于发布官方的加密安全联系方式（GPG 公钥加电子邮件），让研究人员知道如何私下报告漏洞。

## 它解决什么问题？

当研究人员在已部署的合约中发现漏洞时，往往没有可靠的方法得知谁在维护它，或如何私下联系他们。目前最好的惯例是源码中的 NatSpec 注释，例如 `/// @custom:security-contact someone@example.com`，但这只有在源码已验证时才有用，而且不提供加密。

ERC-5437 把联系方式放到链上：合约本身返回公钥和投递地址，因此报告可以加密发送给维护者。

## 它如何运作

必需：

- `getSecurityContact(type, data)` 返回 `(type, publicKey, extraData)`。
- 合约必须实现 [ERC-165](/eip-165/)。

`type` 为一个字节。有效值为 `0x10`–`0x7f`，其余保留。规范定义了其中一个：

| 类型 | 加密方案 | `extraData` |
| --- | --- | --- |
| `0x10` | GnuPG RSA/3072 | RFC 2822 格式的电子邮件地址 |

可选：

- `setSecurityContact(type, publicKey, extraData)` 以及 `SecurityContactChanged` 事件，用于密钥轮换。
- `securityNotify(type, data)`：一个 `payable` 的链上通知，会触发 `OnSecurityNotification`。由于是 payable，项目可以要求报告者质押。
- `bountyPolicy(id)`：返回漏洞赏金政策的 URI；`id = 0` 为概览。

未来的 EIP 可以为其他方案或渠道添加新的 `type` 值。

## 示例代码

获取合约的安全联系方式（ethers v6）：

```ts
import { Contract, JsonRpcProvider, toUtf8String } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const target = new Contract(process.env.CONTRACT!, [
  "function getSecurityContact(uint8 t, bytes data) view returns (uint8, bytes, bytes)",
], provider);

const [type, publicKey, extraData] = await target.getSecurityContact(0x10, "0x");
if (Number(type) === 0x10) {
  console.log("GPG key:\n" + toUtf8String(publicKey));   // ASCII-armored key
  console.log("send encrypted report to:", toUtf8String(extraData));
}
```

然后用该密钥加密报告（例如 `gpg --encrypt --armor -r <key>`）并通过电子邮件发送。

## 需要注意

- 状态为 **Stagnant**，接口中仍有 `TODO` 备注（可选的 setter 和赏金函数可能被删除）。其签名在 interface 中写成了 `public`，并且使用 `type` 作为参数名，因此无法原样编译。
- 规范建议同时保留 `@custom:security-contact` 注释。
- 运营方必须保持联系方式最新，按合理的周期轮换密钥，并真正监控该渠道。
- 不要通过 `securityNotify` 以明文发送漏洞细节：链上数据是公开的。


---

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