Home / Smart Contract Auditing / Solidity 0.8.37 Patches IR-Based Code Generator Bug Affecting Named Custom Errors in Require Statements

Solidity 0.8.37 Patches IR-Based Code Generator Bug Affecting Named Custom Errors in Require Statements

On February 4, 2026, security researchers reported a notable compiler bug within the Intermediate Representation (IR)-based code generator of the Solidity programming language. The vulnerability, discovered by Carl of Cantina Security through the official Ethereum Foundation bug bounty program, centers on how arguments for custom errors are handled when passed to require statements using named-parameter syntax. Due to an oversight in the code generation pipeline, the arguments were incorrectly placed onto the evaluation stack in call-site order rather than adhering to the expected declaration order before undergoing ABI encoding.

The issue originated in Solidity version 0.8.26, a release that notably introduced the capability to pass custom errors as the second argument to require statements, allowing developers to attach descriptive error data alongside conditional checks. With the release of Solidity 0.8.37, the Ethereum Foundation’s Solidity team has deployed a comprehensive fix to resolve the stack-ordering discrepancy.

Core developers assigned the vulnerability a severity rating of "very low," explaining that the issue did not warrant an expedited emergency release cycle. Because the affected code path strictly handles the construction of revert data for transactions that are already slated to fail and revert, the bug has zero direct impact on a smart contract’s state, storage variables, or successful execution flows. Furthermore, triggering the flaw requires a very specific combination of conditions: a custom error must be passed to a require statement, instantiated utilizing named arguments in an order that deviates from the original error declaration, and compiled exclusively through the IR-based pipeline. Other language constructs that process similar execution paths were thoroughly audited during the due diligence phase surrounding the fix and confirmed to be completely unaffected.

Technical Details

To understand the mechanics of the

bug, it is necessary to examine how custom errors are declared, called, and encoded within the Ethereum Virtual Machine ecosystem. A custom error declaration explicitly dictates the exact sequence of its parameters, which in turn defines its cryptographic ABI signature and the precise layout of its encoded byte payload. For instance, declaring a custom error with multiple parameters establishes a strict layout rule. However, Solidity permits developers to invoke these errors at call sites using named arguments, optionally mixing up the sequence compared to how the parameters were initially declared in the contract or interface.

The Solidity compiler’s type checker is designed to bind named arguments to their corresponding parameters by name, allowing any permutation of parameters as long as every declared parameter is explicitly mentioned exactly once. The type system does not enforce that the call-site ordering must mirror the declaration order. Consequently, the bug could be triggered by any permutation of arguments. This included simple swaps of two arguments sharing the exact same data type—a scenario where static analysis tools, compilers, and decoders could easily miss the mistake due to a lack of type mismatch warnings. More covertly, the compiler would also silently encode reorderings involving arguments of entirely different types without raising any compilation errors or warnings.

Tracing the argument lifecycle from the source code down to the final revert data reveals where the compiler diverged. The compiler emits low-level instructions that evaluate arguments and push them onto the evaluation stack in declaration order. Subsequently, the ABI encoder walks through the error’s parameter list, taking the requisite slots from the stack for each parameter and appending their encoded byte sequences to the revert data payload. While most standard types occupy a single stack slot, certain data structures require more. External function pointers consume two slots, dynamic calldata arrays utilize an extra slot to track their length, and string literals occupy zero slots because their values are hard-coded directly into the encoder. Because the EVM stack is fundamentally a sequence of untyped slots without explicit boundaries marking where one argument concludes and another begins, the encoder relies heavily on the assumption that items arrive in the expected sequence.

In the IR-based code generator, the lowering phase for require statements utilizing custom errors omitted the essential reordering step. Instead of aligning parameters to their declarations, it pushed the arguments in the exact order they were written at the call site, while the encoder blindly consumed them according to the declaration order. Consequently, if a contract reverted, off-chain decoders would parse the misplaced words and interpret the values incorrectly, reading swapped parameters instead of the intended source-level variables. Standalone revert ErrorName(...) statements were routed through a completely separate code path that correctly reordered arguments prior to encoding, leaving them entirely unimpacted by the flaw.

