A major incident on the BNB Smart Chain has uncovered a sophisticated attack scheme targeting the LULA token, which was trading in the liquidity pool of the decentralized exchange PancakeSwap. The attacker managed to extract approximately $578,000 without hacking the exchange itself or gaining access to its keys. The root of the problem lies in a vulnerability in the token's own code.

At the core of the attack was the recycle() function implemented in the LULA token's smart contract. It granted the Rental contract two critical permissions: directly withdrawing LULA tokens from the PancakeSwap V2 pool and calling the sync() function, which synchronizes the pool's accounting reserves with the actual balances.

The liquidity pool mechanism can be visualized as a scale: on one side is USDT, on the other is LULA. The price is determined by the ratio of volumes. An ordinary trader can only exchange tokens through swaps. The recycle() function allowed removing LULA from one side, while sync() forced the scale to recognize the new, distorted position as fair.

Blockchain analysts from BlockSec Phalcon detailed the attacker's sequence of actions:

  • A large swap of USDT for LULA, which inflated the USDT reserve in the pair.
  • Multiple calls to recycle(), progressively reducing the LULA reserve.
  • A reverse swap of a small amount of LULA, which completely drained the pool's liquidity.

The essence of the maneuver: the fewer tokens remain on one side of the scale, the more expensive each becomes. By artificially compressing the volume of LULA in the pair, the attacker exchanged a small number of tokens at a fictitiously inflated rate.

12 days of preparation and a $237 million flash loan

The attack was not spontaneous. 12 days before the exploit, the hacker deployed auxiliary contracts to accumulate referral and team rewards. The claimReward() → recycle() chain allowed maximizing the deflationary effect — reducing the number of tokens in circulation.

For the main phase, a flash loan of approximately $237 million was used. A flash loan works like a credit taken for a few seconds on trust: the borrower must repay the amount within the same transaction, otherwise it is canceled. No own capital is required, making this tool often used to amplify price manipulation. The borrowed funds were used to withdraw LULA from the DEX pool, enhancing the effect of the recycle() calls.

Expert opinion: This incident is a classic example of a vulnerability related to improper permission management in smart contracts. The recycle() function effectively gave the Rental contract full control over the pool's reserves, which is unacceptable. Projects should thoroughly audit their code for such "privileged" functions, especially if they interact with liquidity pools. The use of flash loans in such schemes is already standard practice, and protection against it should be built into the contract logic.