Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

According to the ZKsync documentation, the `calls` works in a different way which should be considered in the codebase

Summary

The MondrianWallet2 will be deployed to ZKsync. In ZKsync calls have some differences. The codebase should account them and the calls should be implemented in the assembly language.

Vulnerability Details

According to the ZKsync documentation, the calls have some differences from Ethereum: "Thus, unlike EVM where memory growth occurs before the call itself, on ZKsync Era, the necessary copying of return data happens only after the call has ended, leading to a difference in msize() and sometimes ZKsync Era not panicking where EVM would panic due to the difference in memory growth."

The MondrianWallet2 contract uses the solidity call function in Line 159. Instead, it should use the ZKsync call function.

Impact

The MondrianWallet2 function _executeTransaction is not fully compliant with the ZKsync Era and its differences from Ethereum.

Tools Used

Manual Review

Recommendations

The call from Line 159 of MondrianWallet2.sol can be changed to assembly code. Look at the following code.

function _executeTransaction(Transaction memory _transaction) internal {
address to = address(uint160(_transaction.to));
uint128 value = Utils.safeCastToU128(_transaction.value);
bytes memory data = _transaction.data;
if (to == address(DEPLOYER_SYSTEM_CONTRACT)) {
uint32 gas = Utils.safeCastToU32(gasleft());
SystemContractsCaller.systemCallWithPropagatedRevert(gas, to, value, data);
} else {
bool success;
- (success,) = to.call{value: value}(data);
+ assembly {
+ success := call(gas(), to, value, add(data, 0x20), mload(data), 0, 0)
+ }
if (!success) {
revert MondrianWallet2__ExecutionFailed();
}
}
}
Updates

Lead Judging Commences

bube Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Call works differently on ZKsync

Support

FAQs

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