{"id":4576,"date":"2026-11-26T07:15:19","date_gmt":"2026-11-26T07:15:19","guid":{"rendered":"https:\/\/smartcryptosecurity.com\/?p=4576"},"modified":"2026-11-26T07:15:19","modified_gmt":"2026-11-26T07:15:19","slug":"critical-solidity-compiler-update-released-to-address-spill-slot-collision-bug-in-ir-pipeline","status":"publish","type":"post","link":"https:\/\/smartcryptosecurity.com\/?p=4576","title":{"rendered":"Critical Solidity Compiler Update Released to Address Spill Slot Collision Bug in IR Pipeline"},"content":{"rendered":"<p><strong>The Ethereum Foundation and the Solidity development team have officially disclosed a low-to-medium severity bug within the optimizing Intermediate Representation (IR) compilation pipeline. Discovered and reported by researcher Ng Sze Hon via the Ethereum Foundation\u2019s bug bounty program on July 30, 2026, the vulnerability involves a complex stack-to-memory allocation flaw. While historical contract data scans indicate no known exploits in the wild, developers utilizing specific compiler configurations are strongly urged to upgrade to Solidity version 0.8.37.<\/strong><\/p>\n<p>The core issue stems from how the Solidity compiler handles the Ethereum Virtual Machine&#8217;s strict stack depth limitations. EVM instructions natively access a maximum of the topmost 16 stack slots. When smart contract functions contain a high volume of simultaneously live local variables, standard compilation encounters the well-known &quot;Stack too deep&quot; compilation error. To bypass this restriction, the modern IR pipeline utilizes a dedicated stack-to-memory mover\u2014often referred to as the &quot;stack limit evader.&quot; <\/p>\n<p>This utility works by relocating, or &quot;spilling,&quot; overflowing local variables to fixed memory locations known as spill slots, residing within a reserved memory region at the start of contract memory. The size of this reserved space is communicated to the internal Yul optimizer using the <code>memoryguard<\/code> builtin. Because individual spill slots are designed to be reused across functions that are never active simultaneously, the compiler must meticulously calculate memory requirements across the entire call graph.<\/p>\n<p>However, the bug manifested during the depth-first traversal of the call graph when dealing with mutual recursion. Specifically, the allocator utilized a provisional placeholder value of zero to prematurely terminate recursive search loops and prevent infinite traversal into cyclic call chains. Under precise conditions, the compiler could mistakenly read this provisional zero value as a final requirement. This undercount subsequently propagated to unrelated parts of the call graph.<\/p>\n<p>Consequently, variables belonging to entirely separate functions could be assigned the exact same memory spill slot despite both variables remaining live concurrently. During execution, one variable would silently overwrite the other, causing the affected smart contract to compute, process, and store values that were never explicitly defined in the original source code.<\/p>\n<h2>Understanding the Scope and Affected Configurations<\/h2>\n<p>The vulnerability is closely linked to, yet fundamentally distinct from, an earlier compiler flaw known as the &quot;Unsound Spill In Mutual Recursion Bug,&quot; which was patched earlier in Solidity 0.8.36. While that prior issue involved a misclassification bug where recursive functions were improperly treated as non-recursive and had their variables spilled directly, the newly discovered bug occurs even when function classification is entirely correct. In this latest scenario, non-recursive functions sharing memory offsets experience silent data corruption because of the faulty slot-allocation undercount.<\/p>\n<p>The development team has confirmed that the bug exclusively impacts the IR pipeline via the <code>--via-ir<\/code> compilation flag. The legacy <code>evmasm<\/code> compilation pipeline remains completely unaffected. Because <code>--via-ir<\/code> is not enabled by default across standard compilation setups, projects that have not explicitly opted into the IR pipeline face no risk. Furthermore, contracts lacking mutually recursive functions\u2014whether defined natively in Solidity or written as inline assembly within Yul blocks\u2014are entirely immune.<\/p>\n<p>The vulnerable code path has technically been reachable across compiler versions spanning from Solidity 0.7.2 up to and including 0.8.36, provided a specific set of rare conditions align. On versions from 0.8.21 onward, the stack-to-memory mover operates as an independent stage of the IR pipeline regardless of whether the optimizer is toggled on or off. Conversely, on older versions ranging from 0.7.2 through 0.8.20, triggering the bug additionally required passing the <code>--optimize<\/code> flag alongside <code>--via-ir<\/code>, as the Yul optimizer only executed under those conditions.<\/p>\n<p>To gauge potential real-world exposure, the Solidity team performed a comprehensive rescan of the Sourcify database, recompiling approximately 319,000 verified smart contracts using compiler builds both with and without the patch. The analysis confirmed that none of the verified contracts compiled into differing bytecode when utilizing the patched compiler, verifying that no known deployed contracts are actively impacted by the defect.<\/p>\n<h2>Technical Mechanics of the Slot Allocation Flaw<\/h2>\n<p>To fully understand how the memory collision occurs under the hood, security researchers and protocol engineers must look closely at how the compiler maps function call hierarchies. The stack-to-memory mover&#8217;s slot allocator operates by performing a depth-first search across the call graph, assigning slot requirements to every function based on its immediate requirements combined with the needs of all downstream callees.<\/p>\n<p>When a cyclical path involving mutually recursive functions is encountered, the allocator writes a provisional requirement of zero into its internal cache. This stops the traversal from descending infinitely into the cycle. The fatal flaw was that the traversal algorithm could inadvertently read this provisional zero value as a final, validated metric. When a function reached via a cycle evaluated this zero instead of the true resource requirement of its callee, that faulty calculation became permanently cached and cascaded outward to every subsequent caller in the compilation tree.<\/p>\n<p>Consider a theoretical architecture involving four functions where two functions form a mutually recursive cycle, a third function calls into that cycle, and a fourth function invokes the cycle while requiring its own dedicated memory spill slot. Because of the provisional zero read, the compiler undercalculates the total size of the reserved memory region. As a result, two separate functions end up assigned to the same memory offset. At runtime, when the outer function writes its data and subsequently invokes a subroutine, the inner subroutine overwrites the shared memory location. When the initial function attempts to read its local variable back, it retrieves the corrupted data written by the callee.<\/p>\n<p>The team noted that this miscalculation is heavily dependent on traversal order, which itself is determined by the precise layout of function calls within the generated Yul code. This structural nuance explains why the vulnerability requires such a narrow and uncommon alignment of patterns to manifest in production environments.<\/p>\n<h2>The Patch and Recommended Developer Actions<\/h2>\n<p>Solidity 0.8.37 introduces a comprehensive architectural fix to permanently resolve the slot allocation vulnerability. Instead of processing the call graph on a strictly per-function basis, the updated compiler analyzes the graph based on strongly connected components (SCCs). A strongly connected component represents a maximal set of mutually recursive functions, while every non-recursive function forms an independent component of its own.<\/p>\n<p>Within a cyclic component, every member reaches all other members, meaning individual functions cannot maintain isolated slot budgets; instead, the entire component is sized and budgeted as a single unified block. Slot requirements are calculated and cached per component rather than per function, and internal calls between members of the same component are ignored during the graph walk. Because these components form an acyclic macro-structure, a component can never be revisited while it is actively being processed. This structural guarantee eliminates provisional values entirely, ensuring that every cached requirement read by the compiler is final and accurate.<\/p>\n<p>Additionally, the Solidity engineering team has implemented a rigorous property-based fuzzing test suite. This testing framework automatically generates random, highly complex call graphs and compares exact program behaviors before and after variable spilling to prevent regressions.<\/p>\n<p>Unlike historical compiler updates that introduced breaking changes or forced developers to refactor code due to &quot;Stack too deep&quot; constraints, upgrading to Solidity 0.8.37 will not cause existing compilations to fail. The patch merely corrects the mathematical sizing of the reserved memory region and the corresponding assignment of spill slots.<\/p>\n<p>Developers maintaining Ethereum smart contracts or layer-2 protocols utilizing the experimental or production IR pipeline are advised to audit their build configurations. If a project utilizes <code>--via-ir<\/code> and incorporates mutually recursive logic\u2014particularly within complex decentralized finance architectures or automated market makers\u2014teams should immediately update their compiler version to 0.8.37 or later. While the statistical likelihood of encountering this defect remains extremely low, proactive upgrading ensures absolute cryptographic and computational integrity across all deployed decentralized applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Ethereum Foundation and the Solidity development team have officially disclosed a low-to-medium severity bug&#8230;<\/p>\n","protected":false},"author":9,"featured_media":4575,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[366],"tags":[572,401,2220,1230,201,2223,2001,5,2219,400,402,2218],"class_list":["post-4576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-smart-contract-auditing","tag-address","tag-auditing","tag-collision","tag-compiler","tag-critical","tag-pipeline","tag-released","tag-security","tag-slot","tag-smart-contracts","tag-solidity","tag-spill"],"_links":{"self":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/posts\/4576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4576"}],"version-history":[{"count":0,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/posts\/4576\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=\/wp\/v2\/media\/4575"}],"wp:attachment":[{"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smartcryptosecurity.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}