The AdvancedDistributor::adjust() function decreases the allocated token amount of a user without adequately checking against the claimed token amount. This can lead to a scenario where the decreased token amount is greater than the pending claimable token amount, resulting in insufficient token balance in the contract.
Vulnerability Detail
For example, assume distributionRecord.total = 1000e18 and records[beneficiary].claimed = 800e18:
Execute the adjust() function with amount = -900e18.
Since the condition distributionRecord.total >= diff is true, distributionRecord.total will be updated to 100e18, and 900e18 tokens will be transferred out from the contract.
The beneficiary then claims 100e18.
As a result, the contract will end up distributing a total of 800e18 + 900e18 + 100e18 tokens, causing a deficit in the contract's token balance.
Impact
Insufficient token balance could fail the token claiming.
gajiknownnothing
medium
Inadequate check on token amount adjustment
Summary
The
AdvancedDistributor::adjust()
function decreases the allocated token amount of a user without adequately checking against the claimed token amount. This can lead to a scenario where the decreased token amount is greater than the pending claimable token amount, resulting in insufficient token balance in the contract.Vulnerability Detail
For example, assume
distributionRecord.total = 1000e18
andrecords[beneficiary].claimed = 800e18
:adjust()
function withamount = -900e18
.distributionRecord.total >= diff
is true,distributionRecord.total
will be updated to 100e18, and 900e18 tokens will be transferred out from the contract.As a result, the contract will end up distributing a total of 800e18 + 900e18 + 100e18 tokens, causing a deficit in the contract's token balance.
Impact
Insufficient token balance could fail the token claiming.
Code Snippet
https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/67edd899612619b0acefdcb0783ef7a8a75caeac/contracts/packages/hardhat/contracts/claim/abstract/AdvancedDistributor.sol#L126-L132
Tool used
Manual Review
Recommendation
Consider adding the aforementioned check.
Duplicate of #43