Closed c4-submissions closed 10 months ago
DadeKuma marked the issue as primary issue
DadeKuma marked the issue as insufficient quality report
0xean marked the issue as unsatisfactory: Insufficient quality
0xean marked the issue as unsatisfactory: Insufficient quality
@0xean hey! I was referring to the issue described in this post https://jeiwan.net/posts/public-bug-report-uniswap-swaprouter/. There is a possibility that there is not enough liquidity in ZETA/WETH pool to fully utilize provided token amount, as a result uniswapV3Router.exactInput(params)
will be executed partially. In case of EOA, unutilized tokens are returned back, but since we are using a consumer contract, they will be sent to it's address and there is no way to retrieve them back.
Also there is a same issue in history that was judged as a valid Medium https://github.com/code-423n4/2023-05-juicebox-findings/issues/162
Thank you!
If a reasonable min amount out is supplied, the transaction simply reverts.
consumer.getZetaFromEth{value: 100e18}(alice, 0);
you are calling it with 0 as the min amount out which is user error.
Lines of code
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol#L74-L183 https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol#L103-L207
Vulnerability details
Impact
During swap operations the user needs to transfer tokens to the consumer contract or send ETH directly. https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol#L107-L118
after that, contract will attempt to swap tokens on Uniswap.
sqrtPriceLimitX96
is set to zero, this way router attempts to utilize all liquidity in the pool. However, there is a possibility that there is not enough liquidity in the pool for a given amount, in which case the swap will be partially executed. https://github.com/Uniswap/v3-core/blob/main/contracts/UniswapV3Pool.sol#L640-L650What happens to tokens provided by the user?
Proof of Concept
Here is the case for the ETH->ZETA swap written for Forge.
Tools Used
Foundry, forge-std lib
Recommended Mitigation Steps
We need to send the excess tokens back to
msg.sender
or call router functionrefundETH
after the swap.Assessed type
Uniswap