The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

slippage is not considered during swaps

Summary

The Smart Vault's swapping mechanism via Uniswap V3 lacks slippage protection, exposing it to potential sandwich attacks, risking substantial token losses

Vulnerability Details

The vulnerability exists within the swap() function, where the Smart Vault swaps collateral without accounting for slippage, making it susceptible to sandwich attacks

function swap(bytes32 _inToken, bytes32 _outToken, uint256 _amount) external onlyOwner {
// ................
uint256 minimumAmountOut = calculateMinimumAmountOut(_inToken, _outToken, _amount);
// ... ............
}

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

The calculateMinimumAmountOut() private function sets the minimum output amount

function calculateMinimumAmountOut(bytes32 _inTokenSymbol, bytes32 _outTokenSymbol, uint256 _amount) private view returns (uint256) {
// ... (existing code)
210 return collateralValueMinusSwapValue >= requiredCollateralValue ?
0 : calculator.eurToToken(getToken(_outTokenSymbol), requiredCollateralValue - collateralValueMinusSwapValue);
}

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

At line 210 minoutputAmount has been set to zero of collateralValueMinusSwapValue >= requiredCollateralValue which only makesures that smart vault is overcollateralised even after using amount input collateral tokens.

Impact

The absence of slippage consideration exposes the vault to potential token losses through sandwich attacks during swaps.

Tools Used

Manual

Recommendations

Introduce a user-input parameter allowing specification of a minimum amount out for swaps

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Slippage-issue

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

Slippage-issue

Support

FAQs

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