Signature Replay Attack in Solidity 0.6: Prevention Techniques

Added:

Replay Attack Basics
Attack Scenarios
Prevention Methods
Vulnerable Contract
Implementing Fixes
Final Protection

Replay Attack Basics

0:00
Playing Section
  • 1

    Explains how one signature can execute multiple transactions.

  • 2

    Uses a multisig wallet example to illustrate the vulnerability.

Fundamentals of asymmetric cryptography, specifically how ECDSA (Elliptic Curve Digital Signature Algorithm) works in Ethereum.
Understanding the role and mechanics of the `ecrecover` precompiled contract in Solidity to verify off-chain signatures.
Basic proficiency in Solidity 0.6 syntax, state variables, and transaction execution flow.
The concept of off-chain message signing and why it is used for gas-less transactions or meta-transactions.
Implementing the EIP-712 standard for hashing and signing typed structured data to prevent signature spoofing.
Exploring ERC-1271 to support signature validation for smart contract wallets (such as Gnosis Safe).
Preventing cross-chain and cross-contract replay attacks by integrating `chainId` and the contract's own deployment address into the hash.
Utilizing industry-standard libraries like OpenZeppelin's `ECDSA.sol` and `draft-EIP712.sol` to safely abstract signature verification logic.
11.1K views282likes10:54@smartcontractprogrammerOriginal Release: 2020-09-20

A signature replay attack occurs when an attacker reuses the same digital signature to execute a transaction multiple times against a smart contract, potentially causing unintended repeated actions. This attack exploits the fact that signatures alone do not guarantee transaction uniqueness. Three scenarios enable replay attacks: (1) on the same contract, (2) on the same code deployed at different addresses, and (3) on contracts deployed with CREATE2 that have self-destruct functionality. Prevention requires including a unique nonce in the transaction hash and tracking executed transactions in a mapping within the contract, ensuring each signature can only be used once.