Router does not check if Exact Out Single Swap was partial leading to unexpected results for the users
The Router contract for single exact-out swaps only checks that the input amount paid is below the user's maximum, but does not verify that the full requested output amount was received. If the pool has insufficient liquidity or a restrictive price limit, the swap can be partially filled, so the user receives less output than intended while the transaction still succeeds.
hakunamatata Follow with thimthor
Originally disclosed on Code4rena
Submitted by hakunamatata, also found by thimthor
https://github.com/code-423n4/2025-11-ekubo/blob/main/src/Router.sol#L94-L149
Finding description and impact
The Router contract supports Single and Multihop swaps in both Exact-In and Exact-Out “modes”. For Single-hop swaps, the router calls the pool’s swap function and performs the following validations:
- Exact-In: Verifies that
amountOfTokenOutReceived >= minimumAmountOfTokenOutAmountRequired(user input) - Exact-Out: verifies that
amountOfTokenInToPay <= maximumAmountOfTokenInToPay(user input)
However, for Single Exact Out swaps, one critical validation is missing.
If the pool cannot provide the full desired output amount due to insufficient liquidity or restrictive sqrtRatioLimit, the swap may be partially filled. In such a case, the pool returns a smaller output amount along with smaller input amount to pay. Because the router only checks whether the payment is below the user-provided limit, the validation still passes even though the user did not receive the exact requested output amount.
This situation leads to unexpected and potentially harmful user outcomes, including:
- Users receiving less output than intended while the transaction still succeeds
- Integrating contract may be affected by that unusual behaviour
Note: In the router code, there are no amountOfTokenOutReceived/amountOfTokenInToPay named variables, but I wrote the report using my own naming for clarity as describing everything with amountCalculated that can be positive or negative seems less clear.
Recommended Mitigation Steps
One of the mitigations is to implement behaviour similar to uniswap v3 router, which if sqrtRatioLimit is equal to 0 (default one), the router enforces that swap is NOT partial. For reference:
https://github.com/Uniswap/v3-periphery/blob/main/contracts/SwapRouter.sol#L193-L199
You could also add a user specified flag for exact output swaps e.g allowPartialFill.
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 router omits a check that the received output amount equals the requested exact output amount for single exact-out swaps, only validating the input payment cap.
Impact
Users could receive less output than intended while the transaction still succeeds, and integrating contracts may be affected by this unusual behaviour.
What the attacker needed
Pool has insufficient liquidity; or restrictive sqrtRatioLimit; user performs single exact-out swap
The fix
The router should enforce that single exact-out swaps are not partial when the price limit is at its default, or allow users to opt in to partial fills with a flag.
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.
When you swap tokens, you can say 'I want exactly this much output, and I'll pay up to this much input.' The router checks you didn't pay too much, but forgets to check you actually got the full output you asked for. So if the pool can't give you everything, you get less than you wanted and the trade still goes through.
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.