Oversight in _handleReturn()
Use this -> Replace depositInfo[counter]
with depositInfo[depositId]
Root Cause & Where It Happens
Look at the snippet from _handleReturn()
(near the end of the function):
Notice the mismatch:
The if-check uses:
That’s correct for the deposit currently being withdrawn (depositId
).
But the actual refund call references:
instead of depositInfo[depositId].owner
and depositInfo[depositId].executionFee
.
This is essentially the same category of bug exist in _cancelFlow()
, but in a different location.
Proven Loss
When a user finalizes their withdrawal and triggers _handleReturn(..., refundFee = true)
, the code intends to refund any leftover gas fee to that user’s deposit.
Instead, it refunds to whatever deposit is at depositInfo[counter]
.
If counter
points to a different user’s deposit (which it almost always will, especially if more deposits happened after the withdrawing user’s deposit was created), the wrong user gets the leftover fee.
If depositInfo[counter]
is unset or already deleted, this call will effectively do nothing or revert in the try
block.
Either ways, the user who rightfully should have gotten some portion of their leftover execution fee is denied that refund. This can't be theoretical: the code path is there, it will definitely misdirect or fail the refund whenever _handleReturn()
tries to do a refundExecutionFee()
call.
Severity by Likelyhood & impact
This is at least medium severity: although it does not allow vault draining, it results in direct user fund loss (the leftover execution fee) whenever a withdrawal flow tries to refund. Over time, multiple users can be affected if they frequently deposit/withdraw and rely on leftover fee refunds.
FIX
In _handleReturn()
:
This parallels the fix you would do in _cancelFlow()
, ensuring we always reference depositInfo[depositId]
instead of depositInfo[counter]
.
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.