diamond-eip2535

Solid

Detect Diamond (EIP-2535) bugs — facet selector collisions, init-vs-upgrade safety, storage-namespace collisions, facet selfdestruct paths, missing facet cuts. Activate on Diamond imports, DiamondCut, IDiamondLoupe, IDiamondCut, LibDiamond, facet patterns.

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

# Diamond (EIP-2535) detection ## When this applies - Any contract using EIP-2535 Diamond Standard - Custom multi-facet upgradeable systems - Frameworks: Nick Mudge's diamond-1, Diamond Industries' SoliState, custom diamond impls ## Detection patterns ### Function-selector collision (CRITICAL) Two facets implementing the same 4-byte selector (e.g. `function foo()` and `function bar(uint256)` that hash to the same selector). Diamond routes to the last-cut facet, but during a cut, the *old* version may be reachable. - Required: precompute selector mapping at deploy + verify uniqueness; rerun at every diamond-cut. ### Storage namespace collision (CRITICAL) Two facets using the same `bytes32 STORAGE_POSITION` slot prefix. ```solidity library LibA { bytes32 constant POS = keccak256("auditsentry.a"); } library LibB { bytes32 constant POS = keccak256("auditsentry.a"); } // ← collision ``` Use unique namespace strings per facet. ### Init-vs-upgrade confusion (HIGH) Diamond init runs once via `delegatecall` to an Init contract. Re-running init after diamond-cut → can re-initialize values or run dangerous code. See [[initialization]]. ### `diamondCut` access control (CRITICAL) ```solidity function diamondCut(FacetCut[] calldata cuts, address init, bytes calldata data) external { // ← no owner check } ``` Anyone can add/remove/replace facets. ### Removing facet without removing selectors (HIGH) Facet contract removed from blockchain (selfdestructed pre-6780, or simply deau...

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