ERC-5437 Security contact interface

Stagnant · Other · created 2022-08-09

Lets a contract publish an encryption public key and contact information on-chain for security researchers, enabling vulnerabilities to be reported safely through an encrypted channel.

Why it is needed

Until now, smart contracts had no standard way to designate an official channel for reporting security vulnerabilities. Existing approaches like OpenZeppelin's amount to writing a plaintext email address in a source code comment, which cannot be queried on-chain and exposes the contact information in plaintext without encryption. As a result, security researchers have to find the contact method differently for each contract, and there is no standard channel for delivering vulnerability details in encrypted form. There is also no standardized way to check whether a bug bounty policy exists or what it contains, leading to inconsistent reporting and reward procedures.

What to implement

In depth

Range and meaning of the type value

The type value accepted by getSecurityContact and setSecurityContact is a 1-byte value with a valid range of [0x10, 0x7f]. [0x00, 0x0f] and [0x80, 0xff] are reserved for future extension. The type value determines the format of the returned publicKey and extraData. The current specification defines only 0x10, where the encryption scheme is GnuPG RSA/3072 and extraData is an email address encoded in RFC 2822 format. New encryption schemes or delivery methods will be added to the table in the future through new EIPs assigning new type numbers.

Public key return format

The publicKey returned by getSecurityContact must follow the encryption scheme specified in the table. For type 0x10, the specification includes an example of returning an RSA/3072 public key generated with GnuPG as an RFC 2822 (ASCII-encoded, as stated in the source) PGP public key block string.

setSecurityContact and the change event

setSecurityContact is an optional function to implement. If this function is implemented and a call succeeds in setting a new security contact, it MUST emit the SecurityContactChanged event with the same values as the parameters passed to setSecurityContact. This function exists because the contact may need to change due to circumstances such as expiration of the encryption key.

On-chain reporting via securityNotify

It is RECOMMENDED to implement the securityNotify function for receiving security reports on-chain. This function is explicitly declared payable, allowing implementers to require a stake of a certain amount when reporting a vulnerability. If implemented and a call succeeds, it MUST emit the OnSecurityNotification event with the same values as the passed parameters.

EIP-165 implementation requirement

To comply with this interface, EIP-165 MUST be implemented. This allows other contracts or tools to check in a standardized way whether a given contract supports this security contact interface.

Querying the bug bounty policy

It is recommended to set the bug bounty policy through the bountyPolicy function. An id of 0 is reserved for an overall overview, while other id values point to individual bounty policies. The return value is a URI string for the document containing the policy content, and the format of the bounty policy itself is not specifically defined by this specification.

Compatibility with the existing plaintext approach

Current solutions like OpenZeppelin use a plaintext email address written in a source code comment in the form @custom:security-contact. This EIP recommends that new versions of contracts adopt this EIP's interface in addition to the existing plaintext comment approach.

Proposal status

This proposal is in Stagnant status, with some items in the specification (such as whether setSecurityContact should remain, adding the EIP-165 interface ID, and whether to split bountyPolicy into a separate EIP, all marked as TODO) still undetermined, and discussion is no longer active.

Things to watch out for

Original ERC · ← ERCs