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.
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
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.
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
- Assume the initial liquidity provider holds 100 LP tokens and the pool is in AMM phase.
- Over the first three weeks, burn 1 LP token each week.
- 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.