Closed c4-bot-9 closed 8 months ago
no factor
141345 marked the issue as insufficient quality report
similar to https://github.com/code-423n4/2024-03-abracadabra-money-findings/issues/166, but lack detailed POC why rounding could have problem
Invalid, 1e18 is the amplifier for rewardPerToken_ to prevent rounding losses, divided by 1e18 is the correct reward amount
thereksfour marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-03-abracadabra-money/blob/1f4693fdbf33e9ad28132643e2d6f7635834c6c6/src/staking/LockingMultiRewards.sol#L292-L295
Vulnerability details
[M-08] Incorrect rewards calculation with low balances (rounding down to zero)
Impact
In
LockingMultiRewards
contract: whenever a user stakes, withdraws or claims his rewards; his rewards are updated via_updateRewardsForUser()
function, where it loops over reward tokens and updates therewards[user_][token_]
via_udpateUserRewards()
function:But as can be noticed from
_earned()
function; if thebalance_ * pendingUserRewardsPerToken
is less than 1e18, it will be rounded down to zero and the_earned()
function will return the same old value without update.Proof of Concept
LockingMultiRewards._earned function
Tools Used
Manual Review.
Recommended Mitigation Steps
Implement a mechanism that prevents updating the
rewards[user_][token_]
if(balance_ * pendingUserRewardsPerToken)
is < 1e18 .Assessed type
Math