https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L1129-L1150
PerpetualVault::_handleReturn is the last step during a withdrawal flow. In this function, fees are refunded to the user who invoked the withdrawal if applicable.
If the user performing the withdrawal is applicable for a refund, instead of being transferred to this user, the refund will be transferred to the latest depositor of this vault.
As can be seen, the refund is done to depositInfo[counter].owner instead of depositInfo[depositId].owner.
Also, in case the latest depositor has an executionFee < usedFee (what the if above checks is depositInfo[depositId].executionFee > usedFee instead), it will underflow and revert so not letting the user to withdraw the funds.
The user withdrawing funds will not get fees refunded and/or might get the withdraw function reverted.
Manual review
Likelihood: Medium/High, when withdraw on a 1x vault. Impact: High, the fees will be distributed to the last depositor and not the withdrawer.
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.