off by 1 case diff < type(uint120).max in adjust function
Summary
While during adjustment of distribution record the check for diff value is off by one.
Vulnerability Detail
The owner will call the adjust function to override the distribution record of users. To do so the owner will provide the user address and the amount to override the record by.
129 it can be observed that diff must be less then type(uint120).max. which is wrong as we have allowed the user to receive type(uint120).max value. if the owner want to reset the user to 0, the owner must provide type(uint120).max value to override user distribution record to 0.
lets assume :
Alice is illegible to receive type(uint120).max value .
The owner decided to reset Alice record to 0.
The owner Provided type(uint120).max negative value to override the user record.
The contract will revert because of require(diff < type(uint120).max, "adjustment > max uint120");
Impact
The user Distribution record will not be override if its value is type(uint120).max. although its a big value but could be possible in vesting because the vesting occur on long duration.
aman
medium
off by 1 case
diff < type(uint120).max
in adjust functionSummary
While during adjustment of distribution record the check for diff value is off by one.
Vulnerability Detail
The owner will call the
adjust
function to override the distribution record of users. To do so the owner will provide the user address and the amount to override the record by.129
it can be observed that diff must be less thentype(uint120).max
. which is wrong as we have allowed the user to receivetype(uint120).max
value. if the owner want to reset the user to 0, the owner must providetype(uint120).max
value to override user distribution record to0
. lets assume :type(uint120).max
value .type(uint120).max
negative value to override the user record.require(diff < type(uint120).max, "adjustment > max uint120");
Impact
The user Distribution record will not be override if its value is
type(uint120).max
. although its a big value but could be possible in vesting because the vesting occur on long duration.Code Snippet
https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/factory/AdvancedDistributorInitializable.sol#L124-L145 https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/abstract/AdvancedDistributor.sol#L119-L140
Tool used
Manual Review
Recommendation
change following condition: From :
To: