Skip to content
Business logic Audit finding Intermediate

Users can lose value in emergency state

The emergency withdrawal function reverts because the WAVAX reserve was already used to provide liquidity, and users do not receive their LP tokens either, so they lose their entire deposit.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by static

Imagine the following sequence of events:

  • LaunchEvent.createPair() is called which sets wavaxReserve = 0, adds liquidity to the pair and receives lpSupply LP tokens.
  • LaunchEvent.allowEmergencyWithdraw() is called which enters emergency / paused mode and disallows normal withdrawals.
  • Users can only call LaunchEvent.emergencyWithdraw which reverts as the WAVAX reserve was already used to provide liquidity and cannot be paid out. Users don’t receive their LP tokens either. The users lost their entire deposit in this case.

Recommendation

Consider paying out LP tokens in emergencyWithdraw.

cryptofish7 (Trader Joe) confirmed and commented:

Fix: https://github.com/traderjoe-xyz/rocket-joe/pull/99


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

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 emergencyWithdraw function attempts to pay out WAVAX that is no longer available because it was used to provide liquidity, and it does not transfer the LP tokens instead.

Impact

Users could lose their entire deposit because emergencyWithdraw reverts and they do not receive their LP tokens.

What the attacker needed

CreatePair called; allowEmergencyWithdraw called; users attempt emergencyWithdraw

The fix

The fix was to pay out LP tokens in emergencyWithdraw, as confirmed by the project.

How it was found

  1. Call LaunchEvent.createPair() which sets wavaxReserve = 0, adds liquidity to the pair and receives lpSupply LP tokens.
  2. Call LaunchEvent.allowEmergencyWithdraw() to enter emergency/paused mode and disallow normal withdrawals.
  3. Users call LaunchEvent.emergencyWithdraw which reverts because the WAVAX reserve was used for liquidity and cannot be paid out; users do not receive their LP tokens.

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.

In a smart contract, users deposit funds and receive tokens representing their share. If the contract enters an emergency mode, users should be able to withdraw their original tokens. Here, the emergency withdrawal fails and users get nothing back, losing their deposit.

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 cmichel

View all

196 more disclosed reports, best first.

More from Trader Joe contest

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.