DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: high
Invalid

Incorrect Slippage Validation in StrategyArb.sol

Summary

The StrategyArb contract contains an incorrect slippage validation implementation within the _swapUnderlyingToAsset function. The current slippage validation relies solely on the minOut parameter passed by the caller. This approach allows an attacker to set an unreasonably low minOut value, enabling swaps at unfavorable prices and potentially causing significant losses for the protocol.

Vulnerability Details

function _swapUnderlyingToAsset(uint256 _amount, uint256 minOut, IRamsesRouter.route[] calldata _path) internal {
require(minOut > _amount, "minOut too low");
uint256 underlyingBalance = underlying.balanceOf(address(this));
require(underlyingBalance >= _amount, "not enough underlying balance");
IRamsesRouter(router).swapExactTokensForTokens(_amount, minOut, _path, address(this), block.timestamp);
}

Caller-Defined minOut: The minOut parameter, which determines the minimum acceptable output tokens, is supplied by the caller and lacks verification against price oracles.

  • No Price Oracle Integration: There is no mechanism to validate the swap rate (e.g., using a price oracle) to ensure that the swap occurs at a fair price.

Exploitation Scenario

  1. A malicious keeper calls the claimAndSwap function with a deliberately low minOut value.

  2. The _swapUnderlyingToAsset function approves the transaction as long as the minOut is marginally greater than _amount, bypassing slippage protection.

  3. The attacker routes the swap through unfavorable paths, causing a significant loss in the value of tokens received compared to the underlying tokens sent.

Tools Used

Mqnual Review

Recommendations

Price Oracle Validation
Use a reliable price oracle (e.g., Chainlink) to fetch the current market price of underlying and asset. Compare the swap rate with the oracle price and ensure it does not exceed a predefined slippage tolerance. Example:

uint256 oraclePrice = fetchOraclePrice(); // Fetch price from an oracle
uint256 expectedMinOut = (_amount * oraclePrice) / 1e18;
require(minOut >= (expectedMinOut * (100 - slippageTolerance)) / 100, "Slippage too high");
Updates

Appeal created

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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