Timelock can be bypassed
The Timelock contract allowed the current governor to immediately replace itself and then set the delay to zero, so the governor could execute any privileged action without waiting. This let the governor mint unlimited tokens and grant minter roles at will.
Submitted by WatchPug, also found by 0x0x0x and gzeon
The purpose of a Timelock contract is to put a limit on the privileges of the governor, by forcing a two step process with a preset delay time.
However, we found that the current implementation actually won’t serve that purpose as it allows the governor to execute any transactions without any constraints.
To do that, the current governor can call Timelock#setGovernor(address _governor) and set a new governor effective immediately.
And the new governor can then call Timelock#setDelay() and change the delay to 0, also effective immediately.
The new governor can now use all the privileges without a delay, including granting minter role to any address and mint unlimited amount of MALT.
In conclusion, a Timelock contract is supposed to guard the protocol from lost private key or malicious actions. The current implementation won’t fulfill that mission.
function setGovernor(address _governor)
public
onlyRole(GOVERNOR_ROLE, "Must have timelock role")
{
_swapRole(_governor, governor, GOVERNOR_ROLE);
governor = _governor;
emit NewGovernor(_governor);
}
function setDelay(uint256 _delay)
public
onlyRole(GOVERNOR_ROLE, "Must have timelock role")
{
require(
_delay >= 0 && _delay < gracePeriod,
"Timelock::setDelay: Delay must not be greater equal to zero and less than gracePeriod"
);
delay = _delay;
emit NewDelay(delay);
}
Recommendation
Consider making setGovernor and setDelay only callable from the Timelock contract itself.
Specificaly, changing from onlyRole(GOVERNOR_ROLE, "Must have timelock role") to require(msg.sender == address(this), "...").
Also, consider changing _adminSetup(_admin) in Timelock#initialize() to _adminSetup(address(this)), so that all roles are managed by the timelock itself as well.
Alex the Entreprenerd (judge) commented:
The warden has identified an exploit that allows to sidestep the delay for the timelock, effectively bypassing all of the timelock’s security guarantees. Because of the gravity of this, I agree with the high risk severity.
Mitigation can be achieved by ensuring that all operations run under a time delay
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 setGovernor and setDelay functions were callable by the governor role directly instead of only by the Timelock contract itself, so the governor could bypass the delay.
Impact
The governor could bypass the timelock entirely and mint unlimited tokens or grant minter roles without any delay.
What the attacker needed
Governor role
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 meant to force a waiting period before important changes, like a safety delay. Here, the person in charge could swap themselves out and then remove the delay, so the waiting period never applied. That meant they could do anything instantly, such as creating unlimited tokens.
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.