sherlock-audit / 2024-06-mellow-judging

7 stars 3 forks source link

Audinarey - `_requireAtLeastOperator()` is implemented wrongly breaking core protocol functionality #306

Closed sherlock-admin4 closed 4 months ago

sherlock-admin4 commented 4 months ago

Audinarey

Medium

_requireAtLeastOperator() is implemented wrongly breaking core protocol functionality

Summary

The _requireAtLeastOperator() function is used exclusively to protect most privilege functions in the protocol. It is intended to ensure that only a caller that admin role or at least an operator role can call the functions that is protects.

As shown below, it check to ensure that the caller has both the admin and operator roles.

File: DefaultAccessControl.sol
53:     function _requireAtLeastOperator(address sender) internal view {
54: @>      if (!isAdmin(sender) && !isOperator(sender)) revert Forbidden();
55:     }

Vulnerability Detail

Assume for instance that

If

So the goal of giving access to an account that has at least an OPERATOR role is defeated

Impact

The implementation breaks core protocol functionality

Code Snippet

https://github.com/sherlock-audit/2024-06-mellow/blob/main/mellow-lrt/src/utils/DefaultAccessControl.sol#L53

Tool used

Manual Review

Recommendation

Modify the _requireAtLeastOperator() function as shown below

File: DefaultAccessControl.sol
53:     function _requireAtLeastOperator(address sender) internal view {

54: -       if (!isAdmin(sender) && !isOperator(sender)) revert Forbidden();
54: +       if (!isAdmin(sender) || !isOperator(sender)) revert Forbidden();

55:     }