SetDelay function doesnt revert even when the d
The setDelay function in a timelock contract used a greater-than-or-equal check against the minimum delay, so the delay could be set to exactly the minimum instead of strictly above it. This contradicts the stated intent that the delay must exceed the minimum, though no value is lost.
Originally disclosed on Immunefi
- Disclosed after under an hour
25906 - [SC - Insight] setDelay function doesnt revert even when the d...
Submitted on Nov 20th 2023 at 23:43:57 UTC by @ThreeHrSleep for Boost | DeGate
Report ID: #25906
Report type: Smart Contract
Report severity: Insight
Target: https://etherscan.io/address/0xf2991507952d9594e71a44a54fb19f3109d213a5#code
Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Bug Description
While using the setDelay() function,it's supposed to revert when the delay doesn't exceed the MINIMUM_DELAY. But due to wrong validation logic, the delay can be set to exactly MINIMUM_DELAY. In setDelay() function,it's making sure that delay_ >= MINIMUM_DELAY(delay is greater or equals minimum delay)
require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
where as it should have been delay_ > MINIMUM_DELAY to make sure that Delay is exceeding minimum delay.
Impact
Intended behaviour of the smart contract and actual functionality doesn't match
Risk Breakdown
Difficulty to Exploit: Easy Weakness: N/A CVSS2 Score: N/A
Recommendation
change the require statement at line 226 https://etherscan.io/address/0xf2991507952d9594e71a44a54fb19f3109d213a5#code#F1#L226 from
require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
to
require(delay_ > MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
References
https://etherscan.io/address/0xf2991507952d9594e71a44a54fb19f3109d213a5#code#F1#L226
function setDelay(uint delay_) public {
require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock.");
require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");
delay = delay_;
emit NewDelay(delay);
}
Proof of concept
To demonstrate the issue,here the setDelay() function is called with the exact Minimum Delay(45 days,which is 3888000 seconds),and it is not reverting even though the delay isn't exceeding minimum 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
The validation used a greater-than-or-equal comparison instead of a strict greater-than comparison against the minimum delay.
Impact
The contract's behaviour does not match its stated intent, but no funds are lost and the delay cannot go below the minimum.
What the attacker needed
Caller must be the timelock itself
The fix
The require statement should be changed to use a strict greater-than comparison against the minimum delay.
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. The code meant to reject any delay that was not longer than the minimum, but its check also allowed a delay exactly equal to the minimum. So the contract accepted a value the developers said should be refused.
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.