The lender won't be able to claim rewards in some cases and most of RewardsManager's methods (e.g. staking, unstaking ..etc) will revert. #354
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-440
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
upgraded by judge
Original issue severity upgraded from QA/Gas by judge
Lines of code
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/RewardsManager.sol#L719-L726
Vulnerability details
Impact
In RewardsManager, when claiming the rewards,
_updateBucketExchangeRates
method is called. This method does the following:_updateBucketExchangeRateAndCalculateRewards
)updatedRewards_
to track the total rewards.Since rewardsClaimedInEpoch is always supposed to be not be greater than rewardsCap we have no revert issue (note: the method reverts if rewardsCap is lower than rewardsClaimedInEpoch). However, to guarantee this, totalBurned should never decrease. In other words, if totalBurned went from a high to low value at any point, then rewardsCap will follow. If we check how totalBurned is calculated, we notice that there is a possibilty that this happens.
totalBurnedLatest => total burned of current epoch
totalBurnedAtBlock => total burned of previous epoch
If totalBurnedLatest equals zero, it takes the difference between totalBurnedLatest and totalBurnedAtBlock. otherwise, it takes totalBurnedAtBlock. because of this logic, it is possible that we have the following:
Now. since totalBurned went lower, rewardsCap will go lower as well.
The issue is that, in case the above happens, updateRewardsClaimed in epoch will be greater than rewardsCap and this condition will be true regardless of how much updatedRewards_ the user should receive
This results in a revert in the following line since rewardsCap is lower than rewardsClaimedInEpoch:
Therefore, the user won't be able to claim rewards in such situations. And since claim rewards is also done upon staking, unstaking and moveStakedLiquidity, all of those will revert due to this issue.
Proof of Concept
Please check above for explanation.
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/RewardsManager.sol#L719-L726
Tools Used
Manual analysis
Recommended Mitigation Steps
Check if rewardsCap is lower than rewardsClaimedInEpoch, set updatedRewards_ to zero.
Assessed type
DoS
The text was updated successfully, but these errors were encountered: