Users may suffer from loss of tokens if owner decreases their claimable tokens.
Summary
User's claimable tokens are not claimed and settled during the adjust tx. If an user's current claimable tokens exceeds the new claimable tokens (been adjusted downwards), the user will not be able to claim the excess ones later and will suffer a token loss.
Vulnerability Detail
Owner can decrease user's total claimable tokens. But the tokens that currently claimable before adjust should be claimed and settled and transfer to user, as they are belong to user now and should not be revoked by owner.
For example:
Initially, Alice's total claimable tokens is 100 (records[Alice].total=100, records[Alice].claimed=0).
After some time, the tokens can be claimed by Alice is 60. These 60 tokens should nominally belong to alice, but she has not claim them yet (getClaimableAmount(Alice, ...)=60, records[Alice].claimed=0).
At this moment, owner adjusts Alice's total claimable tokens downwards to 50 (i.e. records[Alice].total=50, records[Alice].claimed=0).
Afterwards, Alice can claim 50 tokens at most, but she should have 60 tokens (getClaimableAmount(Alice, ...)=50).
ydlee
high
Users may suffer from loss of tokens if owner decreases their claimable tokens.
Summary
User's claimable tokens are not claimed and settled during the
adjust
tx. If an user's current claimable tokens exceeds the new claimable tokens (beenadjust
ed downwards), the user will not be able to claim the excess ones later and will suffer a token loss.Vulnerability Detail
Owner can decrease user's total claimable tokens. But the tokens that currently claimable before
adjust
should be claimed and settled and transfer to user, as they are belong to user now and should not be revoked by owner.For example:
records[Alice].total=100, records[Alice].claimed=0
).getClaimableAmount(Alice, ...)=60, records[Alice].claimed=0
).adjust
s Alice's total claimable tokens downwards to 50 (i.e.records[Alice].total=50, records[Alice].claimed=0
).getClaimableAmount(Alice, ...)=50
).https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/abstract/AdvancedDistributor.sol#L119-L140
AdvancedDistributorInitializable.adjust
has the same problem.https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/factory/AdvancedDistributorInitializable.sol#L124-L145
Impact
User may suffer from token loss if their total claimable tokens get decreased.
Code Snippet
https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/abstract/AdvancedDistributor.sol#L119-L140
https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/factory/AdvancedDistributorInitializable.sol#L124-L145
Tool used
Manual Review
Recommendation
At the begining of the
adjust
function, claim and settle user's claimable tokens first.