The Staking
contract contains a vulnerability related to the claim rewards function, where user rewards are calculated based on the total staked amount at the time of claim. This vulnerability allows users to potentially exploit the system by depositing additional tokens just before claiming, resulting in inflated rewards.
In the staking contract's claim function, the rewards calculation is performed using the formula:
However, the userStakes[msg.sender]
value can be updated through the deposit function, allowing users to manipulate their rewards by depositing additional tokens just before claiming. So if claim period is reached, he can deposit more tokens and get extra rewards in claiming.
This vulnerability has the potential to result in disproportionate rewards for users who deposit additional tokens right before claiming. Such manipulation could lead to an imbalance in the reward distribution and impact the fairness of the staking system.
Copy below test and run it via ``
Test:
Result:
Implement Snapshot Mechanism:
Introduce a snapshot mechanism to capture the user's staked amount at the beginning of each staking period. Use this snapshot value for reward calculations, ensuring consistency and preventing manipulation.
High severity, this allows users to claim additional rewards without committing to intended weekly staking period via multi-deposit/deposit right before claiming rewards.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.