erc1271-contract-signatures

Solid

Detect ERC-1271 contract-signature bugs — magic-value handling, signature validation edge cases, smart-wallet interactions (Safe, Argent), replay-via-signature-update. Activate on `isValidSignature`, ERC1271 imports, smart-wallet integration, signed orders that may originate from contracts.

AI & Automation 38 stars 5 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
53
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# ERC-1271 contract signatures detection ## Background ERC-1271 lets contract accounts (smart wallets, multisigs) sign messages. Verification call: ```solidity IERC1271(signer).isValidSignature(hash, sig) returns (bytes4 magicValue); // magicValue must equal 0x1626ba7e ``` Without ERC-1271, smart-wallet users can't sign anything (no private key). ## When this applies - Off-chain order signing (Seaport, Blur, X2Y2) - Permit2 with smart-wallet senders - EIP-712 verification paths - Any `ecrecover(...) == signer` check that might accept contract signers ## Detection patterns ### Bypass via `ecrecover` for smart wallet (HIGH) ```solidity require(ecrecover(hash, v, r, s) == signer, "bad sig"); // ← signer is a smart wallet, ecrecover returns address(0), check fails legitimately ``` The bug: contract owners can't sign at all. Add an ERC-1271 fallback: ```solidity if (signer.code.length > 0) { require(IERC1271(signer).isValidSignature(hash, abi.encodePacked(r, s, v)) == 0x1626ba7e); } else { require(ecrecover(hash, v, r, s) == signer); } ``` ### Wrong magic value check (HIGH) ```solidity require(IERC1271(signer).isValidSignature(hash, sig) == 0x1626ba7c); // ← typo: should be 0x1626ba7e ``` ### Pre-EIP-1271 magic value (HIGH) Some old impls return `0x20c13b0b` (the legacy bytes-based variant). Spec is hash-based `0x1626ba7e`. Mixing → reject valid sigs. ### Replay via signature-update on smart wallet (HIGH) A Safe's `isValidSignature` checks owner approvals. If s...

Details

Author
iktok90-design
Repository
iktok90-design/ai-smart-contract-auditor
Created
1 weeks ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category