You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
sherlock-admin opened this issue
Jul 3, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
The processWithdrawals function may cause users can't withdraw their funds forever
Summary
The processWithdrawals function in VUSD.sol doesn't handle if call function failed, this will cause users can't withdraw their funds forever.
Vulnerability Detail
The processWithdrawals function will uses the withdrawals to transfer value to users with call:
VUSD.sol
/** * @notice Process withdrawals in the queue. Sends gas token to the user. */function processWithdrawals() externaloverride whenNotPaused nonReentrant {
uint reserve =address(this).balance;
require(reserve >= withdrawals[start].amount, 'Cannot process withdrawals at this time: Not enough balance');
uint i = start;
while (i < withdrawals.length&& (i - start) < maxWithdrawalProcesses) {
Withdrawal memory withdrawal = withdrawals[i];
if (reserve < withdrawal.amount) {
break;
}
(boolsuccess, bytesmemorydata) = withdrawal.usr.call{value: withdrawal.amount}(""); // <--hereif (success) {
reserve -= withdrawal.amount;
} else {
emitWithdrawalFailed(withdrawal.usr, withdrawal.amount, data);
}
i +=1;
}
// re-entracy not possible, hence can update `start` at the end
start = i;
}
But if call failed, it will skip this withdrawal and continue, last update start. And the next call to processWithdrawals won't handle the failed withdrawal. This will cause users to never be able to withdraw their funds.
Change the logic of processWithdrawals, starting from the head of withdrawals every time, when the call is successful, delete the current withdrawal from the withdrawals. When the call fails, the withdrawal is kept and a new round of attempts is made on the next call of the processWithdrawals function.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
ver0759
medium
The processWithdrawals function may cause users can't withdraw their funds forever
Summary
The
processWithdrawals
function inVUSD.sol
doesn't handle ifcall
function failed, this will cause users can't withdraw their funds forever.Vulnerability Detail
The
processWithdrawals
function will uses thewithdrawals
to transfer value to users withcall
:But if
call
failed, it will skip thiswithdrawal
and continue, last updatestart
. And the next call toprocessWithdrawals
won't handle the failedwithdrawal
. This will cause users to never be able to withdraw their funds.Impact
Users can't withdraw their funds forever.
Code Snippet
https://github.com/sherlock-audit/2023-04-hubble-exchange/blob/main/hubble-protocol/contracts/VUSD.sol#L65-L85
Tool used
Manual Review
Recommendation
Change the logic of
processWithdrawals
, starting from the head ofwithdrawals
every time, when thecall
is successful, delete the currentwithdrawal
from thewithdrawals
. When thecall
fails, thewithdrawal
is kept and a new round of attempts is made on the next call of theprocessWithdrawals
function.Duplicate of #162
The text was updated successfully, but these errors were encountered: