Skip to content
Race condition Audit finding Advanced

DAO.execute ( bytes32 , Action[] , uint256 ) is vulnerable to re-entrancy attacks

The DAO.execute function lacks reentrancy protection, so if an action calls back to the original caller, that caller can re-enter and execute the same set of actions again, potentially out of order. An attacker could exploit this to cause actions to run multiple times or in the wrong sequence, leading to unintended DAO states.

carlitox477 Follow

Originally disclosed on Code4rena

Submitted by carlitox477

The present implementation permits the execution of a predetermined sequence of instructions, where the order of execution is at times crucial, as described in the documentation:

Imagine a DAO is currently governed by a multisig (it has the Multisig plugin installed) and wants to transition the DAO governance to token voting. To achieve this, one of the Multisig members creates a proposal in the plugin proposing to

  1. install the TokenVoting plugin
  2. uninstall the Multisig plugin

If enough multisig signers approve and the proposals passes, the action array can be executed and the transition happens.

Here, it is important that the two actions happen in the specified order and both are required to succeed. Otherwise, if the first action would fail or the second one would happen beforehand, the DAO could end up in a state without having a governance plugin enabled.

In the event that any of the actions performs a callback to the permitted msg.sender, that particular address would gain the ability to dispatch the same set of actions.

Impact

Considering that the msg.sender could be a contract, the importance of the order of execution (at least in certain scenarios), and the potential for reentrancy, it can be concluded that the intended behavior is at risk of compromise

Proof of Concept

In the following hypothetical scenario:

  1. A contract named DAOsWilling possesses the necessary authorization to invoke DAO.execute.
  2. DAOsWilling has established a predetermined sequence of five ordered actions that, according to its code, are guaranteed to succeed. However, it is imperative that these actions be executed in a specific order.
  3. DAOsWilling permits anyone to invoke a function - let’s call it executeDaosWilling - in order to execute this pre-established sequence of ordered actions.
  4. Furthermore, DAOsWilling has a contract that contains a callback function for one of the aforementioned actions, which subsequently calls back to the original caller of executeDaosWilling.”

Then, next action could happen:

  1. A DAO has established a set of 5 actions in DAOsWilling contract, the 3° action do a callback in name of executeDaosWilling caller
  2. Bob calls executeDaosWilling through a smart contracts he has designed, after the 3° action a callback is done to DAOsWilling, which calls Bob’s contract, and Bob’s contracts calls executeDaosWilling again
  3. Then 1 to 5 action is executed in a row (let’s suppose that in this other callback done by the 3° action Bob’s contract do nothing), and then action 4 and 5 are executed

This POC shows that there scenarios where we cannot guarantee that actions are execute in order.

Recommended Mitigation Steps

Use ReentrancyGuard contract from openzeppelin and add nonReentrant modifier to execute(bytes32, Action[], uint256) function or assume the risk informing them in documentation.

    function execute(
        bytes32 _callId,
        Action[] calldata _actions,
        uint256 _allowFailureMap
    )
