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

robot
Abstract generation in progress

Cellframe Network Suffers Flash Loan Attack Analysis

On June 1, 2023, at 10:07:55 (UTC+8), Cellframe Network was hacked on the Binance Smart Chain due to a token calculation issue during the liquidity migration process. The attack resulted in a profit of approximately $76,112 for the hacker.

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

Attack Details

The attacker first obtained 1000 BNB and 500,000 New Cell tokens through Flash Loans. Then, they exchanged all New Cell tokens for BNB, causing the amount of BNB in the pool to approach zero. Finally, the attacker exchanged 900 BNB for Old Cell tokens.

It is worth noting that the attacker added liquidity for Old Cell and BNB before carrying out the attack, obtaining the Old lp.

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

Attack Process

  1. The attacker calls the liquidity migration function. At this time, there is almost no BNB in the new pool, and there are almost no Old Cell tokens in the old pool.

  2. The migration process includes: removing old liquidity and returning the corresponding amount of tokens to users; adding new liquidity according to the ratio of the new pool.

  3. Due to the almost non-existent Old Cell tokens in the old pool, the amount of BNB obtained when removing liquidity increases, while the number of Old Cell tokens decreases.

  4. Users only need to add a small amount of BNB and New Cell tokens to obtain liquidity, and any excess BNB and Old Cell tokens will be returned to the user.

  5. The attacker removes the liquidity from the new pool and exchanges the Old Cell tokens returned from the migration for BNB.

  6. At this time, there are a large number of Old Cell tokens in the old pool but no BNB. The attacker will exchange the Old Cell tokens back into BNB to complete the profit.

  7. The attacker repeatedly performs the migration operation.

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

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

Vulnerability Root

The calculation of token quantities during the liquidity migration process has issues, allowing attackers to profit by manipulating the pool ratios.

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

Security Recommendations

  1. When migrating liquidity, one should fully consider the changes in the quantities of both tokens in the old and new pools, as well as the current token prices.

  2. Avoid directly using the quantities of the two currencies in the trading pair for calculations, as this can be easily manipulated.

  3. Conduct a comprehensive security audit before deploying the code to prevent potential vulnerabilities.

This event highlights once again the importance of considering various situations comprehensively when designing and implementing complex financial operations, especially when it involves sensitive operations such as liquidity migration. At the same time, it also reminds us that the importance of security audits in the blockchain ecosystem should not be overlooked.

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

CELL16.01%
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
  • 6
  • Share
Comment
0/400
GasFeeCriervip
· 21h ago
Another project has had an accident, it's so scary.
View OriginalReply0
WhaleMistakervip
· 21h ago
Another project has become a target for attacks, sigh.
View OriginalReply0
LiquidationWatchervip
· 21h ago
Another one has crashed, let's see who will be next.
View OriginalReply0
LiquiditySurfervip
· 21h ago
It's just market making while riding the waves. This scene is too common~
View OriginalReply0
DAOdreamervip
· 21h ago
Ha, the freebie god is back again.
View OriginalReply0
MimiShrimpChipsvip
· 22h ago
News mast new
Reply0
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)