{"id":8737,"date":"2025-02-19T11:53:27","date_gmt":"2025-02-19T10:53:27","guid":{"rendered":"https:\/\/wsj-crypto.com\/?p=8737"},"modified":"2025-02-19T11:53:27","modified_gmt":"2025-02-19T10:53:27","slug":"beware-solidity-storage-vulnerability-your-variables-might-be-at-risk","status":"publish","type":"post","link":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/","title":{"rendered":"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk"},"content":{"rendered":"<p><\/p>\n<div id=\"\">\n<p class=\"chakra-text css-gi02ar\"><strong>Overview:<!-- --><\/strong> In certain circumstances, variables may overwrite others in storage.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\"><strong>Affected versions of Solidity compiler: <!-- --><\/strong>0.1.6 up to 0.4.3 (inclusive of 0.4.4 pre-release versions)<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\"><strong>In-depth explanation:<!-- --><\/strong><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Storage variables smaller than 256 bits are grouped within the same 256 bit slot if they can fit together. When a value exceeding the allowed range of the type is assigned to the first variable, that value overwrites the subsequent variable.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Consequently, if an adversary manages to induce an overflow in the value of the first variable, the second variable could be altered. An overflow can be triggered in the first variable through arithmetic operations or by directly supplying a value from the call data (as call data values align to 32 bytes, padding is not checked or enforced).<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Contracts exclusively utilizing the types specified below for state variables are <!-- --><strong>not<!-- --><\/strong> impacted. Arrays, mappings, and structs (constructed from those specified types) are also <!-- --><strong>not<!-- --><\/strong> impacted:<!-- --><\/p>\n<p><!-- --><\/p>\n<ul role=\"list\" class=\"css-1onhfjo\">\n<li class=\"css-cvpopp\">signed integers, including those smaller than 256 bits<!-- --><\/li>\n<li class=\"css-cvpopp\">bytesNN types, including those smaller than 256 bits<!-- --><\/li>\n<li class=\"css-cvpopp\">unsigned integers (uint) of 256 bits<!-- --><\/li>\n<\/ul>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Contracts comprising types smaller than 256 bits that are never adjacent to one another (it should be noted that state variables from base contracts are &#8220;pulled in&#8221;) are <!-- --><strong>not<!-- --><\/strong> affected.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">The Ethereum multisignature wallet contract remains <!-- --><strong>not<!-- --><\/strong> affected.<br \/>\nIt\u2019s important to note that addresses consume 160 bits, which means contracts that solely utilize addresses and 256-bit types are secure. Furthermore, addresses and booleans are rarely manipulated through arithmetic in practice, so contracts using only addresses, booleans, and 256-bit types should also be deemed secure.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">The following contracts might be at risk:<br \/>\nContracts containing two or more adjacent state variables whose total size is less than 256 bits, where the first state variable is neither a signed integer nor of bytesNN type.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Types smaller than 256 bits encompass:<br \/>\nbool, enums, uint8, &#8230;, uint248, int8, &#8230;, int248, address, any contract type<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\"><strong>Suggested measures:<!-- --><\/strong><\/p>\n<p><!-- --><\/p>\n<ul role=\"list\" class=\"css-1onhfjo\">\n<li class=\"css-cvpopp\">Recompile contracts that are not yet deployed using at least Solidity version 0.4.4 (excluding pre-release or nightly versions).<!-- --><\/li>\n<li class=\"css-cvpopp\">Deactivate, withdraw funds from, or upgrade already deployed contracts.<!-- --><\/li>\n<\/ul>\n<p>This vulnerability was discovered by [github.com\/catageek](https:\/\/github.com\/catageek): [https:\/\/github.com\/ethereum\/solidity\/issues\/1306](https:\/\/github.com\/ethereum\/solidity\/issues\/1306)<!-- --><\/div>\n<p><br \/>\n<br \/><a href=\"https:\/\/blog.ethereum.org\/en\/2016\/11\/01\/security-alert-solidity-variables-can-overwritten-storage\">Source reference <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview: In certain circumstances, variables may overwrite others in storage. Affected versions of Solidity compiler: 0.1.6 up to 0.4.3 (inclusive of 0.4.4 pre-release versions) In-depth explanation: Storage variables smaller than 256 bits are grouped within the same 256 bit slot if they can fit together. When a value exceeding the allowed range of the type<\/p>\n","protected":false},"author":3,"featured_media":8282,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[1353],"class_list":["post-8737","post","type-post","status-publish","format-standard","has-post-thumbnail","category-ethereum","tag-return-a-list-of-comma-separated-tags-from-this-title-security-alert-solidity-variables-can-be-overwritten-in-storage"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk - WSJ-Crypto<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk - WSJ-Crypto\" \/>\n<meta property=\"og:description\" content=\"Overview: In certain circumstances, variables may overwrite others in storage. Affected versions of Solidity compiler: 0.1.6 up to 0.4.3 (inclusive of 0.4.4 pre-release versions) In-depth explanation: Storage variables smaller than 256 bits are grouped within the same 256 bit slot if they can fit together. When a value exceeding the allowed range of the type\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/\" \/>\n<meta property=\"og:site_name\" content=\"WSJ-Crypto\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-19T10:53:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"2100\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"wsjcrypto\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Scritto da\" \/>\n\t<meta name=\"twitter:data1\" content=\"wsjcrypto\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/\",\"url\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/\",\"name\":\"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk - WSJ-Crypto\",\"isPartOf\":{\"@id\":\"https:\/\/wsj-crypto.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\",\"datePublished\":\"2025-02-19T10:53:27+00:00\",\"author\":{\"@id\":\"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7\"},\"breadcrumb\":{\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#primaryimage\",\"url\":\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\",\"contentUrl\":\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\",\"width\":2100,\"height\":900},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wsj-crypto.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wsj-crypto.com\/#website\",\"url\":\"https:\/\/wsj-crypto.com\/\",\"name\":\"WSJ-Crypto\",\"description\":\"Just Another Crypto News Website\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wsj-crypto.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7\",\"name\":\"wsjcrypto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/wsj-crypto.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g\",\"caption\":\"wsjcrypto\"},\"url\":\"https:\/\/wsj-crypto.com\/index.php\/author\/wsjcrypto\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk - WSJ-Crypto","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/","og_locale":"it_IT","og_type":"article","og_title":"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk - WSJ-Crypto","og_description":"Overview: In certain circumstances, variables may overwrite others in storage. Affected versions of Solidity compiler: 0.1.6 up to 0.4.3 (inclusive of 0.4.4 pre-release versions) In-depth explanation: Storage variables smaller than 256 bits are grouped within the same 256 bit slot if they can fit together. When a value exceeding the allowed range of the type","og_url":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/","og_site_name":"WSJ-Crypto","article_published_time":"2025-02-19T10:53:27+00:00","og_image":[{"width":2100,"height":900,"url":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","type":"image\/jpeg"}],"author":"wsjcrypto","twitter_card":"summary_large_image","twitter_misc":{"Scritto da":"wsjcrypto","Tempo di lettura stimato":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/","url":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/","name":"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk - WSJ-Crypto","isPartOf":{"@id":"https:\/\/wsj-crypto.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#primaryimage"},"image":{"@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#primaryimage"},"thumbnailUrl":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","datePublished":"2025-02-19T10:53:27+00:00","author":{"@id":"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7"},"breadcrumb":{"@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/"]}]},{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#primaryimage","url":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","contentUrl":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","width":2100,"height":900},{"@type":"BreadcrumbList","@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/19\/beware-solidity-storage-vulnerability-your-variables-might-be-at-risk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wsj-crypto.com\/"},{"@type":"ListItem","position":2,"name":"Beware! Solidity Storage Vulnerability: Your Variables Might Be at Risk"}]},{"@type":"WebSite","@id":"https:\/\/wsj-crypto.com\/#website","url":"https:\/\/wsj-crypto.com\/","name":"WSJ-Crypto","description":"Just Another Crypto News Website","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wsj-crypto.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7","name":"wsjcrypto","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/wsj-crypto.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g","caption":"wsjcrypto"},"url":"https:\/\/wsj-crypto.com\/index.php\/author\/wsjcrypto\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts\/8737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/comments?post=8737"}],"version-history":[{"count":2,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts\/8737\/revisions"}],"predecessor-version":[{"id":8739,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts\/8737\/revisions\/8739"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/media\/8282"}],"wp:attachment":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/media?parent=8737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/categories?post=8737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/tags?post=8737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}