signature-malleability
Skill36 starsChanged 5 months agoMITView on GitHub
Detect ECDSA signature malleability and ecrecover pitfalls — missing low-s (EIP-2) enforcement, unconstrained v, unchecked address(0) from ecrecover, replay across chainId/contract from a missing EIP-712 domain separator, EIP-2098 compact-signature confusion, and signature reuse. Activate whenever code calls ecrecover directly, parses (r,s,v) from bytes, or verifies signed messages without OpenZeppelin ECDSA.
In this repository44 other files it gives its agents.
- access-controlSkill
- approval-issuesSkill
- caching-and-incrementalSkill
- centralization-riskSkill
- confidence-scoringSkill
- cosmwasmSkill
- cross-chain-messagingSkill
- cross-contract-stateSkill
- delegatecall-risksSkill
- diamond-eip2535Skill
- dos-vectorsSkill
- erc1271-contract-signaturesSkill
- erc4337-account-abstractionSkill
- erc4626-inflationSkill
- false-positive-feedback-loopSkill
- fee-on-transferSkill
- flash-loan-attacksSkill
- initializationSkill
- inline-assemblySkill
- integer-issuesSkill
- intents-erc7683Skill
- known-good-comparisonSkill
- liquidation-cascadeSkill
- mev-frontrunningSkill
- mev-pbsSkill
- multi-pass-self-critiqueSkill
- oracle-manipulationSkill
- oracle-redundancySkill
- permit2-patternsSkill
- pragma-and-addressesSkill
- progress-and-streamingSkill
- reentrancySkill
- restaking-eigenlayerSkill
- selfdestruct-eip6780Skill
- signature-replaySkill
- solana-anchorSkill
- storage-layoutSkill
- stylus-rustSkill
- token-compatibilitySkill
- tx-context-misuseSkill
- unchecked-callsSkill
- ve-lock-governanceSkill
- vyper-specificSkill
- zk-verifier-bugsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
Signal: no EIP-712 domain separator binding chainId and verifyingContract.
- Very specific: line 64
Prefer SignatureChecker when signers may be ERC-1271 contract wallets.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Signature malleability detection
When this applies
Trigger on any of:
- Direct
ecrecover(hash, v, r, s)calls (not via OpenZeppelinECDSA.recover) - Manual
(r, s, v)decoding from abytessignature with assembly - Permit / meta-tx / order-book / claim flows that verify a signed digest
- Signatures used as nonces or dedup keys (e.g.
usedSig[sig] = true) - EIP-712 typed-data verification, or its absence where one is needed
Detection patterns
Missing low-s enforcement / malleable sig (HIGH if sig is a key)
address signer = ecrecover(hash, v, r, s); // no s-range check
require(signer == expected);
usedSignature[keccak256(abi.encode(r,s,v))] = true; // ← dedup keyed on sig bytesSignal: for any valid (r,s,v) the "flipped" signature (r, n - s, v ^ 1) recovers the same signer (the classic Bitcoin/Ethereum transaction-malleability class). If the signature itself is the replay key, an attacker submits the twin and bypasses dedup. Enforce s <= secp256k1n/2 (EIP-2).
Unchecked ecrecover returning address(0) (HIGH)
address signer = ecrecover(hash, v, r, s);
require(signer == owner); // if owner could ever be address(0)... or no check at allSignal: malformed inputs make ecrecover return address(0). Any code path where the compared-against value can be address(0) (uninitialized mapping slot, default) authenticates an attacker with garbage. Always require(signer != address(0)).
Unconstrained v (MEDIUM)
Accepting arbitrary v (not 27/28) or trusting a caller-supplied v for EIP-2098 compact sigs, mixing the 64-byte and 65-byte formats. EIP-2098 packs yParity into the high bit of s; decoding it as a raw 65-byte sig corrupts recovery.
Cross-domain / cross-chain replay (HIGH)
bytes32 digest = keccak256(abi.encode(ORDER_TYPEHASH, maker, amount, nonce));Signal: no EIP-712 domain separator binding chainId and verifyingContract. A signature is replayable on another chain (post-fork) or a sibling deployment. Build the digest with _hashTypedDataV4 (\x19\x01 + domainSeparator + structHash) and recompute the domain separator if block.chainid changes.
Signature reuse / no nonce (HIGH)
Same digest accepted twice because there's no per-signer nonce or no marking of consumed digests — meta-tx and claim flows drain repeatedly.
Severity rubric
| Pattern | Severity | Notes |
| Malleable sig used as replay/dedup key | High | Twin sig bypasses guard |
| ecrecover==address(0) authenticates attacker | High | Auth bypass |
| Missing EIP-712 domain → cross-chain replay | High | Signature reuse across deployments |
| No nonce → straight replay | High | Repeated execution |
| Unconstrained v / EIP-2098 confusion | Medium | Format-dependent |
| Low-s missing but sig never used as a key | Low | Defense-in-depth |
Remediation patterns
- Use OpenZeppelin
ECDSA.recover— it enforcess <= secp256k1n/2, rejects badv, and reverts onaddress(0)(it also handles EIP-2098). - Bind digests with EIP-712 (
EIP712base +_hashTypedDataV4), includingchainIdandverifyingContract; recompute the domain separator on chainid change. - Use per-signer nonces (incrementing) rather than signature-bytes dedup; consume by
(signer, nonce)not(r,s,v). - Explicit
require(signer != address(0))even when using libraries, for any hand-rolled path. - Prefer
SignatureCheckerwhen signers may be ERC-1271 contract wallets.
False-positive notes
- Code already routing through OpenZeppelin
ECDSA/SignatureCheckerwith EIP-712 and nonces is safe — don't re-flag the underlyingecrecover. - A sig verified against a non-zero, always-set signer where the digest is never reused is malleability-tolerant; note, don't escalate.
Related
- [[signature-replay]] — nonce/chainId replay is the sibling concern
- [[erc1271-contract-signatures]] — smart-wallet signers need
isValidSignature - [[permit2-patterns]] — Permit2 / EIP-2612 digests and nonces
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

