Yearn Finance, a popular decentralized finance (DeFi) platform on the Ethereum network, recently fell victim to a significant vulnerability in its yETH pool. This flaw allowed an attacker to drain approximately $9 million in assets from the pool, as reported by Check Point Research (CPR).
The exploit was a result of a critical oversight in the internal accounting of the yETH pool. The attacker was able to mint an astronomical amount of yETH tokens, totaling 235 septillion, by depositing a mere 16 wei, equivalent to a negligible value of $0.000000000000000045 at the time of the attack.
The researchers at CPR identified that the flaw in the pool’s cached storage system was the root cause of the breach. The yETH pool utilizes virtual balances called packed_vbs[] to optimize gas costs during transactions. However, a desynchronization issue occurred when all liquidity was removed from the pool, causing the main supply counter to reset to zero while the cached values remained inflated.
Taking advantage of this discrepancy, the attacker executed a complex exploit by cycling deposit and withdrawal transactions through flash loans. By leaving behind residual virtual balances after each transaction, the attacker was able to manipulate the protocol into minting tokens based on the inflated cached values rather than the actual input.
The breach unfolded in six distinct phases, starting with borrowing assets through flash loans and culminating in converting the stolen assets into ETH and laundering the funds through Tornado Cash. The attacker managed to exchange the stolen assets for ETH via decentralized exchanges (DEXs) before obfuscating the transaction trail through a privacy-focused tool like Tornado Cash.
CPR emphasized the importance of handling all state transitions explicitly in complex systems like AMMs to prevent such exploits. They suggested that transaction simulation, sequence-level monitoring, and automated blocking of abnormal minting behavior could have prevented the breach.
The incident serves as a stark reminder of the risks associated with complex DeFi protocols and underscores the need for robust security measures in place to safeguard user funds. By learning from this exploit, DeFi platforms can strengthen their defenses against similar attacks in the future.
