The Ethereum Foundation’s Solidity development team has officially released Solidity version 0.8.38, addressing a subtle and potentially hazardous optimization defect discovered within the Yul intermediate representation compiler. The vulnerability, which affects a wide range of recent compiler versions spanning several years, can under specific and fragile conditions cause the Yul optimizer to incorrectly evaluate memory and storage locations. As a result, compiled smart contracts might execute loads using outdated values or inadvertently eliminate essential storage updates, posing silent data integrity risks for decentralized applications.
The issue first came to light on August 17, 2026, when security researcher Daniel Boye submitted a formal bug report through the Ethereum Foundation’s bug bounty program. Boye’s initial analysis demonstrated that the optimizer could occasionally treat two distinct memory or storage locations as entirely separate entities even when those locations coincided during runtime execution. This flawed assumption could lead the compiler to replace a necessary data load with a stale value or remove a write operation deemed redundant by the faulty optimization logic.
Weeks later, on September 28, 2026, a second independent report submitted by Surya Prakash Akula expanded the understanding of the vulnerability’s scope. Akula’s findings proved that the bug was not restricted to low-level assembly blocks or specialized configurations; it could be triggered directly from plain, high-level Solidity code without the developer ever writing explicit inline assembly.
Internal security assessments by the Solidity team classified the severity of the bug as low. This rating reflects the highly specific and complex preconditions required for the defect to manifest in a production environment. Nevertheless, because smart contract bugs can lead to severe financial consequences in decentralized finance ecosystems, developers have been strongly urged to update their compiler toolchains.
Which Contracts Are Affected?
The scope of affected contracts depends heavily on compilation settings, pipeline configurations, and code structure. The vulnerability was originally introduced in Solidity version 0.8.19 and impacts all subsequent versions up to and including 0.8.37. The defect has been fully resolved starting with Solidity 0.8.38.
Crucially, smart contracts compiled with the Yul optimizer disabled remain entirely unaffected by the issue. However, when the optimizer is active, the impact varies depending on the compilation pipeline utilized. When employing the modern --via-ir pipeline—or its equivalent settings.viaIR parameter in Standard JSON configurations—any smart contract code may be vulnerable, including standard Solidity implementations that contain zero inline assembly. Similarly, Yul code compiled directly using the --strict-assembly flag or the "language": "Yul" JSON parameter is subject to the same risks.
By contrast, projects relying on the default evmasm compilation pipeline face a much narrower exposure. Under the default pipeline, only compiler-generated Yul utility functions and isolated inline assembly blocks that completely omit references to surrounding Solidity variables or functions can potentially be affected.
Determining whether a specific codebase is vulnerable purely by inspecting source code can be exceptionally difficult. The intermediate Yul code that feeds into the problematic optimizer steps relies heavily on the specific compiler version, the sequence of optimization passes configured by the developer, and the surrounding context of the codebase. Known reproducers utilizing the default optimizer sequence typically involve patterns where a local variable used for address computation is modified dynamically within a loop or conditional branch, both before and after an initial address is derived from it. A subsequent value is then written to the same storage slot via an address derived from the updated variable value. The targeted Ethereum Virtual Machine (EVM) version does not influence whether the bug manifests.
Technical Details
To understand the root cause of the vulnerability, it is necessary to examine the internal mechanics of the Yul optimizer, particularly its components responsible for tracking memory and storage contents. The LoadResolver component is designed to optimize performance by replacing mload, sload, and keccak256 instructions with cached values the compiler already knows. For example, if a location has been written to earlier in execution, the resolver attempts to reuse that known value rather than executing a fresh read operation. Meanwhile, the EqualStoreEliminator component removes redundant store instructions if the target location is already known to contain the exact value being written.
Both optimization components rely on a shared bookkeeping mechanism to track the known contents of memory and storage. When the optimizer encounters a store instruction where the exact destination location cannot be precisely determined at compile time, it must adopt a conservative approach and invalidate its knowledge regarding any location that the write operation might potentially overwrite. To determine which locations are affected, the compiler consults the KnowledgeBase, a subsystem dedicated to resolving mathematical and logical relations between variables.
The KnowledgeBase represents variables symbolically as constant offsets originating from a base variable. If a variable resolves to a static constant, its base is treated as zero. If its value cannot be expressed as a simple constant offset, the variable is treated as its own independent base with an offset of zero. For instance, following instructions such as let base := calldataload(0) and let ptr := add(base, 2), the variable base acts as its own base, while ptr is represented symbolically as base + 2.
Under normal operation, two addresses sharing the same base are recognized as distinct if their respective offsets differ by a sufficient margin—specifically, if they are offset for storage or separated by at least 32 bytes for memory. When addresses are proven distinct, the optimizer safely preserves its knowledge of one location even when a write occurs at the other.
To improve compilation performance, a caching mechanism for these symbolic representations was introduced in Solidity 0.8.19. Prior to that version, the KnowledgeBase computed offsets dynamically on the fly from current variable values. With the cache in place, however, the system relied on a lazy invalidation scheme. Whenever the KnowledgeBase performed a variable lookup, it compared the current value expression of the variable against the expression recorded during the previous lookup. If the expressions differed, the cached entry was reset.
This lazy verification approach could fail to detect a variable reassignment under specific execution flows. When a check was missed, two addresses might be represented as offsets derived from the same base variable, but with one address originating from the value of the base before a reassignment and the other originating from its value afterward. The optimizer incorrectly treated both offsets as relative to a single, unified value, leading it to conclude that the two memory or storage locations were distinct. Consequently, a store to the second location would fail to invalidate the optimizer’s assumptions about the first location. If the two locations happened to coincide during runtime execution, subsequent load operations would mistakenly retrieve outdated cached values, necessary store instructions could be omitted, or hash operations could be performed on stale data.
Example Scenario
The vulnerability can be illustrated through a plain Solidity contract compiled with the --via-ir flag and the optimizer enabled:
contract C
struct S uint256 v;
S[20] public a;
function g(uint256 max1, uint256 max2, uint256 aaaa, uint256 bbbb) external returns (uint256)
uint256 i;
for (uint256 j; j < max1; j++) i++;
uint256 k = i + 2;
a[k].v = aaaa;
for (uint256 j; j < max2; j++) i++;
a[i].v = bbbb;
return a[k].v;
In this contract, a represents a static array starting at storage slot zero. Because structure S contains a single value-type member, each array element occupies exactly one storage slot, aligning each slot index directly with the array index. When executing g(0, 2, 0xaaaa, 0xbbbb), the first loop does not execute, leaving k equal to 2, and 0xaaaa is written to a[2].v. The second loop executes twice, incrementing i to 2, which causes 0xbbbb to be written to the exact same storage location. Logically, the function should return 0xbbbb.
However, due to the compiler defect, the generated Yul code derives the storage slot for a[k].v from variable i prior to the second loop, while the slot for a[i].v is derived from i after the second loop. Because the optimizer tracks no explicit value for i at these points, it treats i as its own base, representing the two slots as i + 2 and i. The KnowledgeBase fails to recognize that these expressions reflect different points in the program timeline, wrongly concluding that the two write operations target distinct storage slots. As a result, the final load from a[k].v is incorrectly replaced with the initial parameter aaaa, causing the function to return 0xaaaa instead of the expected 0xbbbb.
Severity Assessment and Mitigation
The Solidity compiler emits no warnings when this bug is triggered, and affected runtime code does not necessarily trigger an EVM revert. Instead, state modifications are silently corrupted through missing writes or stale reads.
Despite the severity of potential data corruption, practical exploitability is considered extremely low. The confluence of fragile intermediate Yul code patterns and runtime address collisions requires precise conditions. Furthermore, an extensive scan of the Sourcify verified contract database—rebuilding roughly 283,000 verified compilations utilizing --via-ir and over 607,000 using the evmasm pipeline with and without the compiler fix—produced zero instances of differing bytecode output. While this scan provides strong statistical confidence that the bug is exceptionally rare in existing deployed codebases, developers cannot rely on it as an absolute guarantee.
The core engineering fix implemented in Solidity 0.8.38 replaces the fragile lazy cache invalidation strategy with an explicit variable versioning system. Every variable tracked within the KnowledgeBase now maintains an incremental version counter that updates automatically whenever the optimizer records a change to the variable’s value. Cached symbolic representations are now stored uniquely per variable and version identifier. Following any variable reassignment, the system treats the variable as a distinct new entity, entirely eliminating the possibility of stale cache entries.
Development teams maintaining smart contracts written in Solidity versions 0.8.19 through 0.8.37 are strongly encouraged to upgrade their compiler toolchain to version 0.8.38 immediately, particularly if their deployment pipelines utilize the Yul optimizer or --via-ir compilation settings.






