medium

Missing deadline check allow pending transactions to be maliciously executed

Contest
Reward

Total

7.87 USDC

Selected
0.22 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
0.16 USDC
Selected Submission

Missing deadline check allow pending transactions to be maliciously executed

Severity

Medium Risk

Relevant GitHub Links

https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/SmartVaultV3.sol#L214-#L231

Summary

SmartVaultV3#swap() function does not allow users to submit a deadline for their actions which execute swaps on Uniswap. This missing feature enables pending transactions to be maliciously executed at a later point.

Vulnerability Details

SmartVaultV3#swap() function is using block.timestamp as deadline which can be exploited by a malicious miner.

function swap(bytes32 _inToken, bytes32 _outToken, uint256 _amount) external onlyOwner {
    uint256 swapFee = _amount * ISmartVaultManagerV3(manager).swapFeeRate() / ISmartVaultManagerV3(manager).HUNDRED_PC();
    address inToken = getSwapAddressFor(_inToken);
    uint256 minimumAmountOut = calculateMinimumAmountOut(_inToken, _outToken, _amount);
    ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
            tokenIn: inToken,
            tokenOut: getSwapAddressFor(_outToken),
            fee: 3000,
            recipient: address(this),
            deadline: block.timestamp,      // <----
            amountIn: _amount - swapFee,
            amountOutMinimum: minimumAmountOut,
            sqrtPriceLimitX96: 0
        });
    inToken == ISmartVaultManagerV3(manager).weth() ?
        executeNativeSwapAndFee(params, swapFee) :
        executeERC20SwapAndFee(params, swapFee);
}

Impact

Swap can be maliciously executed later, user can face up with the loss when the value of token change. In the worst scenario, vault can be liquidated because of the swap.

Tools Used

Manual review.

Recommendations

User should be able to set the deadline.