Smart contract bugs / 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.
8 real exploits · $1.5M lost
How the attack works
- A function accepts a signature for an action: a withdrawal, a permit, a meta-transaction, a bridge release.
- The signed data has no nonce, no chain id or no contract address.
- The attacker submits the same signature again, on another chain, or to another deployment of the same contract.
- Variants:
ecrecoverreturnsaddress(0)for a bad signature and the check compares it to an unset signer; malleablesvalues give a second valid signature.
Vulnerable and fixed code
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);
}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 rawecrecover. It rejectsaddress(0)and malleable signatures. - Check that
signeris set and is notaddress(0). - Do not use
abi.encodePackedwith 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)
-
GiddyVaultV3: 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.
Root cause and fix
Vulnerable code:
GiddyVaultV3 · compound()GiddyVaultV3 checks the EIP-712 authorization for compound() using only keccak256(SwapInfo.data). The fields fromToken, toToken, amount and aggregator are not covered by the signature. The attacker reused valid signed data and swapped in their own helper contract as the aggregator and token, with amount set to uint256.max. Each compound call made the strategy approve the helper for uint256.max. The helper then pulled the YieldBasis gauge tokens out of the tBTC, cbBTC and WBTC strategies.
What would have stopped it: Put every field of each SwapInfo (fromToken, toToken, amount, aggregator and the data hash) into the EIP-712 struct hash that is signed. Also whitelist aggregators and never let a strategy approve an arbitrary address for an unlimited amount.
-
LegendaryMoneyMonNft: 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.
Root cause and fix
Vulnerable code:
LegendaryMoneyMonNft · cliamRewred()recoverSigner() returns ecrecover(hash, v, r, s) without rejecting address(0). The owner had earlier called changeadmin() and set admin to address(0). The attacker called cliamRewred() with a 65-byte signature of r=0, s=0, v=27. ecrecover returned address(0), which equals admin, so verify() passed. The contract then sent its whole MON balance to the caller, and the attacker swapped it to USDT on PancakeSwap V3.
What would have stopped it: Revert in recoverSigner when ecrecover returns address(0), or use OpenZeppelin ECDSA.recover. Never allow admin or signer to be set to address(0): add a zero-address check in changeadmin().
-
AzukiDAO (Bean token): AzukiDAO's Bean token lost about $69k because claim() accepted the same signature repeatedly, so the attacker minted Bean many times.
Root cause and fix
Vulnerable code:
Bean token (0x8189AFBE7b0e81daE735EF027cd31371b3974FeB) · claim()The claim() function in the Bean token checks a signature over the sender, contracts, token IDs, claim amount and end time. It does not record that a signature has been used, and it has no nonce. The attacker took one valid signature and called claim() with the same arguments 200 times in the PoC. Each call paid out 31,250 Bean, and more calls were possible.
What would have stopped it: Put a unique nonce or claim ID in the signed message and mark it as used on-chain before paying out. Also track claimed amounts per user or per token ID, and add a test that calls claim() twice with the same signature and expects the second call to revert.
-
Argent-style smart wallet (wallets 0xe545 and 0x5a79): 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.
Root cause and fix
Vulnerable code:
Execution module 0x4e50adfc953551286bbd7fee2b2b846d1d227394 and recovery module 0xf490557d67d934440677a4f16793d5ef319b8ef5 · execute(address,bytes,uint256,bytes,uint256,uint256)The relay entry point execute() recovers the owner and guardian signature but never consumes a nonce and never records the signed-message hash. It also does not enforce the signed deadline, and that deadline overflows. Signatures from 2020 and 2021 therefore still pass and anyone can resubmit them. The recovery-deadline setter (selector 0x254a2e49) takes an attacker-supplied period that wraps the deadline into the past, so executeRecovery and finalizeRecovery change the owner in one transaction. The attacker flash-borrowed WETH from Balancer and replayed the swap signature many times. Each replay made the wallet buy MARK in a thin MARK/WETH pool at a price the attacker had pushed up, and the attacker sold the MARK back for profit. The same loop was repeated on the second wallet.
What would have stopped it: Make every relayed signature single-use: include a nonce or the wallet's own sequence number in the signed hash, and increment it or store the hash as used. Enforce the deadline with checked arithmetic and bounds on any caller-supplied period, and bind each signature to the chain, the module and the intended action.
-
TCH: 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.
Root cause and fix
Vulnerable code:
TCH token (0x5d78CFc8732fd328015C9B73699dE9556EF06E8E) · burnToken()The burnToken(amount, nonce, signature) function checked a signature that could be altered without invalidating it. The attacker took valid signatures from earlier burn transactions and changed the last byte (v from 0x1c to 0x01, or 0x1b to 0x00). The contract treated these as new valid signatures, probably because replay protection used the signature bytes and not the nonce. The attacker flash-loaned 2.5M BUSDT, bought TCH, replayed 34 tampered burns to cut the TCH supply in the pair and raise its price, then sold TCH back for BUSDT and repaid the loan.
What would have stopped it: Track used nonces or the signed message hash, not the signature bytes. Use OpenZeppelin ECDSA, which rejects malleable signatures (high s and non-canonical v). Do not let a signed burn change the balance of an AMM pair.
-
Unverified (unnamed proxy/implementation): 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.
Root cause and fix
Vulnerable code:
0x8Fd3d01Cc65eA0E4dFFFde7Ec8159Dc99a177f0A · unknown selector 0x97e76253The implementation verified a signature over keccak256(abi.encodePacked(timeBucket, recipient)). The signed message did not include the victim, token, amount, caller, proxy, chain or a nonce. The attacker called the proxy selector 0x97e76253 with a victim address, a recipient and a valid signature. The contract read the victim's full USDT balance and moved it to the recipient with transferFrom, using the victim's allowance to the proxy. The same signature could be reused for any victim who had approved the proxy during that 5-minute window.
What would have stopped it: Sign a full structured message (EIP-712) that binds the victim, token, amount, recipient, caller, contract address, chain id, nonce and deadline. Mark each nonce as used so a signature cannot be replayed against other accounts.
-
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.
Root cause and fix
Vulnerable code:
Lixir vault tokens (e.g. 0xfD4c9a491DD777b8b3e13659e9E379252eC78390) · permit()The permit() function in the Lixir vault tokens accepted any signature as long as ecrecover returned a nonzero address. It did not check that the recovered address equals the owner. The attacker passed a fixed dummy v/r/s to permit() for each holder, which gave the attacker's contract an allowance for the holder's full vault-token balance. The attacker then called withdrawETHFrom() or withdrawFrom() to redeem those shares for the underlying assets, across six vaults.
What would have stopped it: In permit(), require that the address recovered by ecrecover is nonzero and equals the owner, and include a nonce, deadline and domain separator in the signed digest. Use a well-tested implementation such as OpenZeppelin ERC20Permit, and add tests that a random signature is rejected.
-
BEGO: BEGO token on BNB Chain lost about 12 BNB because mint() accepted empty signature arrays as valid authorization.
Root cause and fix
Vulnerable code:
BEGO token (0xc342774492b54ce5F8ac662113ED702Fc1b34972) · mint()The mint() function is meant to require validator signatures (arrays of r, s, v), but it does not enforce a minimum number of valid signatures. The attacker passed empty _r, _s and _v arrays, so the signature check had nothing to fail and mint() succeeded. The attacker minted 1 trillion BEGO to themselves and swapped it for WBNB on PancakeSwap, which drained the liquidity pool.
What would have stopped it: Require that the number of verified, distinct signers is at least a set threshold, and revert if the signature arrays are empty or their lengths differ. Add tests that call mint() with empty and malformed signature arrays.