Open hats-bug-reporter[bot] opened 5 months ago
Break keywords are working as expected. It's a gas optimisation allowing to don't iterate over all the array of merged rewards.
SDT typos are residual from our StakeDao integration.
The mecanism is :
We iterate through all the rewards coming from the service.
In this same loop, we have an other loop searching in the global reward array the position of the same token.
We are taking the iteratedTotalClaimableToken
( from the final array ) :
We so considers the issue as Invalid
Github username: @PlamenTSV Twitter username: @p_tsanev Submission hash (on-chain): 0x733ba17e245174f744b0d2b9d538414c3ed3d0c2f34b7e5b21f7ab378b50fbed Severity: medium
Description: Description\ The
claimMultipleStaking()
function, per the comments, intends to claim the accumulated rewards on Convex from different services in 1 transaction. We do so by firstly iterating over all staking services and iterating over all claimed CVX rewards of the positions. Here we iterate over a merged array of CVX rewards in the SDT claimable and have a number of sanity checks performed wrongly, which would lead to wrongly calculating_totalCvxClaimable
.Attack Scenario\ The scenario has 2 sides:
totalCvxClaimable
. Then we initialize the token and assume that we move to the next iteration_totalCvxClaimable
by the amount. In both cases we invoke thebreak
keyword with the developer assumption being, per the comment:/// @dev Pass to the next token
However invokingbreak
will stop the loop entirely, instead of moving on to the next token. Even if the next token has a claimable reward for the current position, it would not be claimed and would remain stuck, since an attempt to reclaim it would fail. The inner call tocvxStaking.claimCvgCvxMultiple
would have already claimed the position.Attachments
Recommendation Instead of invoking
break
, in order to 'skip' the current iteration, you need to invoke thecontinue
keyword and increment the the loop iterator before thecontinue
call: