Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

The same `horseId` can be happy on `Arbitrum` but unhappy on `Ethereum`

Summary

At the same time the same horse can be happy on Arbitrum and unhappy on Ethereum due to the way in which block.timestamp works on Arbitrum.

Vulnerability Details

The project will be deployed on Arbitrum and Ethereum. Also, the HorseStore::isHappyHorse relies on block.timestamp to check the time when the horse was last fed. But the block.timestamp on Arbitrum works differently.

In the Arbitrum documentation is said:

Block timestamps on Arbitrum are not linked to the timestamp of the L1 block. They are updated every L2 block based on the sequencer's clock. These timestamps must follow these two rules:
- Must be always equal or greater than the previous L2 block timestamp
- Must fall within the established boundaries (24 hours earlier than the current time or 1 hour in the future). More on this below.
Furthermore, for transactions that are force-included from L1 (bypassing the sequencer), the block timestamp will be equal to either the L1 timestamp when the transaction was put in the delayed inbox on L1 (not when it was force-included), or the L2 timestamp of the previous L2 block, whichever of the two timestamps is greater.

https://docs.arbitrum.io/for-devs/concepts/differences-between-arbitrum-ethereum/block-numbers-and-time#block-timestamps-arbitrum-vs-ethereum

Impact

Due to the way in which the block.timestamp works on Arbitrum it is possible the following scenario:

Bob feeds the horse with Id 1 at 15 hour on 18 January. On the next day (19 January) at 17 hour Alice checks if the horse with Id 1 is happy. The contract is deployed on Arbitrum and the block.timestamp can return value that is 24 hours earlier than the current time. So, the HorseStore::isHappyHorse function returns true, because for the function is 17 hour on 18 January and the horse was fed 2 hours ago. But actually the horse was fed 26 hours ago and it is unhappy. On the Ethereum the horse will be unhappy.

Tools Used

Manual Review

Recommendations

Ensure that the return value of the HorseStore::isHappyHorse function is reliable on every chain that the project is deployed.

Updates

Lead Judging Commences

inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Arbitrum timestamps can be inaccurate.

Block timestamps can vary between Arbitrum and Ethereum in case sequencer fails to post batches on the parent chain within a [24 hours earlier than the current time or 1 hour in the future] boundary. This can lead to inconsistencies for Horses minted on Arb.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.