22 Nov 2026, Sun

Critical Solidity Compiler Bug Affects IR Pipeline Storage Operations, Patched in Version 0.8.34

On February 11, 2026, blockchain security firm Hexens reported a critical bug in the Solidity code generator that impacts compiler versions 0.8.28 through 0.8.33 when utilizing the intermediate representation (IR) pipeline. The vulnerability causes the compiler to emit incorrect opcodes—mistakenly substituting an sstore instruction for a tstore, or vice versa—whenever a contract attempts to clear both a persistent storage variable and a transient storage variable of the same type. This unexpected behavior stems from shared naming conventions in the generated Yul helper functions, causing one function to overwrite another during the compilation process.

Assigned a "high" severity rating on the internal Solidity team scale, the issue has prompted coordinated responses across the decentralized finance and blockchain security ecosystems. Following comprehensive scanning efforts across all Ethereum Virtual Machine (EVM)-compatible chains, only three deployed contracts matching the vulnerable pattern were identified. The respective development teams have already been notified, and necessary measures have been taken to mitigate any potential impact. Nevertheless, developers maintaining projects compiled with the --via-ir flag that implement the delete keyword on transient storage are strongly advised to review their codebases.

The vulnerability is strictly confined to the IR pipeline, leaving the legacy evmasm pipeline completely unaffected. Furthermore, because the --via-ir compilation flag is not enabled by default, projects that have not explicitly opted into the IR pipeline face no exposure. For developers utilizing the affected range of compiler versions, the issue has been fully resolved in Solidity version 0.8.34.

Understanding the Vulnerability and Affected Contracts

A contract is only susceptible to this storage collision if a specific set of conditions is met within its codebase. Most importantly, code that does not implement the delete keyword on a transient state variable is entirely safe from this issue. Developers should also note that explicitly assigning a zero value—such as writing _lock = 0—bypasses the shared clearing helper function altogether and does not trigger the compiler bug.

The underlying collision occurs when two distinct clearing operations—one targeting transient storage and the other targeting persistent storage—generate identical internal helper functions. This happens when both operations clear matching Solidity value types. Crucially, the persistent variable does not need to be declared as the exact same type as the transient variable; it is sufficient for a matching value type to be nested within it, such as a struct member or an array element.

On the transient side of the equation, there is precisely one code path that triggers the production of the tstore variant: executing a delete operation on a transient state variable. Because Solidity does not yet support transient arrays, mappings, or structs, this operation always involves a value type. Conversely, the persistent side can generate the sstore variant through any operation that clears persistent storage of a matching value type.

Complications also arise via array clearing mechanisms. Clearing operations on arrays are generally performed at slot granularity, treating every slot as a uint256 rather than clearing each individual element. Consequently, operations like deleting boolean arrays, fixed-size address arrays, or multidimensional integer arrays all utilize the exact same clearing helper as a standard uint256 variable, regardless of the actual underlying element type. For example, a contract containing a persistent bool[] array and a transient uint256 variable will experience a collision between the array clearing and the transient deletion, despite their distinct declared types. However, this slot-granularity expansion does not apply to array .pop() operations, which use the actual element type, nor does it apply to struct member clearing for members smaller than 32 bytes, which execute direct sstore(slot, 0) instructions that completely bypass the shared helper.

The components of the collision do not even need to reside within the same contract file. A base contract containing a transient variable combined with a derived contract featuring a persistent variable or a mapping with a matching value type is enough to trigger the bug. Similarly, clearing operations executed within free functions or library functions utilized by the contract can contribute to the naming collision. Both clearing operations must simply be present within the same Yul object. A delete statement appearing exclusively in creation code, such as inside a constructor, will not interact with a delete statement found only in deployed runtime code because the compiler generates them as separate Yul objects with independent helper function sets.

Technical Root Cause in the Compiler Internals

The IR pipeline relies on deduplicating reusable Yul helper functions through a component known as MultiUseYulFunctionCollector. This collector indexes functions strictly by name, meaning that a request to create a function with an existing name simply returns the cached result rather than generating a new block of code. The helper responsible for clearing a storage slot—which is invoked by delete and related routines—derives its name entirely from the Solidity type being cleared, designating names such as storage_set_to_zero_t_address for an address type.

However, the naming convention historically omitted the storage kind, meaning persistent and transient storage operations produced identical function names for identical types. Whichever clearing operation the compiler encountered first determined the implementation. If a persistent clearing operation was processed first, the generated function incorporated an sstore instruction. If a transient deletion was encountered first, it implemented a tstore instruction. Any subsequent operation of the opposite storage kind would then inadvertently reuse the existing function, emitting the wrong opcode.

The order in which the compiler encounters these operations is dictated by function selectors and the syntax tree structure rather than the optimizer, which operates during a distinct stage after code generation. The definitive fix introduced in Solidity 0.8.34 explicitly incorporates data locations into the helper function names. This creates distinct Yul functions—differentiating between persistent variants like storage_set_to_zero_t_address and transient variants like transient_storage_set_to_zero_t_address—thereby ensuring that each operation invokes the correct underlying EVM opcode.

Real-World Impact and Severity Assessment

Because the compiler emits no warnings and the generated bytecode does not revert at runtime, the vulnerability manifests purely as unexpected state modifications. This silent failure mode makes diagnosis challenging, though projects maintaining robust test suites executed with --via-ir prior to deployment are well-positioned to catch aberrant behavior. Unlike many historical compiler vulnerabilities, this bug requires no inline assembly to manifest, significantly raising its practical probability of occurrence.

The precise impact depends entirely on the direction of the opcode collision. In scenarios where persistent clearing is processed first, transient deletions incorrectly execute sstore instructions, potentially overwriting critical persistent state variables with zero while failing to clear the transient storage slot, locking resources within a transaction. In reverse scenarios where transient deletion is processed first, persistent clearing operations mistakenly execute tstore instructions, leaving persistent state variables intact while clearing non-persistent memory slots.

Following the initial disclosure, a rapid, coordinated audit across EVM-compatible chains was launched with support from SEAL 911, Etherscan, Dedaub, and Hexens. Out of all deployed contracts on public networks, only three instances of the vulnerable pattern were discovered. The respective development teams were promptly alerted, and investigations confirmed that none of the affected contracts were tied to live public applications handling significant user funds or external interactions.

Developers seeking to verify whether their projects are affected can compare the unoptimized Yul output generated via the --ir flag between their current compiler version and version 0.8.34. Identifying whether a single helper handles both persistent and transient clearing for a given type serves as a definitive indicator of vulnerability. The Solidity team recommends upgrading immediately to Solidity 0.8.34 or later for any projects utilizing the IR pipeline, alongside conducting thorough test suite executions to validate state management logic.

Leave a Reply

Your email address will not be published. Required fields are marked *