SSSwap

First Flight #41
Beginner FriendlyRust
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

swap_tokens Allows Swapping Identical Token In and Out

Root + Impact

No validation exists to block swapping from a token to itself.

Description

  • Calling swap with from_token == to_token causes unnecessary logic execution and potential event/log confusion.

// @> swap_operations.rs
pub fn swap_tokens(...) {
...
// No check to prevent same-token swap
// This opens up gas grief or log spoof
}

Risk

Likelihood:

  • Easy to exploit with simple UI interaction or script

  • Common pattern where validation is forgotten

Impact:

  • Wastes gas, pollutes logs and events

  • May lead to unexpected balances due to rounding

Proof of Concept

No-op swap goes through, produces misleading outcome

swap_tokens(
from_token = DAI,
to_token = DAI,
amount_in = 1_000_000,
min_expected_amount = 1
)

Recommended Mitigation

Add check and then Reject same-token swaps upfront.

ensure!(from_token != to_token, Error::InvalidSwap);
Updates

Lead Judging Commences

0xtimefliez Lead Judge 7 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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