Flow

Sablier
FoundryDeFi
20,000 USDC
View results
Submission Details
Severity: low
Invalid

[L-5] Incompatibility of PUSH0 Opcode with Non-Mainnet EVM Versions Due to Default Compiler Settings in Solidity 0.8.20

Summary:

The introduction of the PUSH0 opcode in the Solidity 0.8.20 compiler, which defaults to the Shanghai EVM version, creates a compatibility risk for smart contracts intended for deployment on non-mainnet chains. While Ethereum's mainnet and some Layer 2 solutions support this opcode, many alternative blockchains and legacy systems may not, leading to potential deployment failures.

Vulnerability Details:

The vulnerability related to the PUSH0 opcode stems from the changes in the Solidity compiler starting with version 0.8.20, which alters the default EVM version used during compilation. Below are the key aspects of this vulnerability:

  1. Introduction of PUSH0 Opcode:

    • The PUSH0 opcode allows for pushing a zero value onto the stack, which can be useful for optimizing certain operations. However, its introduction means that contracts compiled with the new settings may include this opcode in their bytecode.

  2. Default EVM Version Shift:

    • With Solidity 0.8.20, the default target EVM version has been switched to Shanghai. This change affects all contracts compiled without a specific EVM version declaration, leading to the automatic inclusion of opcodes like PUSH0.

  3. Compatibility Issues:

    • Many non-mainnet chains and some Layer 2 solutions may not support the PUSH0 opcode, as they have not adopted the latest EVM specifications. Deploying contracts with PUSH0 on these chains will lead to deployment failures, as the network cannot recognize or execute the opcode.

  4. Existing Contracts:

    • The pragma directive used in the contracts (pragma solidity >=0.8.22;) does not specify a particular EVM version, allowing the compiler to select any compatible version, including those that introduce PUSH0. This can inadvertently affect contract behavior and compatibility.

Impact:

Deployment Failures:

  • Contracts that include the PUSH0 opcode may fail to deploy on non-mainnet chains or Layer 2 solutions that do not support this opcode. This can lead to wasted gas fees and additional time spent on troubleshooting.

Operational Disruptions:

  • If contracts are inadvertently deployed to incompatible chains, they may not function as intended, leading to disruptions in services or functionalities that rely on these contracts. This could result in financial losses and operational inefficiencies.

Compatibility Risks:

  • The introduction of new opcodes and the default switch to a specific EVM version can create fragmentation within the ecosystem. Developers targeting multiple chains may face challenges ensuring consistent behavior across different environments.

Financial Implications:

  • In addition to wasted gas fees, unexpected failures can lead to direct financial losses for users relying on smart contract functionality. This can include loss of funds in applications that handle monetary transactions.

Tools Used: Slither and Aderyn.

Recommendations:

Specify the Target EVM Version:

  • Explicitly define the target EVM version in the Solidity pragma directive to ensure compatibility with the intended deployment chain

Upgrade Compiler Settings:

  • Regularly update and review the compiler settings and documentation to ensure awareness of any changes in defaults, particularly concerning EVM versions and supported opcodes.

Testing Across Environments:

  • Conduct thorough testing of smart contracts on all targeted chains, especially those that may not support the latest EVM features. Use testnets and staging environments to simulate deployments before launching on mainnet.

Fallback Options:

  • Consider implementing fallback functions or alternative logic in contracts that can handle scenarios where certain opcodes are unsupported. This ensures contracts can still function or revert gracefully in incompatible environments.

Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.