Skip to content
Business logic Audit finding Intermediate

Initial Liquidity provider can bypass the withdrawal limit

The initial liquidity provider can bypass the 25% weekly withdrawal limit because the check is skipped when only one withdrawal remains, allowing them to withdraw all remaining liquidity at once. This enables a rug pull, harming other users.

AhmedAdam Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-03-goat-trading-judging/issues/94

Found by

AhmedAdam

Summary

the initial liquidity provider can bypass maximum withdrawal limit and withdraw all the liquidity that he has leading to a rug pull.

Vulnerability Detail

According to the protocol documentation, mandatory liquidity locks are implemented, restricting the initial liquidity provider to withdraw only 25% of their liquidity each week. The check for this restriction is enforced within the _beforeTokenTransfer function as follows:

if (amount > lpInfo.fractionalBalance) {
                    revert GoatErrors.BurnLimitExceeded();
                }

but this check isn't done if the number of withdrawals left for the lp is 1. so the initial liquidity provider can withdraw the whole amount of lp tokens that he has, bypassing the 25% limit.

Proof of Concept:

  • Assume the initial liquidity provider holds 100 LP tokens of the pair tokenA/WETH, and the pool is in the AMM phase.
  • Over the first three weeks, they burn 1 LP token each week.
  • By the fourth week, they have 97 LP tokens remaining, and they withdraw all of them.
  • This action effectively results in a rug pull, harming the users of the protocol.

Impact

a key invariant of the system gets breached by having the inital liquidity provider able to bypass the withdraw limit

Code Snippet

https://github.com/sherlock-audit/2024-03-goat-trading/blob/beb09519ad0c0ec0fdf5b96060fe5e4aafd71cff/goat-trading/contracts/exchange/GoatV1Pair.sol#L886-L909

Tool used

Manual Review

Discussion

sherlock-admin4

The protocol team fixed this issue in the following PRs/commits: https://github.com/inedibleX/goat-trading/pull/8

sherlock-admin4

The Lead Senior Watson signed off on the fix.

The original report as published on Sherlock, by AhmedAdam. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 withdrawal limit check is conditionally skipped when the number of withdrawals left is 1, allowing the full balance to be withdrawn.

Impact

The initial liquidity provider can bypass the withdrawal limit and withdraw all their liquidity, effectively performing a rug pull that harms protocol users.

What the attacker needed

Be the initial liquidity provider; pool in AMM phase; wait until one withdrawal remains

The fix

The protocol team fixed this issue in the referenced PR.

How it was found

  1. Assume the initial liquidity provider holds 100 LP tokens and the pool is in AMM phase.
  2. Over the first three weeks, burn 1 LP token each week.
  3. By the fourth week, 97 LP tokens remain, and withdraw all of them.

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 provider puts tokens into a trading pool. The protocol tries to stop the first provider from taking everything out at once by limiting withdrawals to 25% per week. But a mistake in the code lets them take everything in the last allowed withdrawal, which is like a rug pull.

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.

More by AhmedAdam

View all

1 more disclosed report, best first.

More from Goat Trading

View all

The newest disclosed reports for this program.

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.