Long term denial of service due to lack of fees in Well
The Well AMM charges no fees, so an attacker can sandwich a victim's swap with two trades that move the price beyond the victim's slippage limit, causing the victim's transaction to revert. The attacker's tokens are restored by the constant product formula, so the only cost is gas.
Submitted by Trust, also found by ptsanev
The Well allows users to permissionless swap assets or add and remove liquidity. Users specify the intended slippage in swapFrom, in minAmountOut.
The ConstantProduct2 implementation ensures Kend - Kstart >= 0, where K = Reserve1 * Reserve2, and the delta should only be due to tiny precision errors.
Furthermore, the Well does not impose any fees to its users. This means that all conditions hold for a successful DOS of any swap transactions.
- Token cost of sandwiching swaps is zero (no fees) - only gas cost
- Price updates are instantenous through the billion dollar formula.
- Swap transactions along with the max slippage can be viewed in the mempool
Note that such DOS attacks have serious adverse effects both on the protocol and the users. Protocol will use users due to disfunctional interactions. On the other side, users may opt to increment the max slippage in order for the TX to go through, which can be directly abused by the same MEV bots that could be performing the DOS.
Impact
All swaps can be reverted at very little cost.
PoC
-
Evil bot sees swap TX, slippage=S
-
Bot submits a flashbot bundle, with the following TXs
- Swap TX in the same direction as victim, to bump slippage above S
- Victim TX, which will revert
- Swap TX in the opposite direction and velocity to TX (1). Because of the constant product formula, all tokens will be restored to the attacker.
Recommended Mitigation Steps
Fees solve the problem described by making it too costly for attackers to DOS swaps. If DOS does takes place, liquidity providers are profiting a high APY to offset the inconvenience caused, and attract greater liquidity.
publiuss (Basin) disputed and commented:
This is an issue that is already present in other AMMs. The lack of a fee just makes the DOS cheaper than in other AMMs. However, it still requires paying for 2 Ethereum transaction fees. The use of a private mempool or a higher priority fee solves this problem.
alcueca (Judge) decreased severity to Medium and commented:
It seems to me that the DoS can be economical enough for the attacker to disrupt the UX by forcing all users to use private mempools.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the absence of any swap fee, combined with instant price updates and public mempool visibility, makes sandwich-based denial of service cheap for an attacker.
Impact
All swaps can be reverted at very little cost, disrupting the protocol and forcing users to raise slippage or use private mempools.
What the attacker needed
Attacker can see pending transactions; attacker pays gas for two transactions; victim sets a slippage limit
The fix
Introduce swap fees to make denial of service too costly, and note that private mempools or higher priority fees also mitigate it.
How it was found
- An attacker bot sees a victim's swap transaction with slippage S in the mempool.
- The bot submits a bundle containing a swap in the same direction as the victim to move the price beyond S.
- The victim's transaction is included next and reverts.
- The bot then swaps in the opposite direction, restoring its tokens due to the constant product formula.
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 report has not been written yet. The Original tab links to the source.
A decentralised exchange lets people trade tokens using a formula that sets prices. Because this exchange charges no trading fee, someone can quickly buy and sell around another person's trade to push the price past the limit that person set, making their trade fail. The attacker gets their tokens back and only pays network fees.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.