Cointime

Download App
iOS & Android

Cracking the Code: Delving into the Elaborate Scheme Behind BabyDogecoin's Flash Loan Attack"

Validated Project

In a recent incident, the popular Binance Smart Chain (BSC) token, @babydogecoin, fell victim to a flash loan attack, resulting in a loss of approximately $157,000. The attack exploited a vulnerability of misconfiguration of the BabyDoge contract to allow the FarmZAP contract excluded from the fee-charging mechanism, which allowed the attacker to manipulate the price of $BabyDoge on the PancakeSwap pair and dump BabyDoge tokens of the BabyDoge contract at a lower price.The attack transaction, available at https://bscscan.com/tx/0x098e7394a1733320e0887f0de22b18f5c71ee18d48a0f6d30c76890fb5c85375, provides insights into the steps taken by the attacker.

Here are the key details of the incident.

Token:

  • Token under attack: BabyDoge
  • Contract address: https://bscscan.com/address/0xc748673057861a797275CD8A068AbB95A902e8de#readContract

Attacker:

https://bscscan.com/address/0xcbc0d0c1049eb011d7c7cfc4ff556d281f0afebb

Attacking Contract:

https://bscscan.com/address/0x51873a0b615a51115f2cfbc2e24d9db4bfa2e6e2

Attacked Contract:

BabyDoge https://bscscan.com/address/0xc748673057861a797275CD8A068AbB95A902e8de

TreatSwap pair https://bscscan.com/address/0x0536c8b0c3685b6e3c62a7b5c4e8b83f938f12d1

Pairs Involved:

Attacking Steps:

  1. The attacker acquired 80,000 BNB through a flash loan from Radiant: Lending Pool.
  2. Using the FarmZAP contract, the attacker called the buyTokensAndDepositOnBehalf function to exchange 80,000 BNB for a staggering 3,529,864,186,667,202 $BabyDoge from the TreatSwap pair.
  1. The attacker further swapped 3,525,976,210,595,834 $BabyDoge for 13,208 BNB on the PancakeSwap pair and decreased the price of $BabyDoge.
  2. By triggering the swapAndLiquify action on the PancakeSwap pair and dumping $BabyDoge of the BabyDoge contract at a lower price, the attacker initiated a series of transactions.
  3. Next, the attacker swapped 13,208 BNB for 3,607,312,208,477,806 $BabyDoge on the PancakeSwap pair.
  4. In a subsequent step, the attacker exchanged 3,607,312,208,477,806 $BabyDoge for 80,509 BNB on the TreatSwap pair.
  5. Finally, the attacker repaid 80,072 BNB to the Radiant: Lending Pool, securing a profit of 437 BNB.

5 hours later of the exploit, the project owner included the FarmZAP contract in the fee-charging mechanism.

Here is the transaction https://bscscan.com/tx/0x0c7fa7a334a31c60d9e7f7fd58063aef8cc78680f8e506c4bf4f4761aafe89f2.

Root Cause

The root cause of this attack serves as a crucial lesson for the entire DeFi community. It highlights the significance of implementing comprehensive security measures and conducting thorough audits of smart contracts. In this case, the exclusion of the FarmZAP contract from the fee-charging mechanism created an exploitable vulnerability that allowed the attacker to manipulate the price of $BabyDoge on the PancakeSwap pair.

To prevent similar incidents in the future, projects should prioritize the implementation of robust security practices. This includes conducting regular audits by reputable third-party firms to identify and address potential vulnerabilities. Moreover, projects should establish mechanisms for ongoing monitoring and surveillance of token pairs on decentralized exchanges to promptly detect any suspicious or manipulative activities.

Furthermore, decentralized exchanges play a vital role in maintaining the integrity of the DeFi ecosystem. They should enhance their monitoring capabilities and implement safeguards to identify and prevent price manipulation attempts. This may involve utilizing advanced algorithms and data analysis techniques to detect abnormal trading patterns or sudden price fluctuations that could indicate fraudulent activities.

Additionally, it is crucial for the community to foster a culture of information sharing and collaboration. By sharing knowledge and experiences related to security vulnerabilities and attacks, the community can collectively learn and strengthen the defenses against potential threats. Projects and participants should actively engage in open dialogue, knowledge sharing, and the adoption of best practices to ensure the overall security and resilience of the DeFi ecosystem.

Overall, the attack on BabyDoge highlights the ongoing need for constant vigilance, robust security measures, and collaboration within the DeFi community. By learning from such incidents, the industry can continue to evolve and develop innovative solutions that uphold the principles of transparency, security, and trust in the decentralized financial landscape.

Follow Us

Twitter: @MetaTrustLabs

Website: metatrust.io

Comments

All Comments

Recommended for you

  • BTC breaks through $92,000

     the market shows BTC breaking through $92,000, currently at $92,023.91, with a 24-hour decline of 0.13%. The market is highly volatile, please manage your risk accordingly.

  • WLFI launches lending marketplace powered by Dolomite

     WLFI launches a lending market supported by Dolomite.

  • Spot gold rose more than $300 in January.

     spot gold has risen above $4620/oz, with a daily increase of 2.44%, accumulating a rise of over $300 in the first month of the new year.

  • Hassett: Still interested in a Fed position

    White House National Economic Council Director Hassett: Still interested in the Federal Reserve position. It is unknown whether U.S. President Trump has approved an investigation into the Federal Reserve. Federal Reserve Chairman Powell is a good person.

  • BTC falls below $91,000

     the market shows BTC fell below $91,000, currently at $90,997.44, with a 24-hour increase of 0.26%. The market is highly volatile, please manage your risks accordingly.

  • The US spot Ethereum ETF saw a net outflow of $68.57 million last week.

    according to SoSoValue data, during the trading days last week (January 5 to January 9, Eastern US time), the US spot Ethereum ETF had a net outflow of 68.57 million USD.

  • BTC breaks through $92,000

    the market shows BTC breaking through $92,000, currently at $92,041.92, with a 24-hour increase of 1.49%. The market is volatile, please manage your risk accordingly.

  • Japanese Prime Minister considers dissolving the House of Representatives; USD/JPY rises sharply.

    Japanese Prime Minister is considering dissolving the House of Representatives. The USD/JPY exchange rate quickly rose by 0.66% to 157.95, hitting a new one-year high. 

  • a16z announced the completion of a $15 billion funding round, which will focus on investments in AI and crypto.

    a16z has just completed raising over $15 billion in funds. This batch of funds includes: American Dynamism Fund ($1.176 billion), Apps Fund ($1.7 billion), Bio + Health Fund ($700 million), Infrastructure Fund ($1.7 billion), Growth Fund ($6.75 billion), and other venture capital strategy funds ($3 billion). The announcement states that its mission is to ensure the United States wins the technology competition in the next 100 years, focusing on winning key infrastructures such as AI and crypto. In addition, it will promote the application of related technologies in fields such as biology, health, defense, public safety, education, and entertainment.

  • BTC falls below $90,000

     market shows BTC fell below 90,000 USD, currently at 89,996.08 USD, 24-hour decline reached 0.43%, market volatility is high, please manage risk properly.