Skip to content

Latest commit

 

History

History
70 lines (44 loc) · 2.3 KB

001.md

File metadata and controls

70 lines (44 loc) · 2.3 KB

Tame Menthol Condor

Medium

Missing Modifiers in claimReward Function

Summary

The claimReward() function is responsible for transferring rewards to a specified address. It checks if the caller has a reward, it clears the reward from storage, and performs the transfer.

However it is missing "whenNotPaused" and "onlyChallenger" modifier

Root Cause

The function here:

https://github.com/sherlock-audit/2024-08-morphl2/blob/main/morph/contracts/contracts/l1/rollup/Rollup.sol#L543

  function claimReward(address receiver) external { 
        uint256 amount = batchChallengeReward[_msgSender()];
        require(amount != 0, "invalid batchChallengeReward");
        delete batchChallengeReward[_msgSender()];
        _transfer(receiver, amount);
    }

The function is used by challengers to claim their rewards. However,

Missing onlyChallenger Modifier: • Issue: The function does not enforce that only authorized challengers can call it. • Impact: Without this modifier, people who are not challengers can call this function. This may lead to future abuse or consequences . So only challengers should be able to call this function

Missing whenNotPaused Modifier: • Issue: The function lacks a mechanism to prevent execution during periods when the contract is paused. • Impact: In case of an emergency or maintenance, the contract owner should be able to pause certain functions to prevent operations. Without this modifier, claimReward can be executed even if the contract is paused, which could be risky in situations where a pause is warranted. As you know this function triggers _transfer function. that _transfer function gives external call. So its very important to net getting executed when contract is paused.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

No response

PoC

https://github.com/sherlock-audit/2024-08-morphl2/blob/main/morph/contracts/contracts/l1/rollup/Rollup.sol#L543

  function claimReward(address receiver) external { 
        uint256 amount = batchChallengeReward[_msgSender()];
        require(amount != 0, "invalid batchChallengeReward");
        delete batchChallengeReward[_msgSender()];
        _transfer(receiver, amount);
    }

Mitigation

No response