Skip to content
Smart contracts Audit finding Advanced

OlympusGovernance#executeProposal : reentrancy attack vulnerable function

The executeProposal function resets the active proposal after executing instructions, allowing reentrancy if an instruction calls back into executeProposal. An attacker could repeatedly execute the same proposal instructions, potentially affecting funds depending on the instructions.

carlitox477 Follow

Originally disclosed on Code4rena

Submitted by carlitox477, also found by cryptphi and ladboy233

https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Governance.sol#L265 https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Governance.sol#L278-L288

Given that the activeProposal change is done before the for loop, if this function is call through one kernel.executeAction(instruction,target) we can call the same instructions (in the same order) again and again, which may or may not affect funds (depending on the instructions).

Proof of Concept

For instance, if we install a new module, and this module has a vulnerability (even intentional), the next steps can by trigger:

  1. Call executeAction
  2. This allow us to call kernel.executeAction in the for loop
  3. executAction allow us to call _installModule
  4. _installModule allow us to call newModule_.Init
  5. By init we can call now executeProposal again (suppose that the init function interact with a previous vulnerable proxy contract to scam voters to vote in favour of this proposal as if it was a contract which is ok, and before calling executeProposal we change the implementation to allow this attack),

Recommended Mitigation Steps

Use nonReentrant modifier or move the line activeProposal = ActivatedProposal(0, 0); before the for loop.

fullyallocated (Olympus) confirmed and commented:

I don’t know if funds are going to be threatened, but this does allow for a re-entrancy. Warden is correct in resetting the active Proposal before the for loop based on the checks-effects-interactions code design pattern.


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

Root cause

The active proposal state is reset after the loop that executes instructions, violating the checks-effects-interactions pattern and allowing reentrancy.

Impact

This may or may not affect funds depending on the instructions, but it allows reentrancy.

What the attacker needed

A proposal with malicious instructions; a module with a vulnerable init function

The fix

Use a nonReentrant modifier or move the line that resets the active proposal before the for loop.

How it was found

  1. Call executeAction
  2. This allows calling kernel.executeAction in the for loop
  3. executeAction allows calling _installModule
  4. _installModule allows calling newModule_.Init
  5. Through Init, call executeProposal again

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.

A reentrancy attack happens when a contract calls another contract before it finishes updating its own records, letting the other contract call back in and repeat actions. Here, the governance contract marks a proposal as inactive only after running its instructions, so a malicious instruction could call back and run the same instructions again.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by carlitox477

View all

9 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.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.