Closed sherlock-admin closed 9 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid because { Since the fastWithdraw is a governance job to activate; i consider this invalid vecause they will makesure that there is no active requestWithdraw}
Invalid, if user wants to inititate a time delayed request for withdrawal when fast withdrawal is active, sure he can do that, no issue here (I see no point in doing that). Additionally, initiating fast withdrawal is an admin gated mechanism.
bitsurfer
medium
pendingPrimaryWithdraw
,pendingSecondaryWithdraw
is not cleared out on_withdraw
resulting user can have instant withdrawal whenfastWithdraw
is disabledpendingPrimaryWithdraw
,pendingSecondaryWithdraw
is not cleared out on_withdraw
resulting user can have instant withdrawal whenfastWithdraw
is disabledSummary
pendingPrimaryWithdraw
,pendingSecondaryWithdraw
should be cleared out on_withdraw
in case of user perform arequestWithdraw
while thefastWithdraw
is enabled to withdraw their asset.Vulnerability Detail
Normally, withdrawing will require a certain delay or timelock, but if
fastWithdraw
is active, user can withdraw directly without need to wait withdraw timelock expired.The issue here is that, when
fastWithdraw
is enabled but user dorequestWithdraw
,withdrawExecutionTimestamp
is not cleared. Thus if thefastWithdraw
is disabled later, user can execute the next withdrawal without any timelock.This also makes,
pendingPrimaryWithdraw
andpendingSecondaryWithdraw
are not cleared when user actually executefastWithdraw
.those variables
pendingPrimaryWithdraw
,pendingSecondaryWithdraw
andwithdrawExecutionTimestamp
should be cleared when the_withdrawal
executed. Currently only by callingexecuteWithdraw
thependingPrimaryWithdraw
andpendingSecondaryWithdraw
are cleared to 0.Even though this seems not important or part of user mistakes, but this can potentially skip the timeout with this case:
pendingPrimaryWithdraw
andpendingSecondaryWithdraw
, and guarantee to instant executeWithdrawalAlso, the state of user will be wrong, for example executing
executeWithdrawPrimaryAsset
onDegenSubaccount
will not be valid since it will fetchgetCreditOf
which is out of state.Impact
unsynced state between
primaryCredit
andpendingPrimaryWithdraw
, and also user can execute instant withdrawal even though the fastWithdrawal is disabledCode Snippet
https://github.com/sherlock-audit/2023-12-jojo-exchange-update/blob/main/smart-contract-EVM/src/libraries/Funding.sol#L78-L80
Tool used
Manual Review
Recommendation
Consider to clear out the
pendingPrimaryWithdraw
,pendingSecondaryWithdraw
,withdrawExecutionTimestamp
on_withdraw
function