You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.
sherlock-admin opened this issue
Oct 23, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
Protocol is not usable & possible lock of funds on zksync because of wrong address computation
Summary
The Wagmi Leverage Protocol is supposed to be deployed on many chains, including the zksync Era chain.
On multiple occurences the address of the UniswapV3 pool to use is computed by using the deterministic way the create2 opcode for EVM works, which is different for zkSync ERA.
This results in the protocol not being correctly usable and the possibility for funds to be locked.
Vulnerability Detail
The contracts interact with UniswapV3 pools several times. The address of the pool is always computed by the contract using the UNDERLYING_V3_POOL_INIT_CODE_HASH the UNDERLYING_V3_FACTORY_ADDRESS and the salt which is the hash of the tokens and the fee.
This works, as the UniswapV3 pools are created by the Factory using the create2 opcode, which gives us an deterministic address based on these parameters. (see here
However, the address derivation works different on the zkSync Era chain, as they are stating in their docs.
This will result in the computed address inside the contract to be wrong, which make any calls to these going to be reverted, or giving unexpected results.
As there is a possibility for the borrow function to go work fine, as the computed address will not be used, there is a potential for getting funds into the Vault. However, these would be locked forever, as every possible code path of the repay function is relying on the computed address of the UniswapV3 pool.
As zkEVM differs in some points from the EVM, i would consider writing a slightly adjusted version of the contract for zkEVM, in regards to the differences mentioned in their docs
sherlock-admin
changed the title
Precise Ceramic Donkey - Protocol is not usable & possible lock of funds on zksync because of wrong address computation
shogoki - Protocol is not usable & possible lock of funds on zksync because of wrong address computation
Oct 30, 2023
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
shogoki
medium
Protocol is not usable & possible lock of funds on zksync because of wrong address computation
Summary
The Wagmi Leverage Protocol is supposed to be deployed on many chains, including the zksync Era chain.
On multiple occurences the address of the UniswapV3 pool to use is computed by using the deterministic way the
create2
opcode for EVM works, which is different for zkSync ERA.This results in the protocol not being correctly usable and the possibility for funds to be locked.
Vulnerability Detail
The contracts interact with UniswapV3 pools several times. The address of the pool is always computed by the contract using the
UNDERLYING_V3_POOL_INIT_CODE_HASH
theUNDERLYING_V3_FACTORY_ADDRESS
and thesalt
which is the hash of the tokens and the fee.This works, as the UniswapV3 pools are created by the Factory using the
create2
opcode, which gives us an deterministic address based on these parameters. (see hereHowever, the address derivation works different on the zkSync Era chain, as they are stating in their docs.
This will result in the computed address inside the contract to be wrong, which make any calls to these going to be reverted, or giving unexpected results.
As there is a possibility for the
borrow
function to go work fine, as the computed address will not be used, there is a potential for getting funds into the Vault. However, these would be locked forever, as every possible code path of therepay
function is relying on the computed address of the UniswapV3 pool.Impact
Code Snippet
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/abstract/ApproveSwapAndPay.sol#L211-L213C16
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/abstract/ApproveSwapAndPay.sol#L271C4-L291C6
Tool used
Manual Review
Recommendation
As zkEVM differs in some points from the EVM, i would consider writing a slightly adjusted version of the contract for zkEVM, in regards to the differences mentioned in their docs
Duplicate of #104
The text was updated successfully, but these errors were encountered: