{"id":4802,"date":"2026-11-29T23:15:12","date_gmt":"2026-11-29T23:15:12","guid":{"rendered":"https:\/\/smartcryptosecurity.com\/?p=4802"},"modified":"2026-11-29T23:15:12","modified_gmt":"2026-11-29T23:15:12","slug":"critical-solidity-compiler-bug-affects-transient-and-persistent-storage-clearing-in-ir-pipeline-2","status":"publish","type":"post","link":"https:\/\/smartcryptosecurity.com\/?p=4802","title":{"rendered":"Critical Solidity Compiler Bug Affects Transient and Persistent Storage Clearing in IR Pipeline"},"content":{"rendered":"<p>On February 11, 2026, blockchain security firm Hexens reported a critical code generator bug in the Solidity compiler affecting versions 0.8.28 through 0.8.33. The flaw occurs exclusively within the Intermediate Representation (IR) pipeline when developers utilize the <code>--via-ir<\/code> compilation flag, which is not enabled by default. When a smart contract clears both a persistent storage variable and a transient storage variable of the same type, the compiler emits the wrong opcode for one of the operations. Specifically, it emits an <code>sstore<\/code> instruction instead of a <code>tstore<\/code>, or vice versa, because the generated Yul helper functions share an identical name, causing one to overwrite the other during code generation.<\/p>\n<p>The Solidity development team has assigned this bug a severity rating of high on their internal scale. Despite the high severity, a comprehensive cross-chain analysis identified only three deployed smart contracts matching the affected pattern across all Ethereum Virtual Machine (EVM)-compatible networks. The respective development teams for those contracts were promptly notified, and adequate measures were taken to mitigate any potential security impact. Projects that rely on the standard legacy <code>evmasm<\/code> pipeline, or projects that have not explicitly opted into the <code>--via-ir<\/code> compilation flag, remain entirely unaffected by the vulnerability. The issue has been officially resolved in Solidity version 0.8.34.<\/p>\n<h2>Which Contracts Are Affected?<\/h2>\n<p>For a smart contract to be vulnerable to this compilation bug, specific conditions must align during the build process. Most importantly, code that does not execute a <code>delete<\/code> operation on a transient state variable cannot trigger the flaw. Developers should note that explicitly assigning a zero value\u2014such as writing <code>_lock = 0<\/code>\u2014bypasses the shared clearing helper mechanism entirely and does not invoke the problematic code path.<\/p>\n<p>The underlying name collision occurs when two distinct clearing operations\u2014one targeting transient storage and the other targeting persistent storage\u2014produce the same internal helper function. This happens when both operations clear matching Solidity value types. Crucially, the persistent variable does not need to be declared as the same type as the transient variable; it is sufficient for a matching value type to be nested within it, such as acting as a struct member or an array element.<\/p>\n<p>On the transient side of the equation, there is exactly one code path capable of producing the <code>tstore<\/code> variant: executing a <code>delete<\/code> statement on a transient state variable. Because transient arrays, mappings, and nested structs are not currently supported in Solidity, this operation invariably targets a primitive value type. Conversely, any operation that clears persistent storage of a matching value type can produce the <code>sstore<\/code> variant, including deleting standard persistent variables, mapping values, or array elements.<\/p>\n<p>A notable vector for cross-type collisions involves array clearing operations. Clearing operations on arrays in Solidity are typically performed at a slot granularity, treating every storage slot as a generic <code>uint256<\/code> rather than clearing each individual element separately. Consequently, operations such as deleting a boolean array, a fixed-size address array, or a multi-dimensional integer array all utilize the exact same clearing helper as deleting a standard <code>uint256<\/code> variable, regardless of the actual element type declared in the source code. For instance, a contract containing a boolean array alongside a transient <code>uint256<\/code> variable will experience a collision between the array clearing routine and the transient deletion, despite their differing declared types.<\/p>\n<p>This slot-granularity expansion does not apply to array <code>.pop()<\/code> calls, which correctly use the actual element type, nor does it apply to struct member clearing for members smaller than 32 bytes, which uses a direct persistent store instruction that bypasses the shared helper entirely. Furthermore, the two sides of the collision do not even need to reside within the same contract file. A base contract containing a transient variable paired with a derived contract containing a persistent variable or mapping of the same type is sufficient to trigger the bug. Free functions and library functions utilized throughout the contract can also contribute to the collision. Finally, both clearing operations must be present within the exact same Yul object; a deletion present solely in contract creation code, such as a constructor, will not interact with a deletion present only in deployed runtime code because the compiler generates separate Yul objects with independent helper sets for each phase.<\/p>\n<h2>The Bug<\/h2>\n<p>The root cause of the vulnerability lies in how the IR pipeline handles reusable Yul helper functions during code generation. These helper functions are deduplicated by name, meaning that the compiler enforces a rule where only one Yul function can exist for a given identifier. Therefore, the function name must theoretically encode all behavioral nuances of the routine.<\/p>\n<p>The helper responsible for clearing a storage slot\u2014which is invoked by <code>delete<\/code> and related language constructs\u2014derives its name strictly from the underlying Solidity type being cleared, such as generating an identifier like <code>storage_set_to_zero_t_address<\/code> for an address type. However, the name generation logic completely omits the storage data location. As a result, both persistent storage and transient storage operations generate the exact same function name for identical types.<\/p>\n<p>Because the compiler maintains only one function per name, whichever clearing operation is encountered first dictates the final implementation. If a persistent clearing operation is processed first, the generated function uses the <code>sstore<\/code> opcode. If a transient deletion is encountered first, it uses <code>tstore<\/code>. Any subsequent operation of the opposite storage type reuses the existing function, leading to the emission of an incorrect opcode. The order in which the compiler encounters these operations depends primarily on the structure of the syntax tree and the ordering of function selectors, remaining completely independent of the optimizer stage which executes later in the pipeline. The implemented fix resolves this by injecting the specific data location into the function name, producing entirely separate Yul helpers for persistent and transient clearing operations.<\/p>\n<h2>Examples<\/h2>\n<p>To demonstrate how the bug manifests in practice, security analysts reviewed simplified contract structures illustrating both directions of the failure mode. <\/p>\n<p>In the first scenario, where a persistent clearing operation is encountered first, a contract features both persistent mappings and a transient lock variable. The compiler processes the persistent deletion first, generating an <code>sstore<\/code>-based helper function. When a subsequent transient delete statement is compiled, it inadvertently reuses this persistent helper. Instead of clearing the transient lock, the execution writes a zero to persistent slot zero, effectively overwriting an unrelated state variable\u2014such as an owner address\u2014with zero. Furthermore, because the transient variable was never actually cleared via a <code>tstore<\/code>, the transient lock value remains stuck, rendering the guarded function permanently unusable for subsequent calls within the same transaction.<\/p>\n<p>In the second scenario, where a transient delete operation is encountered first, the generated helper defaults to using the <code>tstore<\/code> opcode. When a subsequent persistent mapping deletion is processed, it reuses this transient helper. Rather than removing the approval or data from persistent storage, the operation clears the corresponding slot in transient storage, leaving the persistent state completely intact and vulnerable to unauthorized access or unintended persistence.<\/p>\n<h2>Severity Assessment and Industry Response<\/h2>\n<p>The vulnerability is particularly insidious because the compiler emits no warnings during the build process, and the generated code does not trigger runtime reverts. Instead, the incorrect storage operations manifest purely as unexpected state changes, complicating debugging efforts. However, development teams maintaining rigorous test suites that compile and test via the IR pipeline prior to deployment are well-positioned to catch anomalous state mutations, even if the root cause remains obscure. Unlike many historic compiler flaws, this issue can be triggered purely through standard Solidity syntax without resorting to inline assembly.<\/p>\n<p>Following the initial disclosure by Hexens, a coordinated security response was launched involving SEAL 911, Etherscan, Dedaub, and Hexens to scan all EVM-compatible blockchains for vulnerable contracts. This extensive audit revealed only three deployed contracts matching the dangerous pattern. Subsequent analysis confirmed that none of these affected contracts were part of high-value public production applications interacting with external users, and the total funds at risk were negligible.<\/p>\n<p>The Solidity core team subsequently verified that no other helper functions within the compiler suffer from comparable naming collisions and announced plans for broader codebase refactoring to prevent similar classes of bugs in future releases. Developers utilizing compiler versions between 0.8.28 and 0.8.33 with the IR pipeline enabled are strongly encouraged to upgrade immediately to version 0.8.34 or later, and to audit their codebase for simultaneous transient and persistent deletions of matching types.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On February 11, 2026, blockchain security firm Hexens reported a critical code generator bug in&#8230;<\/p>\n","protected":false},"author":5,"featured_media":4801,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[366],"tags":[963,401,1227,1230,201,2414,2223,5,400,402,517,2452],"class_list":["post-4802","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-smart-contract-auditing","tag-affects","tag-auditing","tag-clearing","tag-compiler","tag-critical","tag-persistent","tag-pipeline","tag-security","tag-smart-contracts","tag-solidity","tag-storage","tag-transient"],"_links":{"self":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/posts\/4802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4802"}],"version-history":[{"count":0,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/posts\/4802\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/media\/4801"}],"wp:attachment":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}