MINIMUM_DELAY uses incorrect value of days ins
The Timelock contract hard-codes a minimum delay of seven days, but the project's stated specification says the minimum should be two days. As a result, the multisig cannot set any delay between two and seven days, because such calls revert with an invalid-delay error.
Originally disclosed on Immunefi
- Disclosed after under an hour
28729 - [SC - Insight] MINIMUM_DELAY uses incorrect value of days ins...
Submitted on Feb 25th 2024 at 09:04:26 UTC by @MrPotatoMagic for Boost | Puffer Finance
Report ID: #28729
Report type: Smart Contract
Report severity: Insight
Target: https://etherscan.io/address/0x3C28B7c7Ba1A1f55c9Ce66b263B33B204f2126eA#code
Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
The Timelock.sol contract currently uses a MINIMUM_DELAY constant value of 7 days. But according the specification/expected behaviour mentioned by the sponsors in the Technical walkthrough (referenced below), the minimum delay is supposed to be 2 days.
References
https://youtu.be/u1lYGykS-7g?si=-xVed8AAHZ8NkVHh\\&t=2436
Impact Details
Since the minimum delay is expected to be 2 days, when the operation/community multisig try to set a delay in the range [2,7], the call would revert with InvalidDelay error.
Due to this, the issue has been marked as low-severity since the contract fails to deliver promised results and does not abide by its specification/expected behaviour.
Vulnerability Details
Here is the whole process:
- First , let's take a look at the MINIMUM_DELAY constant value in the Timelock.sol contract:
- As we can see, the code is deployed with a constant (immutable) value of 7 days rather than the expected value of 2 days.
File: Timelock.sol
101: uint256 public constant MINIMUM_DELAY = 7 days;
- This mean that when the operation/community multisig calls the function
setDelay()through the functionexecuteTransaction()with a value in the range [2,7], the call would revert with theInvalidDelayerror. This denies the operators/community from setting a value in that range and forces them to set delay to a value greater than 7 days.
File: Timelock.sol
295: function _setDelay(uint256 newDelay) internal {
296:
297: if (newDelay <= MINIMUM_DELAY) {
298: revert InvalidDelay(newDelay);
299: }
300: emit DelayChanged(delay, newDelay);
301: delay = newDelay;
302: }
Proof of Concept
How to use this POC:
- Add the POC to the Timelock.t.sol file.
- Run the test using
forge test --fork-url <ETH_MAINNET_RPC_URL> --match-test testIncorrectMinDelayIssue -vvv
function testIncorrectMinDelayIssue() public {
uint256 operationId;
for (uint256 i = 2; i <= 7 ; i++) {
bytes memory callData = abi.encodeCall(Timelock.setDelay, (86400*i));
operationId++;
vm.prank(timelock.COMMUNITY_MULTISIG());
timelock.executeTransaction(address(timelock), callData, operationId);
assertNotEq(timelock.delay(), 86400*i);
}
}
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 minimum-delay constant was set to seven days instead of the two days described in the specification.
Impact
Operators cannot set a delay in the two-to-seven-day range and are forced to choose more than seven days, so the contract does not behave as specified, though no funds are lost.
What the attacker needed
Community multisig role; delay value between 2 and 7 days
How it was found
- Note the contract's minimum delay constant is seven days.
- Have the community multisig call the delay-setting function through the transaction executor with a delay between two and seven days.
- Observe the call reverts with the invalid-delay error.
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 makes changes wait a set period before they take effect, so people have time to react. This contract refuses any delay shorter than seven days, but the team said the shortest allowed should be two days. So the operators cannot pick a delay of, say, three days, even though the rules say they should be able to.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.