EIPs Explained

ERC-5437 · Stagnant · ERC · 2022-08-09

ERC-5437: Security Contact Interface

A contract interface that publishes an official, encrypted security contact (a GPG public key plus email) so researchers know how to report vulnerabilities privately.

What problem does it solve?

When a researcher finds a bug in a deployed contract, there is often no reliable way to tell who maintains it or how to reach them privately. The best existing convention is a NatSpec comment in the source, e.g. /// @custom:security-contact [email protected], which only helps if the source is verified and does not provide encryption.

ERC-5437 puts the contact on-chain: the contract itself returns a public key and a delivery address, so a report can be encrypted to the maintainers.

How it works

Required:

  • getSecurityContact(type, data) returns (type, publicKey, extraData).
  • The contract must implement ERC-165.

type is one byte. Valid values are 0x10–0x7f; others are reserved. The spec defines one:

Type Encryption scheme extraData
0x10 GnuPG RSA/3072 Email address(es) in RFC 2822 format

Optional:

  • setSecurityContact(type, publicKey, extraData) plus a SecurityContactChanged event, for key rotation.
  • securityNotify(type, data): a payable on-chain notification, emitting OnSecurityNotification. Being payable lets a project require a stake from reporters.
  • bountyPolicy(id): returns a URI to a bug bounty policy; id = 0 is the overview.

Future EIPs can add new type values for other schemes or channels.

Sample code

Fetching a contract's security contact (ethers v6):

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));
}

Then encrypt the report with that key (e.g. gpg --encrypt --armor -r <key>) and email it.

Things to know

  • Status is Stagnant, and the interface still contains TODO notes (the optional setter and bounty function may be removed). Its signatures are written as public in an interface and use type as a parameter name, so they will not compile as-is.
  • The spec recommends keeping the @custom:security-contact comment as well.
  • Operators must keep the contact current, rotate keys on a sensible schedule and actually monitor the channel.
  • Do not send vulnerability details through securityNotify in clear text: on-chain data is public.

#security #disclosure #interface #contact

Details

Authors
Zainan Zhou (@xinbenlv)
Status
Stagnant
Type
Standards Track / ERC
Created
2022-08-09
Requires

Machine-readable: Markdown · JSON