The vulnerability identified is that users are unable to claim subsequent rewards after their initial claim due to incorrect tracking of userRewards[user]
. When a user claims rewards, userRewards[user]
is updated to the totalDistributed
value instead of their individual share. This causes subsequent pending rewards calculations to yield zero, even when users should be eligible for additional rewards.
Affected Code: FeeCollector::ClaimReward
The calculation of pending rewards is as follows:
When userRewards[user]
is set to the totalDistributed
instead of the user's individual reward share, subsequent claims fail. For instance:
Initial scenario:
User voting power: 5
Total voting power: 100
Distributed rewards: 50
The user's share: (50 * 5) / 100 = 2.5
.
After claiming this reward, userRewards[user]
is set to 50 instead of 2.5.
Subsequent scenario:
User voting power: 7
Total voting power: 100
New distributed rewards: 50 (totalDistributed remains 50)
The user's share: (50 * 7) / 100 = 3.5
.
The pending rewards check compares 3.5
against userRewards[user]
(which is 50), resulting in zero because 3.5 < 50
.
Thus, despite being eligible for rewards due to increased voting power, the user cannot claim them.
Paste the following code into the FeeCollector.test.js file in the Fee Collection and Distribution section
This PoC demonstrates that after the first claim, subsequent reward claims fail even when the user should be eligible for additional rewards.
Users who have locked tokens and are eligible for additional rewards after the initial claim cannot access their rewards. This directly impacts the fairness and functionality of the reward distribution system.
Manual code review
Track individual user shares correctly instead of updating userRewards[user]
to the totalDistributed
.
Introduce a time-lock mechanism to prevent multiple claims within a short window.
Consider maintaining a lastClaimedReward
variable per user to ensure correctness.
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.