{"id":21307843,"url":"https://github.com/solidstate-network/diamond-storage-preimage-attack","last_synced_at":"2026-05-14T23:04:05.223Z","repository":{"id":189823315,"uuid":"681327696","full_name":"solidstate-network/diamond-storage-preimage-attack","owner":"solidstate-network","description":"Proof-of-concept of a diamond storage preimage attack 💎 💥","archived":false,"fork":false,"pushed_at":"2023-08-21T23:43:51.000Z","size":134,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-15T22:03:24.212Z","etag":null,"topics":["diamond","eth","ether","ethereum","evm","harhat","keccak","keccak256","preimage","proxy","wow"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solidstate-network.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-21T19:11:29.000Z","updated_at":"2023-10-18T14:24:55.000Z","dependencies_parsed_at":"2023-08-21T23:27:35.955Z","dependency_job_id":"eedc7533-c489-4670-b848-e850e67da394","html_url":"https://github.com/solidstate-network/diamond-storage-preimage-attack","commit_stats":null,"previous_names":["solidstate-network/diamond-storage-preimage-attack"],"tags_count":0,"template":false,"template_full_name":"solidstate-network/hardhat-template","purl":"pkg:github/solidstate-network/diamond-storage-preimage-attack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidstate-network%2Fdiamond-storage-preimage-attack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidstate-network%2Fdiamond-storage-preimage-attack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidstate-network%2Fdiamond-storage-preimage-attack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidstate-network%2Fdiamond-storage-preimage-attack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solidstate-network","download_url":"https://codeload.github.com/solidstate-network/diamond-storage-preimage-attack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidstate-network%2Fdiamond-storage-preimage-attack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274907865,"owners_count":25371821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diamond","eth","ether","ethereum","evm","harhat","keccak","keccak256","preimage","proxy","wow"],"created_at":"2024-11-21T16:34:36.335Z","updated_at":"2026-05-14T23:04:05.177Z","avatar_url":"https://github.com/solidstate-network.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Diamond Storage Preimage Attack\n\nProof-of-concept of a diamond storage preimage attack.\n\n## Description\n\nThis attack can be executed by crafting a particular seed string for the purpose of calculating a diamond storage slot. This seed consists of 64 bytes and can be thought of as a string composed of two 32-byte substrings.\n\nThe first of these substrings (substring A) is human-readable:\n\n```solidity\n'diamond.storage.thirtytwobytestr'\n```\n\nHere's its hex representation:\n\n```solidity\n0x6469616d6f6e642e73746f726167652e74686972747974776f62797465737472\n```\n\nThe second substring (substring B) is composed of zero-bytes and therefore has no valid string representation:\n\n```solidity\n0x0000000000000000000000000000000000000000000000000000000000000000\n```\n\nThe 64-byte seed is hashed, and the result is used as the storage slot for a diamond storage struct.\n\nNow, a mapping is defined at storage slot 0, matching the value of substring B. Accessing this mapping using substring A as a key is equivalent to accessing the diamond storage struct due to [the way mapping storage slots are calculated](https://docs.soliditylang.org/en/v0.8.21/internals/layout_in_storage.html#mappings-and-dynamic-arrays).\n\n## Instructions\n\nInstall dependencies via Yarn:\n\n```bash\nyarn install\n```\n\nCompile contracts via Hardhat:\n\n```bash\nyarn run hardhat compile\n```\n\nRun the tests to demonstrate the attack:\n\n```bash\nyarn run hardhat test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidstate-network%2Fdiamond-storage-preimage-attack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolidstate-network%2Fdiamond-storage-preimage-attack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidstate-network%2Fdiamond-storage-preimage-attack/lists"}