Members lose SPARTA tokens in removeLiquiditySingle()
When a member called removeLiquiditySingle() asking only for SPARTA, the SPARTA portion of their LP tokens was left in the Router contract instead of being returned to them. The member effectively lost that SPARTA, which could later be claimed by other transactions that remove SPARTA from the Router.
Submitted by 0xRajeev, also found by cmichel and XXX
When a member calls removeLiquiditySingle() requesting only SPARTA in return, i.e. toBASE = true, the LP tokens are transferred to the Pool to withdraw the constituent SPARTA and TOKENs back to the Router. The withdrawn TOKENs are then transferred back to the Pool to convert to SPARTA and directly transferred to the member from the Pool. However, the member’s SPARTA are left behind in the Router instead of being returned along with converted SPARTA from the Pool.
In other words, the _member’s BASE SPARTA tokens that were removed from the Pool along with the TOKENs are never sent back to the_member because the _token’s transferred to the Pool are converted to SPARTA and only those are sent back to member directly from the Pool via swapTo().
This effectively results in member losing the SPARTA component of their Pool LP tokens which get left behind in the Router and are possibly claimed by future transactions that remove SPARTA from Router.
LPs sent to Pool, SPARTA and TOKENs withdrawn from Pool to Router, TOKENs from Router sent to Pool, and TOKENs in Pool converted to BASE SPARTA and sent to member directly from the Pool.
Recommend:
- BASE SPARTA should also be transferred to the Pool before
swapTo()so they get sent to the member along with the converted TOKENs viaswapTo() - Use
swap(BASE)instead ofswapTo()so that TOKENs are swapped for BASE SPARTA in Pool and sent back to ROUTER. Then send all the SPARTA from ROUTER to member.
verifyfirst (Spartan) confirmed:
This bug was missed in a last minute edit before pushing to code423n4, wouldn’t have made it past testNet testing. However, it is a good find.
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 withdrew both SPARTA and TOKENs from the Pool but only forwarded the TOKENs to the Pool for conversion, never sending the withdrawn SPARTA back to the member.
Impact
The member loses the SPARTA component of their LP tokens, and that SPARTA could be claimed by later transactions that remove SPARTA from the Router.
What the attacker needed
Member holds Pool LP tokens; member calls removeLiquiditySingle with toBASE true
The fix
The report recommends either sending the withdrawn SPARTA to the Pool before swapTo() so it reaches the member, or using swap(BASE) so all SPARTA is returned to the Router and then forwarded to the member.
How it was found
- A member calls removeLiquiditySingle() with toBASE set to true, asking for only SPARTA.
- The LP tokens are transferred to the Pool and both SPARTA and TOKENs are withdrawn to the Router.
- Only the TOKENs are sent from the Router to the Pool and converted to SPARTA, which is sent to the member directly from the Pool.
- The SPARTA that was withdrawn to the Router is never forwarded, so it stays there.
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 liquidity pool holds two kinds of tokens together, and people who add them get pool tokens in return. When they cash out asking for only one of the two tokens, the contract is supposed to convert everything and send it back. Here a coding mistake meant one half of the payout stayed stuck inside the contract instead of reaching the person.
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.