ERC-7512 Onchain representation of audit reports (Onchain Representation for Audits)
Draft · Signatures & auth · created 2023-09-05
A standard for representing smart contract audit results on chain in a format contracts can read. It allows confirming on chain, together with the auditor's signature, who performed the audit and which ERC implementation was verified.
Why it is needed
Smart contract audits are a core security measure, but their results usually exist only as off-chain documents. As a result, there is no way for other contracts to verify on chain whether a given contract has been audited or whether it correctly implements a standard such as ERC-20 or ERC-721. The original text cites bridges, token contracts, smart account (ERC-4337) modules, and interactions between token standards that trigger callbacks on transfer as areas where this kind of verification is needed. For example, a flaw in a bridge's token custody contract could halt operations or allow uncollateralized assets to be minted, and a token that behaves differently from the standard could lead to loss of funds. Being able to verify audit status on chain is not in itself a guarantee of being bug-free, but it becomes an important building block for creating innovative onchain security systems and can strengthen security guarantees across the entire ecosystem.
In depth
AuditSummary data structure
The audit summary (AuditSummary) consists of six fields. auditor holds audit firm information: name (the display name), uri (an address for additional information), and authors (the list of people who performed the audit and wrote the report). auditedContract is the audit target, where chainId must be the bytes32 representation of the EIP-155 chain ID and deployment must be the contract's deployment address (address). issuedAt must hold the time when the original audit identified by auditHash was issued. ercs is the list of ERCs the target contract implements; any ERC listed must be fully implemented, and the list may be empty. auditHash must be the hash of the original audit document, and auditUri should preferably point to a source from which the audit document can be obtained.
EIP-712 signatures and SignedAuditSummary
EIP-712 is used for signing because of its strong tooling compatibility. The primary type is AuditSummary, and the domain is an EIP712Domain with only name and version, with values "ERC-7652: Onchain Audit Representation" and "1.0". Attaching the generated signature produces a SignedAuditSummary, which adds signedAt (the time of signing) and auditorSignature. There are four signature types (SignatureType): SECP256K1, BLS, ERC1271, and SECP256R1. The data for SECP256K1 and SECP256R1 is the encoding of r, s, v, and the data for ERC1271 is the ABI encoding of chainId, address, blocknumber, and the signature bytes. BLS is not yet defined (TBD).
Findings are not covered
This ERC deliberately does not define audit findings. It was left out of scope because it is difficult to rigorously define how to standardize severity classification or which data to split between on-chain and off-chain. A signed audit summary means that the contract instance identified by chainId and deployment has undergone a security audit and correctly implements the listed ERCs, and it typically corresponds to the final audit revision tied to the deployment. However, this ERC should not be regarded as proof that a contract is safe; it is merely a methodology for extracting related data. Evaluating the quality, scope, and level of assurance of the data is left to whoever integrates this ERC.
One contract per audit summary
A single audit often covers multiple contracts that make up a protocol, but for simplicity in this early version, one audit summary references only one contract. If multiple contracts were reviewed in the same audit, the same summary can be linked to each contract instance. This approach has the advantage of precisely linking the ERCs supported by each instance, but the drawback that the auditor must sign multiple times. Also, since a contract's behavior depends on the chain it is deployed on, the chainId and deployment address are recorded together, and the scope is limited to audits of EVM-based smart contracts so the parameters can be better defined.
Key disclosure and the proxy problem
As a way to link a signing key to a specific auditor, the spec states that the auditor must disclose the public part of the signature on their own website, professional page, social media, etc. Building a public registry is possible as an extension but is out of scope for this ERC. Polymorphic (upgradeable) contracts and proxies are not explicitly addressed by this ERC, and their proper handling is left to auditors and implementers. Support for non-EVM chains, multi-contract audits, improved support for polymorphic contracts, auditor key management, and defining findings remain future extension work.
Reference implementation and proposal status
There is no reference implementation yet (TBD). A script to produce signatures from a JSON containing the audit summary, and a contract to verify signed audit summaries, are planned to be implemented. This proposal is in Draft status, an early-stage proposal whose content may change or whose progress may stall.
Things to watch out for
- Auditor key management: This ERC assumes correct key management by participating auditors. If an auditor's key is leaked, a contract that actually fails to meet the standard could appear to be audited and ERC-compliant. As a protective measure, defining a federation of auditors (e.g., an audit firm) so that a backup key can revoke existing signatures in the event of a key leak is mentioned.