---
title: "Signature replay and forgery"
url: https://dontgetrekt.today/dev/signature-replay
section: "Who can call it?"
---

# Signature replay and forgery

The contract accepts a signed message but does not check the nonce, the chain, the contract or the deadline. The attacker uses one signature many times, or a signature that recovers to address zero.

## How the attack works

1. A function accepts a signature for an action: a withdrawal, a permit, a meta-transaction, a bridge release.
2. The signed data has no nonce, no chain id or no contract address.
3. The attacker submits the same signature again, on another chain, or to another deployment of the same contract.
4. Variants: `ecrecover` returns `address(0)` for a bad signature and the check compares it to an unset signer; malleable `s` values give a second valid signature.

## Vulnerable code

```solidity
function claim(uint256 amt, bytes memory sig) external {
    bytes32 h = keccak256(abi.encodePacked(msg.sender, amt)); // no nonce, chain, contract
    address s = ecrecover(toEthSigned(h), v(sig), r(sig), s_(sig));
    require(s == signer);           // signer unset => address(0) passes
    token.transfer(msg.sender, amt);
}
```

## Fixed code

```solidity
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

bytes32 constant CLAIM = keccak256("Claim(address to,uint256 amt,uint256 nonce,uint256 deadline)");

function claim(uint256 amt, uint256 deadline, bytes calldata sig) external {
    require(block.timestamp <= deadline, "expired");
    bytes32 digest = _hashTypedDataV4(keccak256(
        abi.encode(CLAIM, msg.sender, amt, nonces[msg.sender]++, deadline)));
    require(ECDSA.recover(digest, sig) == signer, "bad sig"); // reverts on address(0)
    token.transfer(msg.sender, amt);
}
```

## Review checklist

- Use EIP-712 typed data. The domain includes the chain id and the contract address.
- Include a nonce that you increase on use, and a deadline.
- Use OpenZeppelin `ECDSA.recover`, not raw `ecrecover`. It rejects `address(0)` and malleable signatures.
- Check that `signer` is set and is not `address(0)`.
- Do not use `abi.encodePacked` with two or more dynamic types in a hash: different inputs give the same hash.

## How to test for it

- Submit the same signature twice. The second call must revert.
- Submit a signature made for another chain id and another contract address.

## Real exploits (8)

- 2026-04-23 GiddyVaultV3 ($1.3M): GiddyVaultV3 lost about $1.3M on Ethereum because its EIP-712 compound authorization signed only the swap calldata hash, so an attacker could change the tokens, amount and aggregator. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-04/giddyvaultv3_compound_auth_exp.sol)
- 2026-05-28 LegendaryMoneyMonNft ($86K): LegendaryMoneyMonNft on BNB Chain lost about $85.5K (MON swapped to USDT) because ecrecover returning address(0) matched an admin that had been set to the zero address. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-05/LegendaryMoneyMonNft_exp.sol)
- 2023-07-03 AzukiDAO (Bean token) ($69K): AzukiDAO's Bean token lost about $69k because claim() accepted the same signature repeatedly, so the attacker minted Bean many times. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2023-07/AzukiDAO_exp.sol)
- 2026-10-19 Argent-style smart wallet (wallets 0xe545 and 0x5a79) ($51K): An Argent-style smart wallet lost about $50.7K USDC (SlowMist reported about $59.8K) because its relay module accepted old owner and guardian signatures again, and a deadline overflow let an attacker change the owner. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-10/Argent_exp.sol)
- 2024-05-16 TCH ($18K): TCH token on BNB Chain lost about $18K because burnToken() accepted malleable signatures that were replayed to burn tokens from the pool and distort its price. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-05/TCH_exp.sol)
- 2025-07-17 Unverified (unnamed proxy/implementation) ($502): An unverified BNB Chain proxy contract lost 502.42 USDT because its signature covered only a 5-minute time bucket and the recipient, so a victim's approved USDT could be drained. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2025-07/unverified_8fd3_exp.sol)
- 2026-06-25 Lixir: Lixir vault tokens lost about 2.60 ETH, 4,477.72 USDC, 3,609.95 USDT and 24,182.56 LIX because permit() accepted a dummy signature. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-06/LixirPermitDrain_exp.sol)
- 2022-10-20 BEGO: BEGO token on BNB Chain lost about 12 BNB because mint() accepted empty signature arrays as valid authorization. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-10/BEGO_exp.sol)

## References

- [SWC-121: Missing protection against signature replay](https://swcregistry.io/docs/SWC-121/)
- [SWC-117: Signature malleability](https://swcregistry.io/docs/SWC-117/)
- [EIP-712: Typed structured data](https://eips.ethereum.org/EIPS/eip-712)
- [OpenZeppelin: ECDSA](https://docs.openzeppelin.com/contracts/5.x/api/utils/cryptography#ECDSA)
