The TempleGoldStaking contract's reward distribution mechanism, specifically the _notifyReward()
function, is susceptible to potential manipulation. This could lead to unfair reward distribution among stakers, particularly if the function is called frequently with varying amounts.
The vulnerability lies in the _notifyReward()
function:
Key issues:
The reward rate can be changed frequently, potentially allowing for strategic timing of rewards.
The use of block.timestamp
makes the function susceptible to minor manipulations by miners.
Precision loss may occur due to the conversion to uint216 for rewardRate
.
Dust accumulation in nextRewardAmount
could lead to undistributed rewards.
While the function is private, it's called by distributeRewards()
and indirectly by notifyDistribution()
, which is callable by the reward token contract. If these access points are compromised or manipulated, it could lead to unfair reward distribution.
The potential impacts of this vulnerability include:
Uneven distribution of rewards among stakers with similar stake amounts and durations.
Possibility for strategic actors to maximize their rewards at the expense of other stakers.
Accumulation of undistributed rewards over time.
Manual review
Implement a minimum threshold for reward notifications to prevent frequent small updates that could be used for manipulation.
Consider using a time-weighted average for reward rates to smooth out short-term fluctuations and reduce the impact of individual notifications.
Add additional checks to ensure that rewardrate
changes are within expected bounds.
Consider distributing accumulated dust (nextRewardAmount
) periodically to ensure all rewards are distributed.
Use a more precise data type for rewardRate
to minimize precision loss.
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.