Skip to content
Business logic Audit finding Beginner

Setting delay at MINIMUM_DELAY in timelock fails

The timelock contract rejects any new delay that is less than or equal to the minimum delay, so setting the delay exactly to the minimum value reverts. An operator trying to set the delay to the documented minimum would see the transaction fail unexpectedly.

haxatron1 Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

28632 - [SC - Insight] Setting delay at MINIMUM_DELAY in timelock fails

Submitted on Feb 22nd 2024 at 19:10:48 UTC by @Haxatron for Boost | Puffer Finance

Report ID: #28632

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

Introduction

Due to the use of >= instead of >, setting the delay exactly at the MINIMUM_DELAY will fail.

Vulnerability Details

When setting a delay for the timelock, there is a MINIMUM_DELAY set for the timelock.

Solidity
     * @notice Minimum delay enforced by the contract
     */
    uint256 public constant MINIMUM_DELAY = 7 days;

However when checking for this delay, >= is used instead of >.

Solidity
    function _setDelay(uint256 newDelay) internal {
        if (newDelay <= MINIMUM_DELAY) {
            revert InvalidDelay(newDelay);
        }
        emit DelayChanged(delay, newDelay);
        delay = newDelay;
    }

Therefore setting the delay at exactly MINIMUM_DELAY will cause the newDelay <= MINIMUM_DELAY check to be true and therefore the setDelay transaction to revert.

Impact Details

This can be surprising to users such as the operations multisig, that waited to execute their setDelay transaction but their transaction will unexpectedly fail because of the above behaviour.

References

https://etherscan.io/address/0x3C28B7c7Ba1A1f55c9Ce66b263B33B204f2126eA?utm\\_source=immunefi#code

Proof of Concept

Add this to the test/unit/Timelock.t.sol test found in https://github.com/PufferFinance/pufETH

Solidity
function test_updating_to_minimum_delay_reverts() public {
        vm.startPrank(timelock.COMMUNITY_MULTISIG());

        // set exactly at minimum delay
        bytes memory minimumDelayCallData = abi.encodeCall(Timelock.setDelay, (7 days));

        uint256 operationId = 1234;

        // update to minimum delay
        (bool success, bytes memory returnData) =
            timelock.executeTransaction(address(timelock), minimumDelayCallData, operationId);

        // confirm the transaction failed
        assertEq(success, false);

        // confirm the delay is not set at minimum delay of 7 days
        assertTrue(timelock.delay() != 7 days, "not equal minimum delay");
    }

The original report as published on Immunefi, by Haxatron. 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 comparison uses <= instead of <, so the boundary value equal to MINIMUM_DELAY is rejected.

Impact

The timelock cannot be set to its documented minimum delay, which could surprise operators whose transaction fails; no funds are lost.

What the attacker needed

Ability to call setDelay on the timelock

The fix

The comparison should be changed to reject only delays strictly below the minimum, for example by using < instead of <=.

How it was found

  1. Call setDelay with a new delay of exactly seven days.
  2. The check newDelay <= MINIMUM_DELAY evaluates to true.
  3. The transaction reverts with InvalidDelay.

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 allow any delay of at least seven days, but the check also rejects exactly seven days, so a valid setting is 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 by haxatron1

View all

7 more disclosed reports, best first.

More from Puffer Finance

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.