The FjordPoints smart contract contains a critical vulnerability in the onStaked function due to a lack of input validation for stake amounts. This oversight allows for zero-amount stakes, which can potentially manipulate the totalStaked value to zero. As a result, the pointsPerToken calculation in the reward distribution mechanism is susceptible to a division by zero error, which could render the entire contract non-functional.
The vulnerability stems from two key issues in the smart contract:
1: The onStaked function does not validate that the staked amount is greater than zero:
2: The pointsPerToken calculation in the distributePoints function relies on totalStaked as a denominator:
The exploitation of this vulnerability could lead to:
Complete failure of the reward distribution mechanism
Inability to calculate or distribute rewards to any users
Potential permanent loss of accumulated rewards
Necessity for contract migration or upgrade, eroding user trust
Possible crash in the value of associated tokens
Cascading failures in interconnected contracts or systems relying on this contract
Manual review
1: Implement input validation in the onStaked function:
2: Add a safety check in the distributePoints function to prevent division by zero:
3: Implement a minimum stake amount to prevent small stakes that could lead to precision issues:
4: Consider implementing a two-step process for critical state changes, such as large unstaking operations that could significantly impact totalStaked.
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.