Misinterpreted Values and Multi-Slot Argument Misalignment

The ramifications of the bug varied depending on the types of the reordered arguments. When developers swapped parameters of different types that coincidentally occupied the same number of stack slots, such as a uint256 and an address, the resulting payload remained structurally valid but contained fundamentally corrupted values. Each parameter simply landed in the other’s designated position and was erroneously interpreted as the wrong data type.

A similar issue occurred with reference types. Swapping a standard uint256 integer with a memory array caused the encoder to treat the integer value as a memory offset, encoding whatever random data resided at that memory location as the array contents, while the array offset was misinterpreted as the integer. Equivalent misalignments occurred when swapping two distinct reference types, such as a memory array and a storage array, or two different structs with contrasting field layouts.

The situation grew more pronounced when the reordered arguments occupied differing numbers of stack slots. Although each argument’s individual slots arrived at the encoder grouped together, the encoder split the stack based on the declaration order, causing the argument boundaries to mismatch entirely. Parameters were consequently handed stack slots that belonged to entirely different arguments. Because string literals occupy zero slots, they could not shift surrounding values, meaning that reordering string literals alone did not trigger the bug. However, combining dynamic types like strings with fixed-size types like integers produced severe misalignment.

In affected scenarios, an encoding helper might read offset fields from value-type slots and length fields from calldata offsets, leading to unpredictable byte copying. Depending on the specific values involved, this mis-encoding could trigger an EVM-level execution error, causing the transaction to revert abruptly without producing any decodable custom error data whatsoever. In other instances, the contract would revert with a payload that coincidentally matched the correct ABI signature and decoded successfully on the surface, yielding plausible-looking numbers that bore no relation to the actual variables passed in the source code. This latter outcome posed significant challenges, as consumers attempting to decode the error observed seemingly valid data that was entirely misleading.

Severity Assessment

Because the vulnerability exclusively impacted the generation of revert data for transactions that were already destined to fail and revert, it could not alter contract storage, alter successful return values, or interfere with external calls made during normal execution flows. Revert data remains observable on-chain through mechanisms such as try/catch blocks or low-level CALL opcodes, though such programmatic handling of revert payloads is relatively rare in production environments. The primary fallout affected off-chain consumers—including block explorers, indexers, automated test frameworks, and error-decoding libraries—that parse revert payloads assuming correct formatting.

Standards that embed revert data directly into a contract’s operational interface, such as ERC-3668 for CCIP Read, were a key consideration during the severity evaluation. ERC-3668 relies heavily on client applications successfully decoding the OffchainLookup custom error to fetch necessary off-chain data. While the standard incorporates safeguards against malicious or forged errors, those protections cannot automatically correct mis-encoded payloads generated by an honest contract compiled with a flawed toolchain. Because OffchainLookup incorporates a mixture of dynamic and value types, an affected require statement could produce a payload that passes basic decoding checks while carrying entirely corrupted values, disrupting lookup workflows silently.

Security analysts confirmed that the bug offered no viable vector for third-party exploitation. External attackers could not artificially inject mis-encoding into an otherwise sound contract, as the flawed named-argument structure had to be explicitly authored into the contract’s source code. Furthermore, an attacker seeking to feed misleading revert data to a user or interface could easily achieve the same result by deploying a custom contract that intentionally reverts with arbitrary byte data. The risk was thus strictly confined to developers unknowingly deploying contracts that emitted erroneous data to trusted off-chain parsers.

Given that named-argument syntax is infrequently utilized inside require statements within real-world codebases, the bug managed to persist unobserved for nearly two years. The narrow set of preconditions required for manifestation, combined with the read-only impact on reverting execution paths and the total absence of external exploit vectors, cemented the decision by Solidity maintainers to classify the vulnerability as "very low" severity.

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *