Cellframe Network suffered a flash loan attack, resulting in a loss of $76,000.

Analysis of the Flash Loan Attack Incident on Cellframe Network

On June 1, 2023, at 10:07:55 (UTC+8), Cellframe Network was hacked on a certain smart chain due to a token quantity calculation issue during the liquidity migration process. This attack resulted in the hacker profiting approximately $76,112.

Web3 Security | Analysis of Cellframe Network's Attack Incident Due to Flash Loans Manipulating Pool Ratios

Root Cause of the Attack

The calculation issues during the liquidity migration process are the main reason for this attack.

Detailed Explanation of the Attack Process

  1. The attacker first obtains 1,000 native tokens of a certain chain and 500,000 New Cell tokens through Flash Loans. Then, they exchange all New Cell tokens for native tokens, causing the amount of native tokens in the liquidity pool to approach zero. Finally, the attacker exchanges 900 native tokens for Old Cell tokens.

  2. It is worth noting that the attacker added liquidity for Old Cell and native tokens in advance before launching the attack, obtaining Old lp tokens.

Web3 Security | Cellframe Network Attacked Due to Flash Loan Manipulation of Pool Ratios Event Analysis

  1. Next, the attacker invoked the liquidity migration function. At this point, there were almost no native tokens in the new pool, and almost no Old Cell tokens in the old pool. The migration process includes the following steps:

    • Remove old liquidity and return the corresponding amount of tokens to the user
    • Add new liquidity according to the new pool's ratio

    Due to the almost non-existent Old Cell tokens in the old pool, the number of native tokens obtained when removing liquidity increases, while the number of Old Cell tokens decreases. This leads to users only needing to add a small amount of native tokens and New Cell tokens to acquire liquidity, while the excess native tokens and Old Cell tokens are returned to the users.

Web3 Security | Cellframe Network Analysis of Attack Incident Due to Flash Loans Manipulating Pool Ratios

  1. Finally, the attacker removes the liquidity from the new pool and exchanges the Old Cell tokens returned from the migration for native tokens. At this point, there are a large number of Old Cell tokens in the old pool but almost no native tokens, so the attacker exchanges the Old Cell tokens back into native tokens, thus completing the profit. Subsequently, the attacker repeats the migration operation.

Web3 Security | Cellframe Network Analysis of Attack Events Due to Flash Loan Manipulation of Pool Ratios

Security Recommendations

  1. When migrating liquidity, it is important to comprehensively consider the changes in the quantities of the two tokens in the old and new pools as well as the current token prices. Relying solely on the quantities of the two tokens in the trading pair for calculations can be easily manipulated.

  2. Before deploying the code, it is essential to conduct a comprehensive and thorough security audit to identify and fix potential vulnerabilities.

Web3 Security | Cellframe Network Attacked Due to Flash Loans Manipulating Pool Ratios Event Analysis

This incident once again highlights the importance of security and code quality in the decentralized finance (DeFi) space. Project teams need to remain vigilant, improve security measures, and protect user assets while maintaining the healthy development of the ecosystem.

Web3 Security | Cellframe Network Attacked Due to Flash Loans Manipulating Pool Ratios Event Analysis

View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • 10
  • Share
Comment
0/400
BTCBeliefStationvip
· 7h ago
This profit is too meager.
View OriginalReply0
BlockDetectivevip
· 12h ago
Another old trap attack method.
View OriginalReply0
New_Ser_Ngmivip
· 19h ago
Clip Coupons is such a hassle.
View OriginalReply0
LightningAllInHerovip
· 07-12 15:40
Still haven't learned to behave, huh?
View OriginalReply0
Yogawvip
· 07-10 22:45
still very small with such losses!
View OriginalReply0
GateUser-a180694bvip
· 07-10 20:22
Another Algorithm vulnerability
View OriginalReply0
MeaninglessApevip
· 07-10 20:18
Another sucker that has been played for.
View OriginalReply0
MEVictimvip
· 07-10 20:11
Another flash loan attack
View OriginalReply0
MetaverseLandlordvip
· 07-10 20:03
Another code vulnerability
View OriginalReply0
JustHereForAirdropsvip
· 07-10 19:57
The loss isn't that big, right?
View OriginalReply0
View More
Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate app
Community
English
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)