This repository has been archived by the owner on Nov 24, 2024. It is now read-only.
KupiaSec - When the startBlock
is reset, the lastRewardBlock
s of the pools are not updated accordingly
#90
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Disputed
The sponsor disputed this issue's validity
KupiaSec
high
When the
startBlock
is reset, thelastRewardBlock
s of the pools are not updated accordinglySummary
The
SophonFarming.setStartBlock()
function resets thestartBlock
value, but does not update thelastRewardBlock
s of the pools.Vulnerability Detail
When the
setStartBlock()
function is called, it only updates thestartBlock
value, but does not reset thelastRewardBlock
s of the pools.In the normal situation, the
lastRewardBlock
s of the pools are initialized to thestartBlock
value in the add() function. However, if the owner later resets thestartBlock
to a value smaller than the original one, thelastRewardBlock
s will remain set to the previous, higherstartBlock
value.As a result, when the first update of the pools is performed, the rewards will be miscalculated. The system will assume the point distribution started from the old, higher
startBlock
value, instead of the new, lowerstartBlock
value. This is because the blockMultiplier is calculated based on thelastRewardBlock
.This mismatch in
startBlock
andlastRewardBlock
values leads to an incorrect rewards calculation, resulting in a loss of points for the users.Impact
If the owner resets the
startBlock
to a value smaller than the previous one, users will lose a portion of their accumulated reward points.Code Snippet
https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L272-L280
Tool used
Manual Review
Recommendation
When the
setStartBlock()
function is called, thelastRewardBlock
s of the pools should also be reset, in addition to thestartBlock
.Duplicate of #108
The text was updated successfully, but these errors were encountered: