MorpheusAI

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

Front-Running Exploitation through Insecure Deadline Setting in L2TokenReciever::swap

Summary

The vulnerability found lies in the L2TokenReciever::swap function setting the deadline for the swap transaction to the current block timestamp using block.timestamp. This approach is susceptible to front-running attacks and can be exploited by malicious actors.

Vulnerability Details

By setting the deadline to the current block timestamp, the contract allows anyone with malicious intent to manipulate the transaction execution by watching the mem pool and Front-running the transaction execution. Front-running is a scenario where an attacker exploits the time delay between the submission of a transaction and its inclusion in a block. In this case, an attacker could submit a transaction with a higher gas fee and a later deadline, effectively replacing the original transaction in the pending block and manipulating the outcome in their favor.

function swap(uint256 amountIn_, uint256 amountOutMinimum_) external onlyOwner returns (uint256) {
SwapParams memory params_ = params;
ISwapRouter.ExactInputSingleParams memory swapParams_ = ISwapRouter.ExactInputSingleParams({
tokenIn: params_.tokenIn,
tokenOut: params_.tokenOut,
fee: params_.fee,
recipient: address(this),
deadline: block.timestamp,// <--------@audit-issue front running can occur here
amountIn: amountIn_,
amountOutMinimum: amountOutMinimum_,
sqrtPriceLimitX96: params_.sqrtPriceLimitX96
});

Impact

The impact of this vulnerability is that the contract is vulnerable to front-running attacks, which can result in undesirable outcomes such as suboptimal swap rates or failed transactions. Malicious actors can exploit the time-sensitive nature of blockchain transactions to their advantage, potentially causing financial losses or disruptions.

Tools Used

Manual Review

Recommendations

To address this vulnerability, it is recommended to use a more secure and deterministic approach for setting the deadline. for instance using a uint256 _deadline parameter in the function such as:

function swap(uint256 amountIn_, uint256 amountOutMinimum_, uint256 _deadline) external onlyOwner returns (uint256) {
SwapParams memory params_ = params;
ISwapRouter.ExactInputSingleParams memory swapParams_ = ISwapRouter.ExactInputSingleParams({
tokenIn: params_.tokenIn,
tokenOut: params_.tokenOut,
fee: params_.fee,
recipient: address(this),
deadline: _deadline,//
amountIn: amountIn_,
amountOutMinimum: amountOutMinimum_,
sqrtPriceLimitX96: params_.sqrtPriceLimitX96
});
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.