`computePoolAddress()` will not work on ZkSync Era
The contract computes Uniswap v3 pool addresses using a method that does not match ZkSync Era's address derivation, so the callback check fails and swaps revert. This could prevent borrowers and liquidators from closing positions if the custom router is removed, leading to a short-term denial of service and extra fees.
Source: https://github.com/sherlock-audit/2023-10-real-wagmi-judging/issues/104
Found by
0x52, HHK, shogoki
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.
Discussion
fann95
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.
Czar102
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
I’m pasting the solution for Sherlock, but we don’t plan to make any fixes to this issue right now.
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
Impact
Medium: unlikely to happen but would result in short-term denial of service and more fees paid by the borrower.
What the attacker needed
Deployment on ZkSync Era; custom router removed or one-sided liquidity
The fix
The recommendation is to call the Uniswap factory getter `getPool()` to get the address of the pool; the team said they will make changes before deployment on ZkSync Era but do not plan to fix this issue right now.
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.
This is about a smart contract on a blockchain called ZkSync Era. The contract tries to guess the address of a trading pool using a formula that works on Ethereum but not on ZkSync Era, so the guess is wrong and trades fail. That means users might not be able to close their positions, and they could keep paying fees.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.