signature-replay
What it does
This playbook guides a review of signed messages, permits and meta-transactions in smart contracts. It is for auditors and developers who use signatures to authorize actions.
When to use it
- βWhen a contract accepts signed approvals, permits or meta-transactions.
- βWhen a signature is meant for one blockchain but could be used on another.
- βWhen a contract checks signatures without tracking which ones were already used.
Skill link
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/signature-replay/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCan you check whether our permit signatures could be reused, either twice or on another chain?β
5 new skills a week. 1 minute to read.
How it works
The agent checks whether each signed message includes a nonce and chain ID, and whether the recovered signer can be the zero address, then confirms with a test.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Signature Replay Playbook
EIP-712 signatures, permits, meta-transactions, and cross-chain bridges
all use ecrecover (or its variants). Each has well-known bugs.
Bug classes
1. Missing nonce β replay
function execute(uint256 amount, bytes calldata sig) external {
bytes32 h = keccak256(abi.encodePacked(msg.sender, amount));
address signer = ecrecover(h, ...);
require(signer == owner);
// ... withdraw amount
}
A valid signature can be replayed forever β anyone who saw it once can re-submit it. Fix: include a per-user / per-message nonce:
mapping(address => uint256) public nonces;
function execute(uint256 amount, uint256 nonce, bytes calldata sig) external {
require(nonce == nonces[msg.sender]);
nonces[msg.sender]++;
bytes32 h = keccak256(abi.encodePacked(msg.sender, amount, nonce));
// ...
}
2. Missing chain ID β cross-chain replay
A signature valid on Ethereum mainnet shouldn't work on Optimism, Base,
Arbitrum, etc. If chainid() not in the signed payload, signatures
replay across chains:
// VULNERABLE
bytes32 h = keccak256(abi.encodePacked(amount, deadline, nonce));
// SAFE β EIP-712 domain separator includes chainid
bytes32 h = _hashTypedDataV4(...); // OZ helper
This is especially bad for bridges β a signed message intended for chain A executes on chain B.
3. Signature malleability (ecrecover variants)
ecrecover accepts two valid s values for any signed message
(s and -s mod n). This means each signature has two valid forms.
If your contract uses the signature itself as a uniqueness key
(e.g., usedSigs[sig] = true), an attacker can find the malleable
version and bypass:
// VULNERABLE β uses sig as uniqueness key
mapping(bytes => bool) public used;
function execute(bytes calldata sig) external {
require(!used[sig]);
used[sig] = true;
address signer = ecrecover(...);
// ...
}
Fix: use the message hash (not the signature) as uniqueness key.
Modern OZ ECDSA library rejects high-s values, but home-rolled
ecrecover does not.
4. ecrecover zero address on invalid sig
address signer = ecrecover(h, v, r, s);
if (signer == owner) { /* approve */ }
Bug: if (v,r,s) is invalid, ecrecover returns address(0). If
owner is somehow address(0) (uninitialized!) β any malformed
signature works.
Fix: require(signer != address(0)).
5. Domain separator without chainid
EIP-712 domain separator should bind to the chain. If a protocol
caches DOMAIN_SEPARATOR in storage at deployment, hard-forks (which
change chainid) break it. OZ's EIP712 handles this; custom code often
doesn't.
// VULNERABLE β cached at deploy
bytes32 immutable DOMAIN_SEPARATOR = keccak256(abi.encode(
keccak256("EIP712Domain(...)"),
keccak256(bytes("Name")),
keccak256(bytes("1")),
1, // β hardcoded chainid
address(this)
));
// SAFE β re-derive when chainid changes
function _domainSeparator() internal view returns (bytes32) {
return keccak256(abi.encode(..., block.chainid, ...));
}
6. Permit signature replay across forks / hard forks
ERC2612 permit is meta-tx for ERC20 approvals. If permit doesn't
include the EIP-712 domain separator correctly, it can be replayed on:
- Forked test chains
- L2s that copied the contract
- Hard forks (ETC, ETHW)
This is mostly resolved by OZ ERC20Permit, but custom permit impls are often wrong.
7. Replay across function selectors
A signed payload keccak256(amount, recipient) is the same regardless
of which function it authorizes. If two functions share the same
hash structure but different effects, the signature replays:
function withdraw(uint256 amt, address to, bytes sig) external {
bytes32 h = keccak256(abi.encodePacked(amt, to));
address s = ecrecover(h, ...);
require(s == owner);
payable(to).transfer(amt);
}
function mint(uint256 amt, address to, bytes sig) external {
bytes32 h = keccak256(abi.encodePacked(amt, to)); // SAME HASH
address s = ecrecover(h, ...);
require(s == owner);
_mint(to, amt);
}
// A withdraw signature works for mint, and vice versa
Fix: include function selector or unique typeID in the signed payload.
Audit steps
1. Find every ecrecover
grep -rn 'ecrecover\|ECDSA.recover\|recover(' src/
2. For each call site, verify the payload contains
- A nonce (or other per-user unique
FAQ
What is a nonce?
A one-time number that makes each signed message usable only once.
Why does the chain ID matter?
Without it, a signature valid on one blockchain can be replayed on another.
What is the recommended approach?
Use the EIP-712 typed-data standard, which includes the chain ID in its domain.
Details
Original description by the author
Signature replay attacks β missing nonces, missing chain ID, ecrecover zero address, signature malleability, cross-chain replay.
Popularity
- GitHub stars
- 6.5k
- Ranking position
- #14012
- License
- Apache-2.0
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
detector-overview
6.5kHelps your agent read code that a scanner flagged and decide which flagged spots are real security bugs and which are false alarms.
exploiter-overview
6.5kHelps your agent join several confirmed security weaknesses into one test chain and check how far that chain could reach.
llm-redteam-overview
6.5kHelps your agent find the right AI red-team guide for a test, covering 15 tactic groups from prompt injection to model abuse.
aatmf-t01-prompt-injection
6.5kExplains prompt injection, where hidden instructions try to override an AI system, so security testers can check for it.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.