Some setters’ timelock can be bypassed
The timelock mechanism for setting privileged addresses in several contracts could be bypassed by the owner. An attacker with owner privileges could set a new minter or distributor without waiting for the intended delay, reducing the notice period for such changes.
Submitted by zzzitron, also found by berndartmueller, GimelSec, GiveMeTestEther, and sseefried
MED - Function could be impacted
As the timelock does not work as supposed to work, the owner of the contract can bypass timelock.
-
Affected Functions:
GolomToken:setMinter,executeSetMinterGolomTrader:setDistributor,executeSetDistributorRewardDistributor:addVoteEscrow,executeAddVoteEscrow
Proof of Concept
- GolomTrader::it can bypass timelock poc
- GolomToken::setMinter it should set the minter with timelock poc
The first poc shows to bypass timelock for GolomTrader::setDistributor. The same logic applies for the RewardDistributor::addVoteEscrow.
0. The setDistributor was called once in the beforeEach block to set the initial distributor. For this exploit to work, the setDistributor should be called only once. If setDistributor was called more than once, one can set the distributor to zero address (with timelock like in the GolomToken case, then set to a new distributor after that)
- reset distributor to zero address without timelock by calling
executeSetDistributor - set a new distributor without timelock by calling
setDistributor - Rinse and repeat: as long as
setDistributoris not called multiple times in row, the owner can keep setting distributor without timelock.
A little bit different variation of timelock bypass was found in the GolomToken. Although the owner should wait for the timelock to set the minter to zero address, but after that, the owner can set to the new minter without waiting for a timelock. Since the meaning of timelock is to let people know the new minter’s implementation, if the owner can bypass that, the timelock is almost meaningless.
The exploitation steps: the second proof of concept
- call
setMineterwith zero address - wait for the timelock
- call
executeSetMineterto set the minter to zero address - now the onwer can call
setMineterwith any address and callexecuteSetMinterwithout waiting for the timelock
The owner can call executeSetdistributor even though there is no pendingDistributor set before. Also, setDistributor sets the new distributor without timelock when the existing distributor’s address is zero.
// GolomTrader
// almost identical logic was used in `RewardDistributor` to addVoteEscrow
// similar logic was used in `GolomToken` to `setMineter`
444 function setDistributor(address _distributor) external onlyOwner {
445 if (address(distributor) == address(0)) {
446 distributor = Distributor(_distributor);
447 } else {
448 pendingDistributor = _distributor;
449 distributorEnableDate = block.timestamp + 1 days;
450 }
451 }
452
453 /// @notice Executes the set distributor function after the timelock
454 function executeSetDistributor() external onlyOwner {
455 require(distributorEnableDate <= block.timestamp, 'not allowed');
456 distributor = Distributor(pendingDistributor);
457 }
Recommended Mitigation Steps
To mitigate, execute functions can check whether pendingDistributor is not zero. It will ensure that the setters are called before executing them, as well as prevent to set to zero addresses.
0xsaruman (Golom) disputed and commented:
call setMineter with zero address wait for the timelock
This alone will trigger awareness that something malicious is happening and since timelock is there people have time to get out.
0xsaruman (Golom) confirmed and commented:
The second POC is valid.
0xsaruman (Golom) resolved and commented:
Removed all secondary time locks in the contract and only using the primary timelock that will be behind the owner.
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 setter functions allow setting the privileged address to zero without a timelock, and the execute functions do not require a pending address to be set, so the owner can reset and then set a new address immediately.
Impact
The owner could bypass the timelock and change critical addresses without the intended delay, reducing the notice period for users.
What the attacker needed
Owner privileges
The fix
The execute functions should check that the pending address is not zero, ensuring setters are called before executing and preventing setting to zero addresses.
How it was found
- Call setDistributor to set the distributor to the zero address without a timelock.
- Call executeSetDistributor to reset the distributor to zero.
- Call setDistributor again with a new address, which now sets it without a timelock.
- Repeat as long as setDistributor is not called multiple times in a row.
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 delay that gives people time to see and react to a change before it happens. Here, the delay could be skipped by first setting the address to zero and then setting a new one, so the protection was ineffective.
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.