Toutes les vulnérabilités
CRITICALWeb3

WEB3-SIG-REPLAY-2022

Web3 · Ethereum · ECDSA signature verification (EIP-155 / EIP-712)

Résumé

Signature replay occurs when a signed message lacks binding context (nonce, chainId, or an EIP-712 domain separator), so a signature valid for one execution can be re-submitted on another call or another EVM chain. The canonical 2022 case is the Optimism/Wintermute loss of 20,000,000 OP tokens disclosed June 9, 2022: Wintermute provided a Gnosis Safe address deployed on Ethereum mainnet but not on Optimism. Because the Gnosis Safe factory's original deployment transaction used a pre-EIP-155 signature, its hash covered only six RLP fields (nonce, gasPrice, gas, to, value, data) and omitted chainId, so anyone could rebroadcast the identical signed transaction on Optimism. An attacker replayed that deployment to recreate the factory and Safe at the same counterfactual address on L2, gained control of the contract account before the rightful owners, and swept the 20M OP. The same low-level flaw appears in application contracts that ecrecover a digest missing nonce/chainId, letting one signed approval be replayed repeatedly.

Comment l’éviter dans votre code

  • Hash chainId, a per-account incrementing nonce, and the verifying contract address into every signed digest.
  • Use EIP-712 typed-data hashing with a full domain separator (name, version, chainId, verifyingContract).
  • Mark each signature consumed (a mapping of used digests) to block same-chain replay.
  • Recompute the domain separator if block.chainid changes to survive forks.
  • Reject malleable or non-EIP-155 signatures and constrain the signature's v value to canonical values.

Références

Vulnérabilités liées

Tout Web3 →