DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Incomplete Withdrawal State Handling

Summary

The PerpetualVault._handleReturn function does not account for partial withdrawals during position closure.
If multiple withdrawals occur while closing a position, this check may allocate funds incorrectly.

Vulnerability Details

Multiple withdrawals could split collateral unevenly if the position is partially closed.

POC

contract TestWithdrawalHandling is Test {
PerpetualVault vault;
MockCollateralToken token;
function setUp() public {
vault = new PerpetualVault();
token = new MockCollateralToken();
}
function testPartialWithdrawalIssue() public {
vault.deposit(1000);
vault.withdraw(500); // Partial withdrawal
vault.withdraw(500); // Another partial withdrawal
uint256 balance = vault.getUserBalance(msg.sender);
assertEq(balance, 0, "Collateral should be fully withdrawn but might be misallocated");
}
}

Impact

Users may receive incorrect withdrawal amounts during concurrent operations.

Tools Used

Manual Review
Foundry

Recommendations

Maintain explicit withdrawal state tracking instead of relying solely on balanceOf.

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

Suppositions

There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

Suppositions

There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!