signature-replay
하는 일
이 플레이북은 스마트 컨트랙트의 서명 메시지, 퍼밋, 메타 트랜잭션 검토를 안내합니다. 서명으로 동작을 승인하는 감사자와 개발자를 위한 스킬입니다.
사용하는 경우
- ✓컨트랙트가 서명된 승인, 퍼밋, 메타 트랜잭션을 받을 때.
- ✓한 블록체인을 위한 서명이 다른 블록체인에서도 쓰일 수 있을 때.
- ✓컨트랙트가 이미 사용된 서명을 추적하지 않고 서명을 검사하는 경우.
스킬 링크
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/signature-replay/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 퍼밋 서명이 두 번 쓰이거나 다른 체인에서 재사용될 수 있는지 확인해 주시겠어요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 각 서명 메시지에 nonce와 체인 ID가 있는지, 복구된 서명자가 0 주소일 수 있는지 확인한 뒤, 테스트로 결과를 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
nonce란 무엇인가요?
각 서명 메시지를 한 번만 쓸 수 있게 하는 일회용 숫자입니다.
체인 ID가 왜 중요한가요?
체인 ID가 없으면 한 블록체인에서 유효한 서명이 다른 블록체인에서 재전송될 수 있습니다.
권장되는 방법은 무엇인가요?
도메인에 체인 ID를 포함하는 EIP-712 타입 데이터 표준을 사용하라고 플레이북은 권합니다.
상세 정보
작성자의 원본 설명
Signature replay attacks — missing nonces, missing chain ID, ecrecover zero address, signature malleability, cross-chain replay.
인기도
- GitHub 스타
- 6.5k
- 순위
- #14012
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
detector-overview
6.5k에이전트가 스캐너가 표시한 코드를 읽고, 표시된 곳 중 어디가 실제 보안 버그이고 어디가 오탐인지 판단하도록 돕습니다.
exploiter-overview
6.5k에이전트가 확인된 여러 보안 약점을 하나의 테스트 체인으로 묶고, 그 체인이 어디까지 닿을 수 있는지 확인하도록 돕습니다.
llm-redteam-overview
6.5k에이전트가 프롬프트 인젝션부터 모델 악용까지 15개 전술 그룹 중 테스트에 맞는 AI 레드팀 가이드를 찾도록 돕습니다.
aatmf-t01-prompt-injection
6.5k숨겨진 지시가 AI 시스템을 덮어쓰려 하는 프롬프트 인젝션을 설명해, 보안 테스터가 이를 점검할 수 있게 합니다.