Skip to content
Access control Audit finding Intermediate

Only guardian can change guardian

The TemporalGovernor contract uses OpenZeppelin's Ownable, where the owner is the guardian, but does not override transferOwnership. This means only the guardian can transfer the guardian role, so governance cannot replace a guardian who refuses to step down, and the only alternative is to revoke the guardian, which permanently disables pausing.

immeas Follow

Originally disclosed on Code4rena

Submitted by immeas

https://github.com/code-423n4/2023-07-moonwell/blob/main/src/core/Governance/TemporalGovernor.sol#L27

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol#L81-L86

guardian is mentioned as an area of concern in the docs:

Specific areas of concern include:

  • TemporalGovernor which is the cross chain governance contract. Specific areas of concern include delays, the pause guardian, …

guardian is a roll that has the ability to pause and unpause TemporalGovernor. In code, it uses the owner from OpenZeppelin Ownable as guardian. The issue is that Ownable::transferOwnership is not overridden. Only guardian (owner) can transfer the role.

This can be a conflict of interest if there is a falling out between governance and the guardian. If the guardian doesn’t want to abstain, governance only option would be to call revokeGuardian which sets owner to address(0). This permanently removes the ability to pause the contract which can be undesirable.

Proof of Concept

Simple test in TemporalGovernorExec.t.sol:

    function testGovernanceCannotTransferGuardian() public {
        address[] memory targets = new address[](1);
        targets[0] = address(governor);
        uint256[] memory values = new uint256[](1);

        bytes[] memory payloads = new bytes[](1);
        payloads[0] = abi.encodeWithSelector(Ownable.transferOwnership.selector,address(newAdmin));

        bytes memory payload = abi.encode(address(governor), targets, values, payloads);
        mockCore.setStorage(true, trustedChainid, governor.addressToBytes(admin), "reeeeeee", payload);

        governor.queueProposal("");

        vm.warp(block.timestamp + proposalDelay);

        // governance cannot transfer guardian
        vm.expectRevert(abi.encodeWithSignature("Error(string)", "Ownable: caller is not the owner"));
        governor.executeProposal("");
    }

Recommended Mitigation Steps

Consider overriding transferOwnership and either limit it to only governance (msg.sender == address(this)) or both guardian and governance.

ElliotFriedman (Moonwell) confirmed and commented:

This is an interesting finding. Only guardian can change guardian, however, guardian can only pause once and is limited in abilities to being able to fast track execution, and unpause. After a single malicious pause, the guardian would no longer be able to pause, and 30 days later, governance would reopen.


The original report as published on Code4rena, by immeas. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

If the guardian refuses to transfer the role, governance can only revoke the guardian, which permanently removes the ability to pause the contract, potentially leaving it without a pause mechanism.

What the attacker needed

Guardian role assigned; governance proposes transfer; guardian refuses to transfer

The fix

The contract should override transferOwnership to restrict it to governance (msg.sender == address(this)) or to both guardian and governance.

How it was found

  1. Governance queues a proposal that calls transferOwnership on the governor contract to a new admin.
  2. After the proposal delay, governance executes the proposal.
  3. The execution reverts with 'Ownable: caller is not the owner' because the governor contract is not the owner.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In this smart contract, a special role called the guardian can pause the system. The contract uses a standard ownership library where the owner is the guardian, but it never added a way for the main governance to change that owner. So if the guardian misbehaves, governance cannot simply replace them; it can only remove the guardian entirely, which also removes the ability to pause.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by immeas

View all

24 more disclosed reports, best first.

More from Moonwell

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.