In claimRewards there is no period of time when this reward should be claimed. Even if the campaign is ended, user can keep his rewards in the contract for late claim.
Currently a campaign doesn't have an information how many accumulated reward is in pending for users to claim. In distributeRewards there is also no on-chain information how many token reward is eligible to be distributed and eligible to be claimed by users. Yes, there is a unclaimed data, but it's not represent a total of potential late user claim amount, because this unclaimed is just initial reward substracted by already claimed reward.
There is this recoverRewards function which is function to recover any reward token by the campaign owner due to cases, such as zero liquidity in the pool. Campaign owner can recover their reward token. How many token can be recovered, this might be the unclaimed.
This situation became issue, because unclaimed doesn't include unclaimed reward for user.
Worse case situation here is, campaign owner recover all of the unclaimed reward token, and eligible user who is going to have a late claim will get less or even zero rewards.
Recommendation
Introduce a variable to store the amount eligible to be claim, for example in distributeRewards add campaign.pendingreward, and decrease this pending reward when users claim. Finally, when recoverRewards, max amount to be recover is the diff between unclaimed and this pending reward.
Github username: -- Twitter username: chainNue Submission hash (on-chain): 0x2bbf6955c894c1d807ed8e910fbcba8815257626f95448133987df9df363a0f4 Severity: medium
Description: Description
In
claimRewards
there is no period of time when this reward should be claimed. Even if the campaign is ended, user can keep his rewards in the contract for late claim.Currently a campaign doesn't have an information how many accumulated reward is in pending for users to claim. In
distributeRewards
there is also no on-chain information how many token reward is eligible to be distributed and eligible to be claimed by users. Yes, there is aunclaimed
data, but it's not represent a total of potential late user claim amount, because thisunclaimed
is just initial reward substracted by already claimed reward.There is this
recoverRewards
function which is function to recover any reward token by the campaign owner due to cases, such as zero liquidity in the pool. Campaign owner can recover their reward token. How many token can be recovered, this might be theunclaimed
.This situation became issue, because
unclaimed
doesn't include unclaimed reward for user.Worse case situation here is, campaign owner recover all of the
unclaimed
reward token, and eligible user who is going to have a late claim will get less or even zero rewards.Recommendation
Introduce a variable to store the amount eligible to be claim, for example in
distributeRewards
add campaign.pendingreward, and decrease this pending reward when users claim. Finally, whenrecoverRewards
, max amount to be recover is the diff betweenunclaimed
and this pending reward.