On June 8, 2026, developer clonker from the core Solidity team identified a significant internal bug residing within the analysis phase of the Solidity compiler. The vulnerability surfaces specifically when the compiler evaluates contracts and emits Warning 3495, an alert designed to warn developers when a custom storage layout is positioned perilously close to the upper limit of the Ethereum Virtual Machine’s storage space. While the intent behind the warning is purely diagnostic, the underlying mechanism tasked with implementing it inadvertently introduced a severe data-mutation flaw. By mistakenly reversing the C3-linearized list of base contracts for any contract undergoing evaluation, the compiler set the stage for widespread inheritance disruptions, potential miscompilations, and abrupt internal compiler errors across downstream operations.
The Solidity development team has assigned this newly discovered vulnerability a severity rating of medium on their internal scale. Because the bug is deeply embedded within the language frontend’s core analysis phase, it operates entirely independently of whichever compilation pipeline a developer chooses to employ. Consequently, both the modern IR-based pipeline and the legacy evmasm pipeline remain equally vulnerable to its effects. However, certain execution environments are entirely spared; pure Yul code remains completely unaffected, and transient storage avoids the issue because custom storage layouts are a feature exclusively implemented for persistent storage within the Ethereum ecosystem.
Tracing the lineage of the defect reveals that it was inadvertently introduced back in Solidity version 0.8.29, the exact release that originally rolled out the storage-end warning feature. Because the faulty helper function has persisted unchanged since that initial rollout, every single official release ranging from Solidity 0.8.29 through Solidity 0.8.35 is affected. Fortunately, the swift discovery by the internal team led to a prompt remediation, and the bug has been fully resolved and patched in Solidity version 0.8.36.
To gauge the real-world exposure of this flaw, the Solidity team conducted broad empirical checks. A comprehensive GitHub search looking for Foundry configuration files that explicitly suppress Warning 3495 yielded zero results, strongly indicating that intentionally configuring storage variables at exceptionally high memory addresses is an exceedingly rare practice among smart contract developers. This observation was further corroborated by a scan of deployed contracts executed via Sourcify, which similarly returned no evidence of contracts actively triggering the vulnerable code pattern in production environments.
Which Contracts Are Affected?
Understanding the precise trigger conditions is crucial for developers auditing their codebases against historical compiler versions. A smart contract is only vulnerable to this specific inheritance-order reversal if a very specific set of conditions is simultaneously met. First and foremost, the contract must be compiled using an affected version of the Solidity compiler, spanning from 0.8.29 to 0.8.35. Second, the contract must utilize an explicit inheritance hierarchy involving multiple base contracts, relying on proper C3 linearization. Third, the contract must implement a custom storage layout via a layout-at clause. Finally, that custom storage layout must be pushed so far toward the upper bounds of the storage space that it triggers Warning 3495.
Because custom storage layouts positioned near the absolute end of the available storage slots are exceptionally rare, and because the compiler actively flags such configurations with a warning, the specific pattern required to trigger the bug is highly unusual in everyday development workflows. Developers can take immediate comfort in a fundamental rule: if a contract does not utilize a custom storage layout, or if it does not employ contract inheritance, it is entirely immune to this bug regardless of the compiler version used.
Technical Details
For developers and systems engineers interested in the granular, implementation-level root cause of the bug, the mechanics lie deep within the compiler’s C++ source architecture. The storage-end warning was originally conceived to protect developers from painting themselves into a corner regarding contract upgradability. Solidity permits developers to place storage variables at a custom base slot using a designated layout-at clause. When the static portion of that custom layout approaches too close to the end of the monumental two-to-the-power-of-256 storage space, the compiler emits a cautionary warning. This warning alerts the user that future upgrades might cause the layout to expand beyond the remaining available slots, at which point the compiler would outright reject the upgrade.
Specifically, the warning triggers when the total number of free slots remaining after the custom layout is equal to or less than two to the power of 64. Because triggering this condition requires a numerical proximity to the storage ceiling, triggering it via a hash-based layout expression—such as the standard ERC-7201 namespaced storage pattern—possesses a vanishingly small probability, roughly equivalent to a mapping element randomly landing on a specific target slot.
The core technical failure that corrupts the compilation process stems from how the compiler handles AST annotations during this warning phase. The linearizedBaseContracts annotation stores the formal C3 linearization of an inheritance hierarchy, a critical roadmap that dictates how the compiler resolves inheritance throughout subsequent phases of analysis and code generation. The specific routine responsible for emitting Warning 3495 was designed to walk this list in reverse order to locate the exact variable sitting closest to the storage boundary.
Instead of creating and working upon a safe, temporary copy of the list, the routine unwittingly performed the reversal operation directly in-place, permanently mutating the underlying data structure stored within the AST annotation. Consequently, every subsequent phase of the compiler that referenced the inheritance list was forced to read a completely reversed hierarchy.
In implementation terms, this catastrophic side effect was caused by utilizing the actions::reverse helper function from the widely adopted ranges-v3 library instead of the intended views::reverse utility. While both functions achieve a reversed iteration, the actions variant mutates the underlying container directly rather than producing a non-destructive, read-only reversed view. Compounding the issue, both helpers share virtually identical signatures, allowing the subtle semantic mismatch to slip past the initial code review undetected.
Adding to the architectural vulnerability was the design of the compiler’s internal annotation framework itself. Annotations in this subsystem are traditionally designed to be mutable, a departure from strict const-correctness principles. Because the underlying data structures were permitted to be altered freely, the C++ compiler itself could not flag the invocation of actions::reverse as a type violation or an illegal modification.
Effect on the Rest of the Compiler
The repercussions of mutating the linearizedBaseContracts annotation are profound because this data structure is consulted extensively across both analysis and code generation pipelines. When the inheritance list is inverted, any resolution mechanism relying on the established C3 linearization order will inevitably yield incorrect results. Confirmed consequences of this corruption include a completely reversed state-variable initialization sequence, an inverted constructor invocation order, broken resolution of super and virtual functions, faulty virtual modifier resolution, and corrupted resolution of virtual fallback and receive functions.
Furthermore, this reversed ordering propagates directly into the final AST JSON export generated by the compiler. Depending on the complexity of the contract architecture, these failures manifest in markedly different ways. Some manifest as silent miscompilations where state variables initialize in an unintended order without throwing errors, while others trigger catastrophic internal compiler errors or generate invalid intermediate representation (IR) code that halts the compilation process outright.
Example
To better understand how this bug manifests in code, consider a minimal reproduction case engineered to satisfy all the necessary trigger conditions. Imagine a simple contract hierarchy consisting of three interconnected contracts:
contract A
uint public x;
constructor()
x = 1;
contract B is A
constructor()
x = x * 10;
contract C is B layout at 2**256 - 2**40
constructor()
x = x + 5;
In this architecture, the standard inheritance chain flows cleanly from A to B and finally to C. Under normal operating conditions, constructors execute in a predictable left-to-right or base-to-derived linearization order. Deploying contract C should mathematically result in x evaluating to (1 * 10) + 5, equaling 15. However, the inclusion of the layout at 2**256 - 2**40 clause pushes the storage layout squarely into the final two-to-the-power-of-64 slots, triggering Warning 3495 and subsequently activating the faulty in-place reversal routine.
Under the influence of the bug, deploying contract C results in x evaluating to 5. This incorrect outcome occurs because the corrupted, reversed linearization forces the constructor execution sequence to run backward. Conversely, if the exact same contracts are compiled without the custom storage layout clause—and consequently without generating the storage-end warning—the compiler processes the inheritance hierarchy correctly, yielding the expected value of 15.
Severity Assessment
While the theoretical impact of the bug is undeniably high—capable of silently miscompiling core inheritance-dependent behaviors such as constructor execution sequences and state-variable initialization—the real-world probability of encountering it remains extremely low. The defect exclusively triggers under conditions that the Solidity compiler already actively discourages: custom storage layouts overlapping with the final segment of storage space. The Solidity team knows of no legitimate, practical use cases for placing persistent storage variables at such astronomical addresses, a fact strongly supported by the complete absence of matching patterns in Sourcify database scans. Furthermore, contracts that eschew complex inheritance altogether remain entirely immune.
It is also worth noting that the resulting corruption does not always lead to silent, undetected miscompilations. In more intricate contract hierarchies involving explicit super calls, complex constructor parameters, or cross-variable dependencies, the inverted inheritance order is statistically likely to trigger an internal compiler error or produce invalid IR. These defensive failures effectively halt compilation, surfacing the problem at build time rather than allowing faulty code to be silently shipped to a live blockchain network.
The Fix
Addressing the root cause of the vulnerability required a targeted correction within the compiler’s source code. The Solidity team permanently resolved the issue by replacing the destructive ranges::actions::reverse function call with the safe, non-mutating ranges::views::reverse utility. This modification ensures that helper functions can successfully iterate over a reversed presentation of the base contract list without altering or corrupting the underlying AST annotations that govern the rest of the compilation pipeline.
Recommended Actions
Developers who have been utilizing vulnerable versions of the Solidity compiler within their development pipelines are strongly encouraged to upgrade their toolchains to Solidity version 0.8.36 or any later release. Upgrading ensures that projects utilizing complex inheritance hierarchies and custom storage layouts are fully protected against both silent miscompilations and internal compiler errors stemming from AST annotation corruption.
Acknowledgements
The discovery and subsequent remediation of this compiler vulnerability were conducted internally by members of the core Solidity development team.






