Delayed Transaction Execution Due to Lack of Deadline in Swap Functions in UniSwapper
Contract
#253
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-24
insufficient quality report
This report is not of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-01-decent/blob/07ef78215e3d246d47a410651906287c6acec3ef/src/swappers/UniSwapper.sol#L130-L135
https://github.com/code-423n4/2024-01-decent/blob/07ef78215e3d246d47a410651906287c6acec3ef/src/swappers/UniSwapper.sol#L150-L156
Vulnerability details
Delayed Transaction Execution Due to Lack of Deadline in Swap Functions in
UniSwapper
ContractThe
swapExactIn
andswapExactOut
functions within theUniSwapper
contract are used to perform token swaps, potentially interacting with Uniswap V3. These functions currently do not include adeadline
parameter, which is a standard feature in decentralized exchange protocols to ensure that swaps are executed within a certain timeframe. The absence of a deadline can lead to delayed transaction execution, resulting in swaps being executed under market conditions that may have changed unfavorably since the transaction was initiated or the transaction will wait a long time to reach a favorable condition.Impact
The lack of a deadline parameter can have several adverse effects:
Delayed Execution: Without a deadline, transactions can remain pending for an extended period, especially during times of network congestion. This delay increases the risk of price movements that can result in unfavorable execution rates.
Market Volatility Exposure: Cryptocurrency markets are highly volatile. A swap executed much later than intended can be subject to significant price slippage, potentially leading to a trade at a rate that is worse than the user's expectations.
Ineffective Trading Strategies: Automated trading strategies that rely on timely execution may become ineffective if transactions are not executed within the expected timeframe.
Proof of Concept
The issue is present in the
swapExactIn
andswapExactOut
functions:Both
ExactInputParams
at line 130 andExactOutputParams
at line 150 are lacking the inclusion of thedeadline
parameter.https://github.com/code-423n4/2024-01-decent/blob/07ef78215e3d246d47a410651906287c6acec3ef/src/swappers/UniSwapper.sol#L130C1-L135C16
https://github.com/code-423n4/2024-01-decent/blob/07ef78215e3d246d47a410651906287c6acec3ef/src/swappers/UniSwapper.sol#L150C13-L156C16
PoC
swapExactIn
function.Alice's swap is executed with maximum slippage due to the absence of a deadline, resulting in her receiving less USDC than she expected at the time of initiating the swap.
Tools Used
Manual Review
Recommended Mitigation Steps
To mitigate this issue, it is recommended to add a
deadline
parameter to theExactInputParams
andExactOutputParams
when calling Uniswap V3's swap functions. Thedeadline
should be set toblock.timestamp
that represents the latest time by which the transaction should be executed.Here is an example modification:
By implementing a
deadline
, the UniSwapper contract will ensure that swaps are executed within a reasonable and expected timeframe, providing users with protection against unfavorable market movements and enhancing the overall reliability of the trading operation.Assessed type
Uniswap
The text was updated successfully, but these errors were encountered: