-
Notifications
You must be signed in to change notification settings - Fork 6
rbserver - MasterChefRewarder.unlink
function does not execute _setRewardParameters(0, block.timestamp, 0)
though it should
#304
Comments
The functions in the MasterChefRewarder contract that carry the admin authority are specified using the onlyOwner modifier. These functions can be called by the admin and include admin actions. Therefore, assumptions and operational changes caused by admin actions are not considered a valid security issue. |
MasterChefRewarder.unlink
function does not execute _setRewardParameters(0, block.timestamp, 0)
though it shouldMasterChefRewarder.unlink
function does not execute _setRewardParameters(0, block.timestamp, 0)
though it should
Escalate |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
The current functionality of the Differences Between Issues 342 and 304Issue 342 is related to users not being able to claim their rewards and losing them. This directly affects the user experience and causes a security vulnerability. Issue 304 is related to the The solution to issue 342 involves updating the My opinion is definitely clear |
Admin can call Planning to reject this escalation, since admins are trusted to call |
Result: |
Escalations have been resolved successfully! Escalation status:
|
rbserver
High
MasterChefRewarder.unlink
function does not execute_setRewardParameters(0, block.timestamp, 0)
though it shouldSummary
Because the
MasterChefRewarder.unlink
function does not execute_setRewardParameters(0, block.timestamp, 0)
,_totalUnclaimedRewards
andrewarder.accDebtPerShare
become less than what they should be at the moment when theMasterChefRewarder
contract is stopped, and_rewardsPerSecond
is not updated to 0, which allows accounts to still earn and claim rewards after theMasterChefRewarder
contract is stopped even though no new rewards should be given after such stop.Vulnerability Detail
Since calling the
MasterChefRewarder.stop
function reverts, theMasterChefRewarder
contract can only be stopped by calling theMasterChefRewarder.unlink
function according to theMasterChefRewarder.stop
function's comment. Unlike theBaseRewarder.stop
function, theMasterChefRewarder.unlink
function does not execute_setRewardParameters(0, block.timestamp, 0)
; thus, when theMasterChefRewarder.unlink
function is called:_totalUnclaimedRewards
is not incremented by the pending rewards, which is returned by the_rewarder.getTotalRewards
function, at the moment when theMasterChefRewarder
contract is stopped though it should be;_rewarder.updateAccDebtPerShare
function is not called,rewarder.accDebtPerShare
is not incremented by thedebtPerShare
corresponding to the total supply and pending rewards at the moment when theMasterChefRewarder
contract is stopped though it should be;_rewardsPerSecond
is not updated to 0 though it should be when theMasterChefRewarder
contract is stopped.Impact
The accounting for
_totalUnclaimedRewards
andrewarder.accDebtPerShare
become inaccurate in which these state variables become less than what they should be at the moment when theMasterChefRewarder
contract is stopped. Moreover, because_rewardsPerSecond
is not updated to 0, accounts can still earn and claim rewards after theMasterChefRewarder
contract is stopped even though no new rewards should be given after such stop, which causes these accounts to receive such rewards that they are not entitled to.Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/MasterChefRewarder.sol#L51-L56
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/MasterChefRewarder.sol#L42-L49
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BaseRewarder.sol#L184-L198
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BaseRewarder.sol#L340-L376
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/libraries/Rewarder.sol#L51-L63
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/libraries/Rewarder.sol#L153-L162
Tool used
Manual Review
Recommendation
The
MasterChefRewarder.unlink
function can be updated to execute_setRewardParameters(0, block.timestamp, 0)
like what theBaseRewarder.stop
function does.The text was updated successfully, but these errors were encountered: