Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perfect Coffee Aardvark - Missing Slippage Protection in Token Swaps Medium Risk #1057

Open
sherlock-admin3 opened this issue Dec 30, 2024 · 0 comments

Comments

@sherlock-admin3
Copy link
Contributor

Perfect Coffee Aardvark

Medium

Missing Slippage Protection in Token Swaps Medium Risk

Summary

The swapCollateralForUSDT function in Treasury.sol executes swaps through ODOS without
any slippage protection.

Root Cause

In Treasury.sol

function swapCollateralForUSDT( 
    IBorrowing.AssetName asset,
    uint256 swapAmount,
    bytes memory odosAssembledData
) external onlyCoreContracts returns (uint256) {
    swapAmount = (swapAmount / 10) * 10;
@> (bool success, bytes memory result) = odosRouterV2.call{value: asset ==
@>     IBorrowing.AssetName.ETH ? swapAmount : 0}(odosAssembledData);
    if (!success) revert Treasury_SwapFailed();
@> return abi.decode(result, (uint256));
}

Key Issues (Lines Marked @>):
External Call Without Minimum Output Check:

The function calls the odosRouterV2 contract to execute the swap without passing or verifying a minimum acceptable output amount.
Marked at @> (bool success, bytes memory result)....
Decoding Result Without Verification:

The output from the swap is decoded and returned without validating whether it satisfies any slippage tolerance or minimum output criteria.
Marked at @> return abi.decode(result, (uint256));

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

The function blindly executes the swap with the assembled data without validating the
minimum output amount. This could allow MEV bots to extract value through sandwich attacks
or allow significant value loss if market conditions change between transaction submission
and execution.

No response

PoC

No response

Mitigation

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant