Skip to content
Business logic Write-up Beginner

Warden Swap

The swap function in a DEX smart contract accepts native Ether alongside ERC20 token parameters without validating that the source token is native, so the Ether is neither used nor refunded and becomes permanently locked in the contract. An attacker or careless user could lose their Ether this way.

github.com

Published on github.com

History

The author, on github.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely missing input validation: the contract does not reject transactions that send native currency when the source token is an ERC20 token.

Impact

Users could permanently lose their Ether, which becomes locked in the contract with no recovery path.

What the attacker needed

User calls swap with ERC20 token and sends ETH

The fix

The contract should be fixed by adding a check that rejects transactions sending native currency when the source token is not native Ether.

How it was found

  1. Approve the router contract to spend your ERC20 tokens.
  2. Call the swap function with ERC20 token parameters and also send native Ether as msg.value.
  3. The tokens are transferred, but the Ether remains in the contract and is not refunded.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A smart contract is a program on a blockchain that holds and moves funds automatically. This one lets you swap tokens, but if you accidentally send the blockchain's native currency (like BNB) while swapping tokens, the contract keeps that currency forever because it never checks for this mistake. The money is stuck with no way to get it back.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.