Openzeppelin Reentrancy Bug Fix Review
The TimelockController contract checked whether a scheduled operation was ready only after executing the call, allowing an executor to reenter and bypass the delay. An attacker with the executor role could hijack the timelock, set the delay to zero, and make arbitrary calls.
immunefi.com
Published on immunefi.com
Whitehat Zb3 submitted a critical reentrancy vulnerability in OpenZeppelin’s TimelockController contract on August 21, 2021, which affected a project hosted on Immunefi’s bug bounty platform. The project, which has elected to remain anonymous, has paid the whitehat an undisclosed amount (including a bonus for…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The isOperationReady check was placed after the external call instead of before it, allowing reentrancy.
Impact
An attacker with the executor role could hijack the TimelockController, remove proposers, set themselves as proposer, and make arbitrary calls to other contracts.
What the attacker needed
Attacker has EXECUTOR role
The fix
The fix added the isOperationReady check before the call is executed, in addition to after, to prevent reentrancy.
How it was found
- The attacker gives themselves permission to propose
- The attacker sets the delay parameter to zero
- The attacker sets an arbitrary call to be approved
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 write-up has not been written yet. The Original tab links to the source.
A timelock is a smart contract that delays actions so people can see them coming. The bug was that the contract performed the action before checking if it was allowed, so someone could sneak in extra actions during that gap. This is called a reentrancy bug.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.