The Standard

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

Lack of swap protection

Summary

The current implementation sets amountOutMinimum to 0, indicating that no tokens are expected in return for a swap. This poses a significant risk, as it allows malicious actors to exploit the transaction by sandwiching it and taking all tokens from the swap.

Vulnerability Details

The function calculateMinimumAmountOut in SmartVaultV3.sol returns 0 when still in bounds, indicating a lack of expectation to receive anything for the swap.

function calculateMinimumAmountOut(bytes32 _inTokenSymbol, bytes32 _outTokenSymbol, uint256 _amount) private view returns (uint256) {
ISmartVaultManagerV3 _manager = ISmartVaultManagerV3(manager);
uint256 requiredCollateralValue = minted * _manager.collateralRate() / _manager.HUNDRED_PC();
uint256 collateralValueMinusSwapValue = euroCollateral() - calculator.tokenToEur(getToken(_inTokenSymbol), _amount);
return collateralValueMinusSwapValue >= requiredCollateralValue ?
0 : calculator.eurToToken(getToken(_outTokenSymbol), requiredCollateralValue - collateralValueMinusSwapValue);
}

Impact

Setting amountOutMinimum to 0 exposes the transaction to front-running attacks, where malicious actors can exploit the lack of a minimum requirement and take all tokens from the swap, resulting in a loss of all tokens for the original sender.

Tools Used

Manual review

Recommendations

It is highly recommended to set a meaningful and non-zero value for amountOutMinimum to prevent front-running attacks. By specifying a minimum acceptable amount, the vulnerability to sandwich attacks can be mitigated.

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.