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

Incorrect Position Switching Leading to Potential Trading Lock

Summary:

In perpetualVault contract, the run() function incorrectly handles position switching when transitioning between long and short positions. If been long does not match is long , the function first closes the existing position before opening the new one. However, if an unexpected failure occurs during position closure, the function will not reach the position opening step, potentially locking trading actions for affected users.

Vulnerability Details:

The function performs a forced position close before opening a new position, but it does not account for failure cases

Impact:

If position closure fails, users cannot execute new trades, potentially causing financial losses.

Tools Used:

  • Manual review

  • Foundry/Hardhat Testing – Simulation of failure cases forcing _createDecreasePosition() to fail

Recommendations:

Validate that _createDecreasePosition() completes before updating nextAction.

# code block
bool positionClosed = _createDecreasePosition(0, 0, beenLong, acceptablePrice, prices);
// Only proceed if the position was successfully closed
if (positionClosed) {
nextAction.selector = NextActionSelector.INCREASE_ACTION;
nextAction.data = abi.encode(isLong);
} else {
nextAction.selector = NextActionSelector.NONE;
nextAction.data = "";
emit PositionCloseFailed(beenLong, acceptablePrice);
}
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
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.