Claiming rewards may DoS due to underflow from unsafe casting in RewardsDistributorV2
Summary
Claiming rewards may DoS due to unsafe casting from int256 to uint256, which will underflow to uint max if int256 is negative. This will DoS claiming rewards for the respective token id.
Vulnerability Detail
The following function updates the total supply checkpoint, which will be used for distributing rewards:
If int256(old_user_point.bias - dt * old_user_point.slope) < 0, then casting to a uint will underflow to type(uint).max, causing DoS either due to to_distribute calculation reverting from overflow or insufficient funds when transferring the rewards to the user.
In this case, the user_epoch_of and time_cursor_of mappings will not be updated, so it will continue to use the old_user_point values and consistently DoS due to overflow, making rewards unclaimable for the token id.
Impact
Unclaimable rewards, denial of service, loss of funds.
cryptic
Medium
Claiming rewards may DoS due to underflow from unsafe casting in
RewardsDistributorV2
Summary
Claiming rewards may DoS due to unsafe casting from int256 to uint256, which will underflow to
uint max
if int256 is negative. This will DoS claiming rewards for the respectivetoken id
.Vulnerability Detail
The following function updates the total supply checkpoint, which will be used for distributing rewards:
RewardsDistributorV2.sol#L195-L215
Looking at the following line:
If
int256(old_user_point.bias - dt * old_user_point.slope) < 0
, then casting to auint
will underflow totype(uint).max
, causing DoS either due toto_distribute
calculation reverting from overflow or insufficient funds when transferring the rewards to the user.In this case, the
user_epoch_of
andtime_cursor_of
mappings will not be updated, so it will continue to use theold_user_point
values and consistently DoS due to overflow, making rewards unclaimable for thetoken id
.Impact
Unclaimable rewards, denial of service, loss of funds.
Code Snippet
https://github.com/sherlock-audit/2024-06-velocimeter/blob/main/v4-contracts/contracts/RewardsDistributorV2.sol#L142-L163
Tool used
Manual Review
Recommendation
Consider making the following changes in
RewardsDistributorV2::_claim
and all other instances whereMath.max(uint(int256...), 0)
is used: