Skip to content
Business logic Audit finding Beginner

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.

ThreeHrSleep Follow

Originally disclosed on Immunefi

Informational View original
  • 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

https://dashboard.tenderly.co/shared/fork/ce6516a7-e525-4be2-abb9-130d0cb1446d/simulation/e72b88be-52ad-4e3b-a651-b9b31542bf41?trace=0

The original report as published on Immunefi, by ThreeHrSleep. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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.

More from DeGate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.