DAO proposals can be executed by anyone due to vulnerable TimelockController
The TimelockController contract checks whether a proposal was scheduled only after executing the batch, allowing an attacker to insert a call that schedules the batch itself. This lets anyone who can create a proposal become the Timelock admin and execute arbitrary transactions as the DAO.
Submitted by cmichel, also found by leastwood
The GovernorAlpha inherits from a vulnerable TimelockController. This TimelockController allows an EXECUTOR role to escalate privileges and also gain the proposer role. See details on OZ and the fix here.
The bug is that _executeBatch checks if the proposal was scheduled only after the transactions have been executed. This allows inserting a call into the batch that schedules the batch itself, and the entire batch will succeed. As the custom GovernorAlpha.executeProposal function removed the original “queued state check” (require(state(proposalId) == ProposalState.Queued), the attack can be executed by anyone, even without the EXEUCTOR_ROLE.
Proof of concept:
- Create a proposal using
propose. Thecalldatawill be explained in the next step. (This can be done by anyone passing the minproposalThreshold) - Call
executeProposal(proposalId, ...)such that the following calls are made:
call-0: grantRole(TIME_LOCK_ADMIN, attackerContract)
call-1: grantRole(EXECUTOR, attackerContract)
call-2: grantRole(PROPOSER, attackerContract)
call-3: updateDelay(0) // such that _afterCall "isOperationReady(id): timestamp[id] = block.timestamp + minDelay (0) <= block.timestamp" passes
call-4: attackerContract.hello() // this calls timelock.schedule(args=[targets, values, datas, ...]) where args were previously already stored in contract. (this is necessary because id depends on this function's args and we may not be self-referential)
// attackerContract is proposer & executor now and can directly call scheduleBatch & executeBatch without having to create a proposal
ℹ️ I already talked to Jeff Wu about this and he created a test case for it confirming this finding
The impact is that, anyone who can create a proposal can become Timelock admin (proposer & executor) and execute arbitrary transactions as the DAO-controlled GovernorAlpha. Note that this contract has severe privileges and an attacker can now do anything that previously required approval of the DAO. For example, they could update the globalTransferOperator and steal all tokens.
Recommend updating the vulnerable contract to TimelockController v3.4.2 as it currently uses OpenZeppelin/[email protected]
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 `_executeBatch` function checks the proposal's scheduled status after executing the transactions, and the custom `GovernorAlpha.executeProposal` removed the queued state check, allowing anyone to execute a proposal that schedules itself.
Impact
Anyone who can create a proposal can become Timelock admin and execute arbitrary transactions as the DAO, potentially stealing all tokens.
What the attacker needed
Ability to create a proposal (meet proposalThreshold)
The fix
The vulnerable contract should be updated to TimelockController v3.4.2.
How it was found
- Create a proposal using `propose` with calldata that includes calls to grant roles and schedule the batch.
- Call `executeProposal` with the proposal ID, which executes the batch of calls.
- The batch includes calls to grant the attacker contract the TIMELOCK_ADMIN, EXECUTOR, and PROPOSER roles, update the delay to zero, and then call a function that schedules the batch itself.
- After the batch succeeds, the attacker contract has proposer and executor roles and can directly call scheduleBatch and executeBatch.
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 timelock is a contract that delays execution of proposals until a certain time. The bug is that it checks if a proposal is scheduled after running the batch, so an attacker can sneak in a call that schedules the batch itself, making the whole batch succeed. This lets anyone who can create a proposal take over the timelock and do anything the DAO could do.
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.