Skip to content
Business logic Audit finding Intermediate

Using block.timestamp as the deadline/expiry invites MEV

The contract used block.timestamp as the swap deadline, which does not enforce immediate execution but allows a malicious miner to delay the transaction until it becomes profitable to extract MEV. An attacker could hold the transaction to cause maximum slippage or trigger liquidations.

IllIllI Follow

Originally disclosed on Code4rena

Submitted by IllIllI

Note: this finding was reported via the winning Automated Findings report. It was declared out of scope for the audit, but is being included here for completeness.

Passing block.timestamp as the expiry/deadline of an operation does not mean “require immediate execution” - it means “whatever block this transaction appears in, I’m comfortable with that block’s timestamp”. Providing this value means that a malicious miner can hold the transaction for as long as they like (think the flashbots mempool for bundling transactions), which may be until they are able to cause the transaction to incur the maximum amount of slippage allowed by the slippage parameter, or until conditions become unfavorable enough that other orders, e.g. liquidations, are triggered. Timestamps should be chosen off-chain, and should be specified by the caller to avoid unnecessary MEV.

There is one instance of this issue:

File: contracts/amo/UniV2LiquidityAmo.sol

337        .swapExactTokensForTokens(
338          token1Amount,
339          token2AmountOutMin,
340          path,
341          address(this),
342          block.timestamp + 1
343        )[path.length - 1];
344
345:     // send tokens back to rdpxV2Core

GitHub: 337

psytama (Dopex) confirmed

Alex the Entreprenerd (Judge) commented

This I agree with the sponsor that could be considered Medium as it allows MEV to be extracted by delaying tx inclusion.


The original report as published on Code4rena, by IllIllI. 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 passed block.timestamp as the swap deadline, which does not enforce immediate execution and allows miners to delay inclusion.

Impact

A malicious miner could delay the transaction to extract MEV, potentially causing maximum slippage or triggering liquidations.

What the attacker needed

Malicious miner or MEV bot

The fix

The deadline should be chosen off-chain and specified by the caller to avoid unnecessary MEV.

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.

When a smart contract sets a deadline using the current block's timestamp, it doesn't mean the transaction must happen right away. A miner can choose to include the transaction in a later block, potentially after prices have moved, to profit at the user's expense. This is a form of MEV (miner extractable value), where miners or bots exploit transaction ordering.

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 IllIllI

View all

119 more disclosed reports, best first.

More from Dopex

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.