MorpheusAI

MorpheusAI
Foundry
22,500 USDC
View results
Submission Details
Severity: medium
Invalid

Using block.timestamp in swap function prone to attack

Summary

Using block.timestamp in a swap function in Solidity carries certain risks

Vulnerability Details

Using block.timestamp in a swap function in Solidity carries certain risks:

A-Manipulation by Miners: Miners can manipulate the block.timestamp value to a certain extent. On Ethereum, this can be up to a few seconds. In some cases, this manipulation can lead to serious consequences,

B-Timing Attacks: In some scenarios, l miners can manipulate the timestamp to gain an unfair advantage. .
C- Sandwich Attacks: If block.timestamp is used to set a deadline for a transaction, a malicious actor can manipulate the timestamp to perform a sandwich attack. This occurs when the attacker places a transaction both before and after a victim's transaction, taking advantage of price fluctuations caused by the victim's transaction 1.

Impact

Medium

Tools Used

Manual review

Recommendations:

To mitigate these risks, consider the following strategies:

1- Use Block Number: Instead of relying on timestamps, consider using the block number as a reference point for time-related decisions. Block numbers are immutable and are not subject to manipulation .

2-External Time Oracle: Integrate an external time oracle. These oracles fetch real-world time and provide it to your smart contract, minimizing the risk of manipulation .

3-Thresholds and Confirmations: Implement thresholds and confirmation mechanisms for time-dependent actions. Require multiple blocks to confirm the passage of time before executing critical functions .

Updates

Lead Judging Commences

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

Protocol should not use block.timestamp as deadline in Uniswap interactions because it renders the protection mechanism useless

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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