code-423n4 / 2022-10-inverse-findings

0 stars 0 forks source link

`operator` role it's handled in a way that can damage the protocol #600

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2022-10-inverse/blob/cc281e5800d5860c816138980f08b84225e430fe/src/BorrowControl.sol#L1

Vulnerability details

operator role it's handled in a way that can damage the protocol

Impact

Same logic is being deployed several times, for maintainability is hardly recommended to not copy paste same logic many times but inherit it.

Also there is an issue in BorrowController with: https://github.com/code-423n4/2022-10-inverse/blob/aaf717f13c1f9a6e2f0888fef7c9b40400eeb4ec/src/BorrowController.sol#L26

function setOperator(address _operator) public onlyOperator { operator = _operator; }

In the first case we can see a simple transfer of privileges. This one:

  1. Some functions not being usable until redeployed BorrowController.sol (allow(), deny(), setOperator()) This means that markets can't being denied in case they get compromised And neither can be allowed new markets
  2. Extra gas cost for redeploying
  3. Reputational damage (most of the times more valuable than the previous one)

Basically this way is error prone, an not recommended.

As we can see in the other files, operator role is managed better, these files use a double step transfer process, where first pendingOperator is assigned, then it's claimed by the pending address:

https://github.com/code-423n4/2022-10-inverse/blob/aaf717f13c1f9a6e2f0888fef7c9b40400eeb4ec/src/DBR.sol#L53 https://github.com/code-423n4/2022-10-inverse/blob/cc281e5800d5860c816138980f08b84225e430fe/src/Oracle.sol#L44

function setPendingOperator(address newOperator_) public onlyOperator { pendingOperator = newOperator_; }
    function claimOperator() public {
        require(msg.sender == pendingOperator, "ONLY PENDING OPERATOR");
        operator = pendingOperator;
        pendingOperator = address(0);
        emit ChangeOperator(operator);
    }

In this case,

Details

All of these methods can be grouped into a single contract

Methods involved:

Params involved:

Events involved:

Github Permalinks

https://github.com/code-423n4/2022-10-inverse/blob/cc281e5800d5860c816138980f08b84225e430fe/src/DBR.sol# https://github.com/code-423n4/2022-10-inverse/blob/cc281e5800d5860c816138980f08b84225e430fe/src/Oracle.sol# https://github.com/code-423n4/2022-10-inverse/blob/cc281e5800d5860c816138980f08b84225e430fe/src/BorrowControl.sol#

Mitigation

neumoxx commented 1 year ago

Inflated severity. Probably should be QA.

c4-judge commented 1 year ago

0xean marked the issue as unsatisfactory: Overinflated severity