Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

HHK - computePoolAddress() will not work on ZkSync Era #104

Open
sherlock-admin2 opened this issue Oct 23, 2023 · 3 comments
Open

HHK - computePoolAddress() will not work on ZkSync Era #104

sherlock-admin2 opened this issue Oct 23, 2023 · 3 comments
Assignees
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Won't Fix The sponsor confirmed this issue will not be fixed

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Oct 23, 2023

HHK

medium

computePoolAddress() will not work on ZkSync Era

Summary

When using the wagmi protocol, multiple swap can happen when borrowing or repaying a position. When the swap uses Uniswap v3 it checks that the callback is a pool by computing the address but the computation won't match on ZkSync Era.

Vulnerability Detail

When borrowing or repaying a position a user can either use a custom router that was approved by the wagmi team to make the swaps required or can use Uniswap v3 as a fallback.

When using the Uniswap v3 as a fallback the _v3SwapExactInput() internal function is being called. This function uses computePoolAddress() to find the pool address to use. computePoolAddress() is also used during the uniswapV3SwapCallback() to make sure the msg.sender is a valid pool.

On ZkSync Era the create2 addresses are not computed the same way see here.

This will result in the swaps on Uniswapv3 to revert. If a user was able to open a position using a custom router but the custom router is removed later on by the team or if the liquidity was one sided so no swap happened. The borrower and liquidators could find themself not able to close the positions until a new router is whitelisted.

The borrower could be forced to pay collateral for a longer time as he won't be able to close his position.

Impact

Medium. Unlikely to happen but would result in short-term DOS and more fees paid by the borrower.

Code Snippet

https://github.com/sherlock-audit/2023-10-real-wagmi/blob/b33752757fd6a9f404b8577c1eae6c5774b3a0db/wagmi-leverage/contracts/abstract/ApproveSwapAndPay.sol#L146
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/b33752757fd6a9f404b8577c1eae6c5774b3a0db/wagmi-leverage/contracts/abstract/ApproveSwapAndPay.sol#L204
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/b33752757fd6a9f404b8577c1eae6c5774b3a0db/wagmi-leverage/contracts/abstract/ApproveSwapAndPay.sol#L271

Tool used

Manual Review

Recommendation

Consider calling the Uniswap factory getter getPool() to get the address of the pool.

@github-actions github-actions bot added Medium A valid Medium severity issue Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Oct 26, 2023
@fann95 fann95 added Disagree With Severity The sponsor disputed the severity of this issue Won't Fix The sponsor confirmed this issue will not be fixed Non-Reward This issue will not receive a payout labels Oct 29, 2023
@fann95
Copy link

fann95 commented Oct 29, 2023

This is too obvious a problem with which this project simply will not work. We know about this, so we will make changes before deployment in ZkSync Era.

@fann95 fann95 self-assigned this Oct 29, 2023
@Czar102
Copy link

Czar102 commented Oct 30, 2023

As the contest readme states, watsons were to consider zkSync as one of the chains the code in scope was to be deployed on. If watsons couldn't have known that a modification of the code in scope would be deployed on zkSync, I don't see a reason to invalidate this issue, even if it was previously considered by the protocol team and/or is trivial.

@fann95
Copy link

fann95 commented Oct 30, 2023

I’m pasting the solution for Sherlock, but we don’t plan to make any fixes to this issue right now.

@cvetanovv cvetanovv removed Non-Reward This issue will not receive a payout Disagree With Severity The sponsor disputed the severity of this issue labels Oct 30, 2023
@sherlock-admin2 sherlock-admin2 changed the title Rough Pearl Wombat - computePoolAddress() will not work on ZkSync Era HHK - computePoolAddress() will not work on ZkSync Era Oct 30, 2023
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Oct 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Won't Fix The sponsor confirmed this issue will not be fixed
Projects
None yet
Development

No branches or pull requests

4 participants