+       nonReentrant
        external
        override
        auth(EXECUTE_PERMISSION_ID)
        returns (bytes[] memory execResults, uint256 failureMap)
    {

0xean (judge) commented:

I think this is worth leaving open for sponsor comment, but would assume that the validation of the proposal payload is meant to happen by voters and would include validating that the payload doesn’t re-enter.

novaknole20 (Aragon) acknowledged and commented:

Hey, we’re aware of this. This would be only possible if action calls the caller which again calls dao.execute.

cA => dao.execute([action1, action2]) => action2 calls back cA => which calls dao.execute. Thats the only possibility as dao.execute is protected by EXECUTE_PERMISSION.

This all means that action shouldn’t be calling back the original caller, which must be the members’ responsibility to review.

0xean (judge) decreased severity to Low/Non-Critical

carlitox477 (warden) commented:

I would like to respectfully express my disagreement with the judge’s decision to downgrade this issue from Medium to QA. My disagreement is based on the following facts:

  • Sponsors acknowledgment and lack of information about it in the documentation: Although the sponsor acknowledged the bug, they did not make it explicitly clear in the documentation or the code. In the appropriate scenario, unless developers who built on top of Aragon take notice, this bug would remain undiscovered, leaving them exposed to potential risks.

  • Precedent: Olympus DAO M-04 exposed a similar vulnerability which was awarded as medium: The executeProposal function in Olympus DAO was vulnerable to the same bug, this function can be considered similar to executeProposal() in Aragon protocol. Taking into account that Olympus DAO protocol was a concrete implementation of a DAO and not a protocol to build on top, it can be perfectly argued that Olympus DAO finding vulnerability impact is less than Aragon DAO current bug reported.

  • The protocol is meant to be used to build on top of it: The Aragon protocol is designed to be used as a foundation for building DAOs using the offered contracts. Developers should be provided with all the necessary information that can improve their development experience and help them avoid exposing their users to potential attack vectors that can compromise the products they offer. In this specific case, if this bug had not been reported, and since the sponsor did not explicitly mention it in the documentation, new DAOs built on top of the Aragon protocol would have been exposed to this vulnerability. For example, if OlympusDAO had chosen to use the Aragon protocol as the foundation for building their DAO, they too would have been exposed to the same bug that they themselves identified as a Medium severity issue in their own audit.

  • Current medium criteria:

    • Asset are not at direct risk: Met

    • Requirement of at least one of next cases:

      1. function of the protocol: Sponsors stated This all means that action shouldn't be calling back the original caller
      2. its availability could be impacted: Not the case
      3. leak value with a hypothetical attack path with stated assumptions, but external requirements: The hypothetical attack path with stated assumption was exposed and acknowledged by the sponsors. Another attack path is presented above, more simpler than the one exposed in the presented issue, but based in the same vector attack allowed by this bug: reentrancy.

About particular sponsor response: The sponsor argue that cA => dao.execute([action1, action2]) => action2 calls back cA=> which calls dao.execute. Thats the only possibility as dao.execute is protected by EXECUTE_PERMISSION. This all means that action shouldn’t be calling back the original caller, which must be onto the members’ responsibility to review. This argument can be illustrated like:

The sponsor is suggesting that an action should intentionally produce a callback (by DAO builders decision), also that EXECUTE_PERMISSION will be enough to forbid a malicious user to exploit this vector attack.

This line of thought seems reasonable at first, however it ignores 2 crucial factors: action have consequences:

  1. EXECUTE_PERMISSION can mean nothing if builders decides so. They just would have to create a contract with an execute function which calls dao.execute(lastVotedActions). Why would they be willing to do this? To show how decentralized they are (as Olympus DAO decided with their executeProposal function)
  2. Actions has consequences: The sponsor supposes that action 2 should necessarily imply a super specific call back, but if action 2 do an ERC-777 transfer or an NFT safeMinting or transfer (maybe as a participation reward) to the one who has trigger the execution of voted action, then an indirect consequence of this would be opening to the re-entrancy attack vector.

Here the use case I think the sponsor is suggesting:

Here the use case in which an executer (considering it is a smart contract deployed by anyone) abuse of this bug to mint 2 NFTs instead of 1:

Given the sponsor acknowledgment, the lack of explicit statement of the bugs in the documentation, the consideration this protocol is meant to be used to build on top of it, current rules for medium requirement are met, and OlympusDAO precedent I would like to respectfully disagree with current judge’s decision to downgrade the issue from medium to QA, and beg them to reconsider their decision based on the exposed arguments.

I would also like to encourage the Aragon protocol to implement my recommendation, as it would demonstrate that the protocol is taking all necessary steps to protect developers and builders from possible misunderstandings about how to correctly build and develop using the protocol. By adopting this recommendation, the Aragon protocol would provide greater clarity and transparency, enabling developers to build with confidence and reducing the likelihood of vulnerabilities being introduced into the system.

0xean (judge) increased severity to Medium and commented:

@carlitox477 - thanks for stating your objections in a productive way.

The external requirement here is that a DAO fails to properly review a proposal, if that assumption is broken essentially ANY action can be taken on behalf of the DAO. Tools like tenderly should also provide some really good visibility into the transactions results before approval / execution.

All of that being said, I don’t think it is that wild to imagine a DAO missing this, and approving a malicious transaction that has some subtle re-entrant behavior. Given that this is supposed to be generic tooling for DAOs, I am going to re-open this back to Medium.


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

Likely the execute function does not use a reentrancy guard, allowing a callback to re-enter and execute actions again.

Impact

The intended order of actions could be broken, potentially leaving the DAO in an inconsistent state or allowing actions to be executed multiple times.

What the attacker needed

A contract with EXECUTE_PERMISSION; That contract allows arbitrary calls to execute; An action triggers a callback to the caller

How it was found

  1. A contract with permission to call DAO.execute sets up a sequence of actions, one of which triggers a callback to the original caller.
  2. Bob calls that contract's function through his own contract.
  3. During the action, a callback goes to Bob's contract, which calls the function again.
  4. The actions are executed again, causing duplication or out-of-order execution.

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 DAO is a smart contract that runs actions in a specific order. If one action calls back to the contract that started the process, that contract can call the DAO again before the first set of actions finishes, causing actions to repeat or run out of order. This is called reentrancy, like someone sneaking back into a queue before it ends.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by carlitox477

View all

9 more disclosed reports, best first.

More from Aragon Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.