Closed code423n4 closed 1 year ago
dmvt marked the issue as duplicate of #156
RedVeil marked the issue as sponsor confirmed
dmvt changed the severity to QA (Quality Assurance)
Revert back to M as requested by @dmvt
dmvt marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/utils/MultiRewardStaking.sol#L308-L312 https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/utils/MultiRewardStaking.sol#L351-L360
Vulnerability details
Impact
The function
_calcRewardsEnd
is called with thepreviousEndTime
as first parameter inMultiRewardStaking.changeRewardSpeed
, which leads to wrong calculation of the newrewardsEndTimestamp
, causing it to be later than it should be. This will lead to more rewards being accrued "on paper" than the contract contains.Proof of Concept
The function
MultiRewardStaking.changeRewardSpeed
calls the_calcRewardsEnd
function like this:If
prevEndTime > block.timestamp == true
then the following block incalcRewardsEnd
will be executed:A quick calculation why the lines above should not be executed in this case:
Tools Used
Manual Review
Recommended Mitigation Steps
Call
calcRewardsEnd
the same way as is done in theaddRewardToken
function:_calcRewardsEnd(0, rewardsPerSecond, amount);
(first parameter = 0)