Skip to content
Business logic Audit finding Intermediate

CLOCK_MODE() will not work properly for Arbitrum or Optimism due to block.number

The governance contract used block.number as a clock, which on Arbitrum and Optimism does not track real time reliably. This could make timing-dependent governance logic behave incorrectly on those chains.

IceBear Follow with btk

Originally disclosed on Code4rena

Submitted by IceBear, also found by btk

Proof of Concept

According to Arbitrum Docs, block.number returns the most recently synced L1 block number. Once per minute, the block number in the Sequencer is synced to the actual L1 block number. Using block.number as a clock can lead to inaccurate timing.

It also presents an issue for Optimism because each transaction is it’s own block.

https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/governance/LybraGovernance.sol#L152

Recommended Mitigation Steps

Use block.timestamp rather than block.number

Assessed type

Timing

LybraFinance commented:

The governance contract only exists on the Ethereum mainnet.

LybraFinance acknowledged


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

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 contract used block.number as a proxy for elapsed time, which is unreliable on chains where block production does not map to fixed time intervals.

Impact

On Arbitrum and Optimism the governance timing logic could be inaccurate; the project stated the contract only exists on Ethereum mainnet, which limits the practical exposure.

What the attacker needed

Contract deployed on Arbitrum or Optimism

The fix

It should be fixed by using block.timestamp instead of block.number for timing.

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 smart contract can measure time in two ways: by counting blocks or by reading a timestamp. Counting blocks only works if each block takes a predictable amount of time. On some networks blocks are produced differently, so counting them gives the wrong sense of how much time has passed, and any rule that depends on that timing can misfire.

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 Lybra 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.