LP Tokens May Be Locked in Contract Due to allowEmergencyWithdraw() in Stage 3
The allowEmergencyWithdraw() function can be called by the owner at any time, and if called during Stage 3 after a pair is created, it sets stopped to true, causing withdrawal functions to revert and locking LP tokens. As a result, depositors and issuers cannot withdraw their LP tokens or incentives.
Originally disclosed on Code4rena
Submitted by kirk-baird
The function allowEmergencyWithdraw() may be called by the rocketJoeFactory.owner() at any time. If it is called while the protocol is in Stage 3 and a pair has been created then the LP tokens will be locked and both issues and depositors will be unable to withdraw.
Proof of Concept
If allowEmergencyWithdraw() is called stopped is set to true. As a result functions withdrawIncentives() and withdrawLiquidity() will revert due to the isStopped(false) modifier reverting.
Additionally, emergencyWithdraw() will revert since all the WAVAX and token balances have been transferred to the liquidity pool.
Thus, depositors and issuers will have no methods of removing their LP tokens or incentives.
Recommended Mitigation Steps
Consider adding the requirement require(address(pair) != address(0), "LaunchEvent: pair not created"); to the function allowEmergencyWithdraw().
cryptofish7 (Trader Joe) confirmed and commented:
To fix, we allow withdrawal of LP in
emergencyWithdraw(): https://github.com/traderjoe-xyz/rocket-joe/commit/8a93c43e9972a2cf7c8ee04ccf263a405ecfcecc
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
Impact
Depositors and issuers could be unable to withdraw their LP tokens or incentives, resulting in locked funds.
What the attacker needed
Owner calls allowEmergencyWithdraw(); Protocol is in Stage 3; A pair has been created
The fix
The fix was to allow withdrawal of LP tokens in emergencyWithdraw().
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.
This is a smart contract bug where a privileged function can be called at the wrong time, making it impossible for users to take back their deposited tokens. The function stops withdrawals, and because the tokens have already been moved into a liquidity pool, there is no other way to retrieve them.
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.