Skip to content
Access control Audit finding Intermediate

Anyone can pass any proposal alone before first VOTES are minted

The governance contract allowed anyone to submit, activate and execute a proposal before any VOTES tokens were minted, because vote-count checks passed when total supply was zero. An attacker could therefore pass a proposal to change the Kernel admin and executor, gaining control of all permissioned functions and funds.

Bahurum Follow

Originally disclosed on Code4rena

Submitted by Bahurum, also found by bin2chen and cryptphi

https://github.com/code-423n4/2022-08-olympus/blob/2a0b515012b4a40076f6eac487f7816aafb8724a/src/policies/Governance.sol#L164 https://github.com/code-423n4/2022-08-olympus/blob/2a0b515012b4a40076f6eac487f7816aafb8724a/src/policies/Governance.sol#L217-L218 https://github.com/code-423n4/2022-08-olympus/blob/2a0b515012b4a40076f6eac487f7816aafb8724a/src/policies/Governance.sol#L268

Before any VOTES are minted anyone can activate and execute an arbitrary proposal even with 0 votes cast. So an attacker can pass any proposal (i.e. change the executor + admin of the Kernel, gaining access to all permissioned functions and to funds held).

Proof of Concept

Checks on vote numbers made in Governance.sol at lines L164, 217-218, 268 pass if VOTES.totalSupply() == 0. So, until no VOTES are minted, anyone can submit, activate and execute a proposal. There is no need to own or cast votes. This happens if OlympusGovernance is granted the executor role before any VOTES are minted (as in Governance.t.sol). The attacker can anticipate/frontrun the minting and pass a proposal to change both the Kernel admin and executor. Then he/she can upgrade malicious modules, steal funds from treasury…

A PoC was obtained modifying the setUp() of Governance.t.sol by keeping only what is before the minting of VOTES (up to L83 included). The test is as follows:

    function test_AttackerPassesProposalBeforeMinting() public {

        address[] memory users = userCreator.create(1);
        address attacker = users[0];
        vm.prank(attacker);
        MockMalicious attackerControlledContract = new MockMalicious();

        Instruction[] memory instructions_ = new Instruction[](2);
        instructions_[0] = Instruction(Actions.ChangeAdmin, address(attackerControlledContract));
        instructions_[1] = Instruction(Actions.ChangeExecutor, address(attackerControlledContract));

        vm.prank(attacker);
        governance.submitProposal(instructions_, "proposalName", "This is the proposal URI");

        governance.endorseProposal(1);

        vm.prank(attacker);
        governance.activateProposal(1);

        vm.warp(block.timestamp + 3 days + 1);

        governance.executeProposal();

        assert(kernel.executor()==address(attackerControlledContract));
        assert(kernel.admin()==address(attackerControlledContract));

    }

with

contract MockMalicious {}

Recommended Mitigation Steps

In Governance.sol check for a minimum VOTES totalSupply, similiar to the expected initial supply of VOTES when they have been fairly distributed, for example at line L164.

fullyallocated (Olympus) acknowledged

0xean (judge) commented:

Leaving as High severity as this shows a clear path to loss of funds.


The original report as published on Code4rena, by Bahurum. 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

An attacker could take over the Kernel by changing its admin and executor, then upgrade malicious modules and steal funds from the treasury.

What the attacker needed

Governance granted executor role before VOTES minted; No VOTES tokens minted yet; Attacker can submit a proposal

The fix

The governance contract should check for a minimum VOTES total supply before allowing proposals to proceed.

How it was found

  1. Deploy a malicious contract to become the new admin and executor.
  2. Submit a proposal with instructions to change the admin and executor to that contract.
  3. Endorse the proposal.
  4. Activate the proposal.
  5. Wait for the voting period to end.
  6. Execute the proposal, which sets the Kernel admin and executor to the attacker's contract.

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.

This is a smart contract governance system where people vote with tokens called VOTES. The code that checks whether a proposal has enough support only looked at the number of votes cast, not whether any voting tokens existed yet. So before the first tokens were created, the checks passed with zero votes, letting anyone push through a proposal that handed them control of the whole system.

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 Bahurum

View all

10 more disclosed reports, best first.

More from Olympus DAO contest

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.