Skip to content
Misconfiguration Audit finding Intermediate

Project may fail to be deployed to chains not compatible with Shanghai hardfork

The contracts were compiled with Solidity 0.8.20, which emits the PUSH0 opcode introduced in the Shanghai hard fork. This could make the bytecode incompatible with supported chains that do not yet support Shanghai, and differences in bytecode between compiler versions could break deterministic contract addresses and counterfactuality.

adriro Follow

Originally disclosed on Code4rena

Submitted by adriro

Current settings may produce incompatible bytecode with some of the chains supported by the protocol.

The Ambire wallet supports and targets different chains, such as Ethereum, Polygon, Avalanche, BNB, Optimism, Arbitrum, etc. This information is available on their website.

All of the contracts in scope have the version pragma fixed to be compiled using Solidity 0.8.20. This new version of the compiler uses the new PUSH0 opcode introduced in the Shanghai hard fork, which is now the default EVM version in the compiler and the one being currently used to compile the project.

Here is an excerpt of the bytecode produced for the AmbireAccount contract, in which we can see the presence of the PUSH0 opcode (full bytecode can be found in the file artifacts/contracts/AmbireAccount.sol/AmbireAccount.json):

This means that the produced bytecode for the different contracts won’t be compatible with the chains that don’t yet support the Shanghai hard fork.

This could also become a problem if different versions of Solidity are used to compile contracts for different chains. The differences in bytecode between versions can impact the deterministic nature of contract addresses, potentially breaking counterfactuality.

Recommendation

Change the Solidity compiler version to 0.8.19 or define an evm version, which is compatible across all of the intended chains to be supported by the protocol (see https://book.getfoundry.sh/reference/config/solidity-compiler?highlight=evm_vers#evm_version).

Ivshti (Ambire) commented:

Valid finding. Do you know of any big mainstream chains that do not support PUSH0?

Picodes (judge) commented:

@Ivshti - I haven’t checked for myself, but it seems Arbitrum doesn’t support PUSH0 yet. For example https://github.com/ethereum/solidity/issues/14254

Picodes (judge) commented:

Regarding the severity of the finding, I don’t think the generic finding of “this contract uses 0.8.20, so won’t work on some L2s” is of Medium severity as there is 0 chance that this leads to a loss of funds in production (the team will obviously see that it doesn’t work and just change the compiler version).

However, in this context, I do agree with the warden that “the differences in bytecode between versions can impact the deterministic nature of contract addresses, potentially breaking counterfactuality”. Therefore, Medium severity seems appropriate.

Ivshti (Ambire) commented:

Solved.

Ambire mitigated:

Downgrade Solidity to allow deploying on pre-Shanghai networks.

Status: Mitigation confirmed. Full details in reports from adriro, carlitox477, and rbserver.


The original report as published on Code4rena, by adriro. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The project used Solidity 0.8.20 with the default EVM version, which includes the PUSH0 opcode not supported by all target chains.

Impact

The contracts could fail to deploy or run on chains that do not support the Shanghai hard fork, and bytecode differences could break deterministic contract addresses and counterfactuality.

What the attacker needed

Target chain lacks Shanghai support

The fix

The Solidity compiler version was downgraded to allow deployment on pre-Shanghai networks.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Solidity is the programming language for Ethereum contracts. Newer compiler versions can produce instructions that older blockchains do not understand. If the contract is deployed to such a chain, it may fail to run, and the contract address may differ from what was expected.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by adriro

View all

57 more disclosed reports, best first.

More from Ambire Wallet - Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.