1inch technology analysis of top DeFi protocol Balancer's deflationary token pool attack details

share
1inch technology analysis of top DeFi protocol Balancer

The popular decentralized finance (DeFi) project Balancer officially disclosed the principles behind the $500,000 loss due to a deflationary token attack. The on-chain aggregator platform 1inch further analyzed more technical details of the Balancer attack incident.

Table of Contents

Original Title: "STA Deflationary Token Balancer Pool Attack Event"
Written by: 1inch, an on-chain aggregation trading platform
Translated by: Lu Jiangfei

On June 29th, at least two multi-token pools on the decentralized exchange Balancer Protocol suffered losses of over $500,000 due to vulnerabilities in an environment of automated market makers (AMM) and deflationary token models. The hacker exploited flash loans to execute multiple STA token exchange transactions, ultimately depleting the STA balance in the Balancer pool.

The Balancer pool is a multi-dimensional automated market maker similar to Uniswap, containing various assets, allowing users to exchange any assets by creating arbitrage opportunities and forming prices based on specific formulas, thus maintaining a certain balance of various tokens.

The attacker sent a complex transaction to the Ethereum mainnet, targeting one Balancer pool. Minutes later, a second attack occurred, targeting another Balancer pool. We have analyzed the situation of this attack, and the report is as follows.

The attacker utilized smart contracts to execute multiple actions automatically in a single transaction, mainly divided into three steps:

First, the attacker obtained a flash loan of 104,000 WETH from dYdX, which was used to execute 24 rounds of WETH to STA token exchanges, depleting the STA balance in the Balancer pool after multiple exchanges, leaving only 1 weiSTA (0.000000000000000001 STA) in the end.

The reason for this phenomenon may be due to the Balancer pool contract continuously tracking token balances in the contract, while the STA token adopts a deflationary model, where each transaction charges the receiver a 1% transfer fee, causing improper behaviors in the internal functions transfer() and transferFrom(). Therefore, whenever the attacker exchanges WETH for STA tokens, the Balancer pool receives less STA tokens than expected by 1%.

Next, the attacker began repeatedly exchanging weiSTA tokens for WETH. Due to the existence of STA token transfer fees, the Balancer pool actually cannot receive STA tokens when the balance is insufficient, but at the same time, they release WETH. If the attacker continues to execute this operation repeatedly, it will deplete the balances of WBTC, SNX, and LINK tokens in the Balancer pool.

Finally, the attacker repaid the 104,000 WETH borrowed through flash loans from dYdX, and then quickly increased their share in the Balancer pool by depositing some weiSTA tokens. Subsequently, they exchanged the acquired Balancer pool tokens for 136,000 STA tokens through Uniswap V2, and then exchanged these tokens for 109 WETH. All stolen funds have now been transferred to the address: 0xbf675c80540111a310b06e1482f9127ef4e7469a.

The mastermind behind this attack is likely a very experienced smart contract engineer with a deep understanding and awareness of top DeFi protocols. This attack was evidently organized and well-prepared in advance. Additionally, the attacker used Tornado Cash to obtain initial funds, which can conceal the source of exchanged Ether, allowing these funds to be used for deploying smart contracts or executing attacks.

This article is authorized for reposting by ChainNews, the original source of this article: ChainNews (ID: chainnewscom)