
Detect Solidity IR Storage Helper Collisions Before Deployment
Solidity 0.8.28 through 0.8.33 can generate incorrect clearing code when a contract compiled with the IR pipeline deletes both transient and persistent storage values of a matching type. The generated Yul helper may use sstore where tstore is required, or the reverse, causing persistent state corruption or ineffective deletion. Identify affected contracts by checking compiler settings and clearing operations in the same Yul object, then compare unoptimized Yul from an affected compiler with Solidity 0.8.34 or later.
Do not treat a successful test run, optimizer setting, or source-level type difference as proof of safety. The relevant question is whether both operations produce the same clearing helper. In particular, array clearing works at storage-slot granularity and can collide with a transient value of a different declared type.
Scope and environment
This guide addresses the transient-storage clearing helper collision reported by the Solidity team on February 18, 2026. The supplied advisory does not assign the bug a SOL-2026-7 or other identifier; do not label it with an invented ID.
The affected compiler range is Solidity 0.8.28 through 0.8.33 inclusive, and only when using the IR pipeline (--via-ir or Standard JSON settings.viaIR: true). The fix is in Solidity 0.8.34. The legacy evmasm pipeline is not affected by this specific bug.
Examples below use Solidity 0.8.34 and Foundry. Transient state variables require an EVM target that supports transient storage; configure a compatible EVM version, such as Cancun, for builds that use them.
# foundry.toml
[profile.default]
solc_version = "0.8.34"
evm_version = "cancun"
via_ir = true
For an affected release audit, compile the same source with the exact deployed compiler version and settings. Do not rely solely on a locally installed solc or a project’s current configuration: deployment artifacts may have been built with different compiler versions, optimizer settings, or IR settings. Record the compiler version, full Standard JSON input, and creation/runtime bytecode for each deployed build.
The vulnerable pattern
A contract is in scope only when all of these are true:
- It was compiled with the IR pipeline.
- It contains
deleteon a transient state variable. - The same generated Yul object contains a persistent-storage clearing operation that resolves to a matching clearing helper.
For example, the following pattern can collide:
// Illustrative vulnerable source. Do not deploy with solc 0.8.28–0.8.33 via-IR.
contract ClearingCollision {
address public owner;
mapping(uint256 => address) public delegates;
address transient _lock;
function clearDelegate(uint256 id) external {
delete delegates[id];
}
function guarded() external {
require(_lock == address(0), "locked");
_lock = msg.sender;
// Protected work
delete _lock;
}
}
The source appears to clear two independent values. In the IR pipeline, however, the compiler generates reusable Yul helpers for clearing storage. A helper’s name must uniquely identify its behavior because the generated function set is deduplicated by name. In affected versions, the name for a clearing helper encodes the Solidity value type but does not distinguish persistent from transient storage.
As a result, whichever operation causes the helper to be generated first determines its implementation. If persistent clearing comes first, the shared helper may use sstore; a later transient deletion can then write to persistent storage instead of clearing the transient slot. If transient deletion comes first, the helper may use tstore; a later persistent deletion can clear transient storage while leaving the persistent value intact. Which operation is encountered first depends on generated code-processing order, including function selectors and syntax-tree structure—not on the order in which a user expects functions to execute.
The first direction can corrupt an access-control or initialization slot and leave a transient lock set for the rest of the transaction. The reverse direction can leave revoked approvals or other persistent values uncleared. The operation need not revert, and Solidity emits no warning for the faulty output.
Type matching is broader than declarations
Do not search only for identical declared variable types. A persistent operation can generate the matching helper through a nested value, a struct member, or an array operation.
For example, clearing a persistent array generally clears storage at slot granularity, treating slots as uint256. Thus, delete flags on a bool[] can share a clearing helper with delete _temp on a transient uint256. Similarly, array element types such as address[5] or nested arrays can lead to slot-level clearing helpers. By contrast, .pop() uses the actual element type, and clearing struct members smaller than 32 bytes can use a direct sstore(slot, 0) path that bypasses the shared helper described here.
Review these operations in the same compilation unit, including inherited contracts and reachable library or free-function code:
deleteof a transient value type.deleteof persistent values, including mapping entries and array elements.deleteof arrays or structs, array.pop(), and array shrinking or reassignment that clears storage.- Clearing performed by base contracts, derived contracts, and linked libraries.
A constructor-only clearing operation does not collide with a runtime-only operation: creation and deployed runtime code are emitted as separate Yul objects with separate helper sets. Still, verify the generated objects rather than inferring object boundaries from source layout.
Production mitigation
The preferred fix is to recompile with Solidity 0.8.34 or later, pin that compiler in CI and deployment tooling, and redeploy affected code where necessary. A compiler upgrade does not change already deployed bytecode. The fixed compiler distinguishes persistent and transient helper names, generating separate functions so the persistent path uses sstore and the transient path uses tstore.
If an immediate compiler upgrade is impossible, stop using the affected via-IR build for deployment. The legacy evmasm pipeline is not affected by this bug, but changing pipelines is a compiler and bytecode change that needs its own testing and review. Do not assume that rewriting delete _lock as _lock = address(0) is a universal fix: explicit zero assignment does not use the clearing helper and avoids this trigger for that assignment, but it is a workaround that must be validated against the exact compiler output and every affected code path.
The fix is not equivalent to adding a reentrancy guard or checking state after the call. The fault is in generated storage opcodes; guard logic cannot make an incorrect sstore or tstore target safe. For broader callback and token interaction concerns, separately review Preventing ERC-20 Return Value Assumptions in Solidity and Preventing Unchecked Low-Level Call Failures in Solidity.
Differential Yul verification
Use unoptimized IR to inspect the compiler’s generated helpers. Compare the exact deployed compiler against 0.8.34 using identical source, remappings, optimizer settings, EVM version, and metadata settings. With a local solc binary, a minimal workflow is:
solc-0.8.33 --version
solc-0.8.33 --ir --optimize --optimize-runs 200 \
--evm-version cancun ClearingCollision.sol > old.ir
solc-0.8.34 --version
solc-0.8.34 --ir --optimize --optimize-runs 200 \
--evm-version cancun ClearingCollision.sol > fixed.ir
grep -nE 'storage_set_to_zero|transient_storage_set_to_zero|sstore|tstore' \
old.ir fixed.ir
For the advisory’s suggested comparison, also produce unoptimized Yul: omit --optimize in both commands. Optimizer output can help explain final code generation, but the collision is introduced during code generation and is not fixed by enabling optimization. The important evidence is whether the affected output reuses one helper for both storage kinds, and whether the fixed output emits distinct persistent and transient helpers. Helper names can vary by type; inspect the definitions and their called functions, not just a single hard-coded name.
For Standard JSON builds, preserve the actual project input and vary only the compiler binary. Set settings.viaIR to true, and request Yul output, for example:
{
"language": "Solidity",
"sources": {
"ClearingCollision.sol": { "urls": ["ClearingCollision.sol"] }
},
"settings": {
"viaIR": true,
"evmVersion": "cancun",
"outputSelection": {
"*": {
"*": ["ir", "irOptimized", "evm.bytecode.object", "evm.deployedBytecode.object"]
}
}
}
}
Capture each compiler’s output and compare the ir fields for the contract’s creation and runtime objects. Do not compare artifacts built with different source files or settings and attribute every difference to the bug.
Tests that exercise the actual failure
A regression test should assert both sides of the behavior, not merely that delete returns without reverting. With the vulnerable compiler, arrange the source so the persistent clearing path is processed before the transient delete, then test that the owner remains unchanged and the transient lock can be cleared. Create a second fixture with the transient clear encountered first and assert that deleting a persistent mapping value actually returns zero from its getter. Run those fixtures under the affected compiler for diagnosis and under 0.8.34 for the expected behavior.
A Foundry test can assert the intended invariant:
function test_guardedDoesNotClearOwner() public {
ClearingCollision target = new ClearingCollision();
address initialOwner = target.owner();
target.guarded();
assertEq(target.owner(), initialOwner);
}
Add a persistent-deletion assertion to the reverse-order fixture:
function test_revokeClearsPersistentApproval() public {
target.approve(spender, 42);
target.revokeApproval(42);
assertEq(target.approvals(42), address(0));
}
For reproducibility, run the same tests with the project’s recorded compiler settings, not only the default Foundry profile. For example:
FOUNDRY_PROFILE=via_ir forge test --match-path 'test/*Clearing*' -vvv
Then run the affected source against the legacy pipeline as a diagnostic comparison, and against 0.8.34 via-IR as the fixed build. The pipeline comparison helps isolate the issue; the fixed compiler is the production remedy. Keep compiler versions explicit in CI so a developer’s local compiler cannot silently change the result.
| Build or check | Version / setting | Expected diagnostic result | Production status |
|---|---|---|---|
| Affected via-IR build | 0.8.28–0.8.33, viaIR: true | Matching helper may use the wrong storage opcode | Do not deploy affected output |
| Legacy pipeline | 0.8.28–0.8.33, via-IR off | This specific collision is not present | Diagnostic alternative; validate separately |
| Fixed via-IR build | 0.8.34+, viaIR: true | Persistent and transient clearing helpers are distinct | Preferred compiler fix |
| Explicit zero assignment | Affected compiler | Avoids the clearing helper for that assignment | Narrow workaround; audit and test fully |
The table’s version ranges and outcomes describe this specific compiler issue, not a general guarantee about all compiler bugs or pipeline equivalence. The affected condition is a source-and-codegen pattern, not a runtime gas threshold; there is no meaningful fixed gas saving to claim.
Production review checklist
Before signing off a deployed build, establish whether it used via-IR and whether its compiler version is in range. Search inherited source and linked libraries for transient delete operations and persistent clears that can produce the same helper, accounting for slot-granularity array clearing. Inspect both creation and runtime Yul objects, because only operations in the same object can collide.
If a deployed contract matches the pattern, review its actual generated Yul and storage layout to determine which direction of collision occurred and which functions can execute the bad operation. Assess persistent state that could be overwritten, such as owner or initialization flags, as well as persistent state that might fail to clear. A source-level patch cannot repair existing bytecode; remediation may require pausing affected flows, migration, or redeployment, depending on the contract’s upgrade and control model. For transient-state design context, see Testing Stateful Precompile DELEGATECALL Semantics in Solidity.
Frequently Asked Questions (FAQ)
Which Solidity versions are affected by the transient storage helper collision?
Solidity 0.8.28 through 0.8.33 are affected when compiling through the IR pipeline. Solidity 0.8.34 fixes the issue by distinguishing persistent and transient clearing helpers. The legacy evmasm pipeline is not affected by this specific bug.
Does delete on a transient variable always trigger the bug?
No. The transient delete must be compiled into the same Yul object as a persistent clearing operation that produces a matching helper. A persistent variable does not need the same declared type: array clearing can operate at slot granularity and match a transient value of another type. Explicitly assigning the zero value avoids the clearing helper for that assignment.
Can optimizer settings prevent the Solidity 0.8.28–0.8.33 bug?
No. The collision arises when IR code generation creates helpers with a name that does not distinguish storage kind. Optimizer settings do not fix that naming collision. Compare unoptimized IR to diagnose it, and use Solidity 0.8.34 or later for the compiler fix.