Skip to content

Latest commit

 

History

History
68 lines (40 loc) · 1.95 KB

036.md

File metadata and controls

68 lines (40 loc) · 1.95 KB

Tall Burgundy Nightingale

High

No Slippage Protection in Token Swaps

Summary

Lack of slippage control in swap operations will cause significant token value loss for users as malicious actors can manipulate token prices during the pending transaction period through sandwich attacks.

Root Cause

https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L21-L40

https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L194-L224

The choice to omit minimum output amount validation in StablecoinSwap and DefiSwap structs is a mistake as it leaves users exposed to price manipulation between transaction submission and execution.

Internal pre-conditions

User needs to submit a swap transaction with specific oAmount and tAmount values

Transaction needs to be pending in the mempool for sufficient time (usually 1-2 blocks)

External pre-conditions

Attack Path

User submits swap transaction to exchange Token A for Token B with amount X

Attacker sees this pending transaction in mempool

Attacker frontrun user's transaction with large buy of Token B, driving price up

User's transaction executes at inflated price, receiving less Token B than expected

Attacker backruns with sell of Token B at higher price

Attacker profits from price difference, user receives significantly less tokens

Impact

Users can suffer unlimited slippage losses on swaps, potentially receiving far fewer tokens than intended

PoC

No response

Mitigation

Add minOutputAmount to swap structs:

struct StablecoinSwap {
    // existing fields
    uint256 minOutputAmount; // Minimum tokens to receive
}

Add validation in verification:

function _verifyStablecoinSwap(address wallet, StablecoinSwap memory ss) internal view {
    require(ss.tAmount >= ss.minOutputAmount, "Slippage too high");
    // existing checks
}