Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Slippage Protection When Mint Liquidity #204

Closed
c4-bot-5 opened this issue Apr 18, 2024 · 7 comments
Closed

No Slippage Protection When Mint Liquidity #204

c4-bot-5 opened this issue Apr 18, 2024 · 7 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-537 🤖_204_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@c4-bot-5
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/PanopticFactory.sol#L335

Vulnerability details

Impact

There is no slippage protection during the minting of full-range-liquidity. In the process, the slot0 is queried and there is no check from the user that the liquidity should be within an acceptable range. Thus user may suffer from loss when providing liquidity in Uniswap V3.

Proof of Concept

In PanopticFactory::deployNewPool, the full-range liquidity should be provided by msg.sender.

        // Mints the full-range initial deposit
        // which is why the deployer becomes also a "donor" of full-range liquidity
        // The SFPM will `safeTransferFrom` tokens from the donor during the mint callback
        (uint256 amount0, uint256 amount1) = _mintFullRange(v3Pool, token0, token1, fee);

In the _mintFullRange, the IUniswapV3Pool(v3Pool).mint is being called. But there is no slippage protection during the minting of full-range-liquidity. In the process, the slot0 is queried and there is no check from the user that the liquidity should be within an acceptable range.

        (uint160 currentSqrtPriceX96, , , , , , ) = v3Pool.slot0();
        ...
        return
            IUniswapV3Pool(v3Pool).mint(
                address(this),
                tickLower,
                tickUpper,
                fullRangeLiquidity,
                mintCallback
            );

Thus, if the pool has gone through prices changes before the mint, the user may suffer from slippage loss.

Tools Used

Manual

Recommended Mitigation Steps

It is recommended to add slippage protection in the function PanopticFactory::deployNewPool.

Assessed type

MEV

@c4-bot-5 c4-bot-5 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Apr 18, 2024
c4-bot-1 added a commit that referenced this issue Apr 18, 2024
@c4-bot-12 c4-bot-12 added the 🤖_204_group AI based duplicate group recommendation label Apr 22, 2024
@c4-judge
Copy link
Contributor

Picodes marked the issue as unsatisfactory:
Invalid

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Apr 24, 2024
@c4-judge
Copy link
Contributor

Picodes marked the issue as unsatisfactory:
Invalid

@Picodes
Copy link

Picodes commented Apr 24, 2024

It's a new pool so by definition there is no price to manipulate yet

@jes16jupyter
Copy link

Hi @Picodes I guess it's the duplicate of #537. Suffering from v3Pool.slot0() which could be manipulated.

@c4-judge
Copy link
Contributor

c4-judge commented May 9, 2024

Picodes marked the issue as duplicate of #537

@Picodes
Copy link

Picodes commented May 9, 2024

Indeed, thanks for flagging

@c4-judge
Copy link
Contributor

c4-judge commented May 9, 2024

Picodes marked the issue as satisfactory

@c4-judge c4-judge added satisfactory satisfies C4 submission criteria; eligible for awards and removed unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-537 🤖_204_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

5 participants