The Ethereum Foundation and core Solidity developers have disclosed a significant medium-severity vulnerability within the Solidity code generator. The flaw, which has quietly persisted across major compiler versions for nearly a decade, could result in silent data corruption when handling recursive data structures in smart contract storage.
Discovered and reported on April 22, 2026, by security researcher cyberthirst through the Ethereum Foundation’s official bug bounty program, the vulnerability affects both the legacy evmasm code generation pipeline and the newer Intermediate Representation (--via-ir) pipeline. Following a thorough investigation and fix implementation, developers have released Solidity version 0.8.39, which resolves the issue across all affected configurations.
Understanding the Vulnerability: Silent Storage Corruption
At the heart of the vulnerability lies the way smart contracts handle recursive structs—data structures that contain dynamic arrays or nested references pointing back to their own type. When performing storage-to-storage copy operations where a descendant struct or a nested array is copied onto an ancestor or enclosing array, the compiler generated instructions that overwrote the source’s storage location before all of its data could be read.
To understand the mechanics of the bug, consider a common pattern for tree-like data structures in Solidity:
struct Node
Node[] children;
uint256 data;
Node root;
Node[] roots;
When executing an assignment such as root = root.children[i] or roots = roots[i].children, the Solidity compiler attempted to copy a child node or nested array directly into the parent storage slot. Because dynamic arrays in Ethereum storage occupy a hash-based layout where elements are indexed via the keccak256 hash of their length slot, overwriting the parent container’s length and content effectively zeroed out underlying storage fields.
Consequently, if a field like data was positioned after the dynamic array within the struct layout, the copy operation would shrink and clear the array, wiping out the source data mid-execution. The contract would then read the corrupted field as zero, bypassing permission checks, balances, or crucial conditional statements without triggering any runtime error or compiler warning. Because the transaction would not revert, the data corruption could remain entirely unnoticed by developers and users alike.
Scope and Affected Versions
The vulnerability’s historical footprint is remarkably wide. According to the development team’s security advisory, the bug has been present since Solidity version 0.4.9, which marked the first release to successfully compile recursive structs. As a result, both struct-to-struct copies and array-to-array copies of recursive types have been susceptible to this flaw for generations of smart contract deployments.
The Intermediate Representation pipeline, introduced as an experimental feature and later stabilized, became vulnerable to the issue starting with version 0.8.13—the first release where --via-ir was no longer classified as experimental.
Despite the wide version range spanning from 0.4.9 through 0.8.38, a comprehensive security analysis suggests that the real-world exploitation risk remains low. A broad automated scan of verified smart contracts hosted on Sourcify found no deployed production contracts performing this specific type of storage-to-storage recursive copy in the dangerous target-contains-source direction. Most smart contract architectures utilizing recursive or tree-like structures either manage them entirely within temporary memory or utilize reference and mapping schemes that bypass direct storage overwrites. Furthermore, because such operations are computationally and gas-expensive, they are rarely implemented in standard decentralized application logic.
Technical Analysis of the Root Cause and Fix
The core issue stemmed from overlapping storage assignments that failed to account for the physical layout of dynamic arrays within smart contract storage. When a source structure overlaps with a target structure during a write operation, the execution order dictates whether data survives or gets overwritten. If a dynamic array is copied first, it modifies the storage slots that the source relies on for subsequent reads.
To permanently resolve the vulnerability without breaking standard compiler operations, the Solidity development team introduced a protective runtime check in version 0.8.39. For every storage-to-storage copy involving a recursive struct, the compiler now injects a verification step that walks the target’s subtree prior to execution to determine if it overlaps with or contains the source.
If an overlap is detected, the compiler automatically takes a snapshot of the source data into temporary memory. The copy operation then reads cleanly from this memory snapshot, ensuring that the target write does not interfere with ongoing source reads. If no overlap exists, the copy proceeds directly as before.
This defensive measure introduces a deliberate trade-off. Because the overlap check executes on every storage-to-storage copy of a recursive struct—even when no overlap is present—it incurs additional gas overhead. The runtime cost scales linearly depending on the depth of the nested structs held by the target. Additionally, because the recursive traversal consumes stack space, smart contracts performing copies into deeply nested targets may experience stack-to-depth limitations earlier than in previous compiler versions, potentially causing transactions to fail under extreme nesting scenarios.
The opposite operational pattern—where the source contains the target, such as root.children[0] = root—remains unsupported and retains its undefined behavior. The development team opted not to add snapshotting protections for this reverse direction due to the steep gas costs and minimal utility, advising developers to avoid such patterns entirely.
Recommended Actions and Acknowledgements
Developers maintaining smart contracts written in Solidity versions 0.4.9 through 0.8.38 are strongly urged to audit their codebases for the presence of recursive structs and storage copy patterns involving descendant-to-ancestor assignments. Projects should promptly upgrade their development environments to Solidity 0.8.39 or later to ensure compiler-level protection. Any contract that has historically utilized affected copy patterns should undergo a thorough state inspection to verify that critical storage slots have not experienced silent data corruption.
The Ethereum Foundation expressed its gratitude to security researcher cyberthirst for responsibly identifying and disclosing the bug through the official bug bounty program, highlighting the ongoing importance of community-driven security research in maintaining the robustness of the Ethereum ecosystem.






