The vulnerability exists in PerpetualVault where users receive zero or near-zero shares when there is pending deposit (flow == DEPOSIT) and right before runNextAction() liquidation is executed by gmx keeper. This occurs due to incorrect price impact calculations in the absence of an active position, leading to excessive deductions from the deposit amount during share minting.
The vulnerability manifests when:
A position is liquidated while a subsequent deposit is pending
The runNextAction() processes the pending deposit (1.2 could be even in one block one-by-one);
The problem code zone is:
So if priceImpact is positive it is actually deducted from amount to be minted. Let's look at how priceImpact is calculated:
So int256 priceImpactInTokens = expectedSizeInTokensDelta.toInt256() - realSizeInTokensDelta.toInt256();
While expectedSizeInTokensDelta it's ovbious that this is sizeDeltaInUsd / prices.indexTokenPrice.min; but realSizeInTokensDelta will be 0 because at the moment of runNextAction() by gamma keeper position has been liquidated. thus realSizeInTokensDelta = 0; //flowData too is 0;
This mean priceImpactInTokens will be equal expectedSizeInTokensDelta;
What leads EVM to drop in this block:
As we see amount [depositInfo[counter].amount;] minus priceImpact[sizeDeltaInUsd / prices.indexTokenPrice.min;] will leads to mint increased zero or near zero or even revert in some cases.
Depositors receive virtually no shares for their deposits or potential revert in some cases;
Funds locked in the contract.
Manual review
Consider to add in runNextAction() additional check whether position has been liquidated or not before proceed deposits.
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.