The cancelFlow function incorrectly refunds execution fees to the owner of the latest deposit instead of the current deposit being canceled. This is due to referencing depositInfo[counter] instead of using depositId extracted from flowData.
The cancelFlow function is triggered by an off-chain keeper when a GMX order continuously fails.
If the flow is in DEPOSIT, it returns collateral to the deposit owner, removes the deposit from tracking structures, refunds the execution fee, and deletes deposit information.
If the flow is in WITHDRAW, it only refunds the execution fee.
However, when refunding execution fees, the function references depositInfo[counter], which always points to the last deposit made.
This means that if a user cancels an earlier deposit, the execution fee refund could be sent to the wrong owner.
Users may not receive their rightful refund if the execution fee is mistakenly sent to the latest depositor instead of the current one.
Manual Review
Extract the current withdrawal depositId and point to it.
Likelihood: Low, contract has to call cancelFlow after a withdraw, and the settle action is already executed by GMX. 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.