The FjordStaking contract contains a vulnerability where users staking at the end of an epoch receive the same rewards as users who staked at the beginning of the epoch. This creates an unfair advantage for users who can time their stakes, allowing them to maximize rewards while minimizing the time their funds are locked.
The vulnerability originates from how the contract handles new stakes and calculates rewards:
New stakes are added to newStaked
, not totalStaked
totalStaked
is only updated at epoch rollover:
Rewards are calculated based on totalStaked
, excluding newStaked
This means that all stakes made within an epoch, regardless of when they were made, are treated equally for reward distribution at the end of that epoch.
Fairness: Users staking for shorter periods within an epoch receive disproportionately high rewards compared to those who stake for the full epoch.
Potential for Exploitation: Knowledgeable users could consistently exploit this to maximize their rewards at the expense of other users.
Manual Review
Implement a pro-rata reward system: Calculate rewards based on the exact duration of staking within an epoch. This would require tracking the timestamp of each stake and adjusting the reward calculation accordingly.
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.