What Went Wrong in BYC Token’s $100K Hack?

Updated at: January 5, 20255 Mins Read

Author:QuillAudits Team

Overview

On Dec-03, 2024, BYC token got exploited due to a vulnerability in the “autoBurnLiquidity” function. The hacker manipulated the “lpBurnFrequency” parameter by exchanging a large amount of USDT for BYC and transferring all BYC to the PancakeSwap pair, which inflated the parameter's value. By calling "autoBurnLiquidity," the attacker reduced the BYC reserve to 1, enabling him to drain all USDT from the liquidity pool, resulting in a $100k loss.

Exploit Details

image.png

Attack Process

  1. The autoBurnLiquidity function in the BYC contract is designed to burn tokens by transferring them from the PancakeSwap liquidity pool to the DEAD address.

    image.png
  2. The function is triggered when the balance of the pancake pair exceeds a threshold defined by the lpBurnFrequency variable.
  3. The value of lpBurnFrequency increases when tokens are transferred to the pancake pair (for example, during exchanges of BYC for USDT).

    image.png
  4. The attacker identified that by transferring a large amount of BYC tokens to the pancake pair, he could artificially increase the lpBurnFrequency threshold.
  5. Once this threshold was manipulated, the attacker exploited the functionality of autoBurnLiquidity to drain the liquidity pool.

    image.png
  6. After the autoBurnLiquidity function execution, the BYC reserve in the liquidity pool was reduced to just 1 BYC.
  7. The extreme imbalance in the reserves of BYC and USDT caused the price of USDT relative to BYC to drop dramatically.
  8. With the BYC reserve effectively drained, the attacker was able to extract almost all the USDT from the liquidity pool.
  9. This resulted in a total loss of approximately $100,000 worth of USDT.

The Root Cause

The root cause of the exploit lies in the autoBurnLiquidity function's reliance on the lpBurnFrequency parameter, which was manipulatable through token transfers to the liquidity pool. The function failed to impose limits or validation checks on how lpBurnFrequency could be increased, allowing the attacker to inflate it artificially. Once inflated, the function burned a disproportionate amount of BYC tokens from the pool, creating an imbalance in the reserves.

Flow of Funds

See the funds flow here:

image.png

How could they have prevented the Exploit?

  1. Adding logic to ensure that autoBurnLiquidity only executes when specific, well-defined conditions are met, such as requiring a minimum balance or specific time intervals between burns.
  2. Introduce strict rate limits or maximum bounds for how much lpBurnFrequency can increase to prevent malicious inflation.
  3. Collaborate with reputable auditors like QuillAudits to analyse smart contracts and identify vulnerabilities.

Why QuillAudits?

Choosing a reputable audit firm like QuillAudits ensures that your protocol undergoes rigorous scrutiny from experienced security professionals. QuillAudits specializes in uncovering critical vulnerabilities and providing actionable remediation strategies. Our expertise helps safeguard your project from attacks, ensuring that security issues are addressed proactively.

image.png
QuillAudits Team

QuillAudits Team

The QuillAudits team, comprises of expert security researchers & auditors in Web3 security, has completed 1,000+ audits across Ethereum, Polygon, Solana, Arbitrum, BSC, and more, securing $30B+ with 0 exploits, advancing the blockchain ecosystem.

TwitterLinkedInTelegram

Get an audit done today for your
Smart Contract

Join 1000+ leaders who secured themselves from losing Billion Dollars.

Request An Audit

Subscribe to our Newsletter

Get Pure Alpha Straight to Your Inbox. Miss this, and you’re missing out. Insider Secrets - Delivered Right to You. Subscribe now.

Telegram