Closed c4-bot-7 closed 7 months ago
141345 marked the issue as primary issue
low decimal with big totalSupply group several reports on the same block of code, but some dup only addresses low decimal, or only totalSupply
141345 marked the issue as sufficient quality report
no factor
0xCalibur (sponsor) disputed
I would think it's dust loss, the rewardRate in the example is very small
thereksfour changed the severity to QA (Quality Assurance)
This previously downgraded issue has been upgraded by thereksfour
thereksfour marked issue #222 as primary and marked this issue as a duplicate of 222
thereksfour marked the issue as partial-75
Lines of code
https://github.com/code-423n4/2024-03-abracadabra-money/blob/main/src/staking/LockingMultiRewards.sol#L528-#L534
Vulnerability details
Vulnerability details
Whenever any operation with the given user as a beneficiary is performed, this user's rewards are checkpointed via function
_updateRewardsGlobal()
, which calculates the reward checkpoint by a call to function_rewardPerToken
rewardRate
is set innotifyRewardAmount
function as below:It is clearly that
pendingRewardsPerToken
can be equal to 0. Consider this mock scenario:timeElapsed
= 12 seconds (equal to the time of a block)_rewardData[rewardToken].rewardRate
= 2totalSupply_
= 1e22_rewardData[rewardToken].rewardPerTokenStored
= xSo the result of the function is
x + 12 * 2 * 1e18 / 1e22
Which is equal tox + 24e18 / 1e22
=x
due to rounding downWhich is incorrect as the calculation does not account for the rewards accumulated since the last checkpoint.
Attacker can griefing attack by continously calling
stake
orlock
function with dust amount, since they only revert when amount = 0:Impact
Incorrect checkpoint value being stored for the beneficiary, which will affect future reward calculations for this beneficiary.
Tools Used
Manual review
Recommended Mitigation Steps
Use validation checks to ensure that the required calculation doesn't round down to zero:
Assessed type
Other