DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

Owner can change pointsPerEpoch at any time causing unfair points distribution to user

Vulnerability Details

In FjordPoints::setPointsPerEpoch the owner can update pointsPerEpoch at any time causing the owner to be able to change the points distributed just before an epoch ends.

function setPointsPerEpoch(uint256 _points) external onlyOwner checkDistribution {
if (_points == 0) {
revert();
}
pointsPerEpoch = _points; // @audit this will set at any time
}

looking at the checkDistribution modifier which includes distributePoints

function distributePoints() public {
if (block.timestamp < lastDistribution + EPOCH_DURATION) {
return;
}
// ...

the condition above in the distributePoints() implies that whenever epoch duration has NOT passed, then the owner can just freely update the pointsPerEpoch.

IMPORTANTLY, the updatePendingPoints modifier uses pointsPerToken variable which is calculated in distributePoints() of which in its caculation uses the current pointsPerEpoch (of which the owner can spoof)

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordPoints.sol#L148
https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordPoints.sol#L242

PoC

  1. The owner sets a high pointsPerEpoch to attract many stakers.

  2. The stakers has been staking tokens in the protocol for 6 days now, and they are expecting many points.

  3. On the end of the 7th day, the owner lowers the pointsPerEpoch.

  4. A week has now passed, and points can now be distributed.
    The stakers will get points according to the newly set pointsPerEpoch which is lower than anticipated.

Impact

An malicious owner could set pointsPerEpoch high to attract stakers, then lower it just before the epoch ends to reduce the actual rewards distributed.

Tools Used

Manual review, Zed code editor

Recommendations

Implement a time delay for changes to pointsPerEpoch, so they only take effect in future epochs.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.