Closed code423n4 closed 1 year ago
hansfriese marked the issue as satisfactory
hansfriese marked the issue as primary issue
This really ought to be out of scope as was clarified in the Discord thread for the competition; there is no intent to ever deploy with reward windows where the initial starting time is not 0. That being said, you took the time to include a fix which I appreciate and might as well include at this point.
TimTinkers marked the issue as sponsor acknowledged
Will consider as a valid medium because there is no documentation about initialStartTime = 0
@hansfriese I disagree with the severity of medium.
window.startTime
is exclusively controlled via an administrative configurePools
function which was flagged as out-of-scopewindow.startTime
of 0configurePools
againTimTinkers marked the issue as disagree with severity
Downgrade to QA as it was clarified in the FAQ already.
hansfriese changed the severity to QA (Quality Assurance)
hansfriese marked the issue as grade-c
Lines of code
https://github.com/code-423n4/2023-03-neotokyo/blob/dfa5887062e47e2d0c801ef33062d44c09f6f36e/contracts/staking/NeoTokyoStaker.sol#L1312-L1320
Vulnerability details
Impact
In getPoolReward, all windows of the pool are iterated to calculate the reward. When lastPoolRewardTime < window.startTime, the reward rate of the previous window is got. When the user claims the reward for the first time, lastPoolRewardTime == 0. If pool.rewardWindows[0].startTime > 0, since lastPoolRewardTime < window.startTime, it will get pool.rewardWindows[0-1].reward, at this point an overflow will occur, resulting in the user not being able to claim the reward.
pool.rewardWindows.startTime is configured in configurePools, but configurePools does not require pool.rewardWindows[0].startTime == 0, if pool.rewardWindows[0].startTime > 0, getPoolReward will fail and the user will not be able to claim the reward.
Proof of Concept
https://github.com/code-423n4/2023-03-neotokyo/blob/dfa5887062e47e2d0c801ef33062d44c09f6f36e/contracts/staking/NeoTokyoStaker.sol#L1312-L1320 https://github.com/code-423n4/2023-03-neotokyo/blob/dfa5887062e47e2d0c801ef33062d44c09f6f36e/contracts/staking/NeoTokyoStaker.sol#L1819-L1842
Tools Used
None
Recommended Mitigation Steps
Change to