A Costly Algorithmic Flaw: DeFi Stablecoin Project Loses 70 ETH

On August 10, a security alert from blockchain security firm SlowMist shed light on an exploit targeting a decentralized stablecoin protocol. The attacker drained approximately 70.83 ETH by exploiting a subtle mathematical flaw in the protocol's core contract logic. This was not a typical hack but a calculated exploitation of a design weakness in the protocol's economic model.

The Root Cause: A "Mathematical Trap" in Redemption Pricing

The vulnerability was rooted in the pricing logic within the ethFromDefund() function, part of the protocol's defund() redemption mechanism.

This function determined how much ETH a user should receive when redeeming FUM (the protocol's governance token). It used a blended price: the arithmetic average of the current FUM sell price and an estimated final sell price. While perhaps intended to mitigate volatility, this design fatally overlooked a crucial property: split invariance.

The Attack Vector: The "Art" of Fractional Redemption

The lack of split invariance, combined with a state shrinkage factor and integer rounding mechanism in the contract, created an exploitable opportunity.

  • Single Large Redemption: A user redeeming a large amount of FUM in one transaction would receive a proportionate amount of ETH based on the flawed calculation.
  • Multiple Split Redemptions: If the same total amount of FUM was split into many small transactions—64 or more—each transaction independently triggered the faulty pricing and rounding logic.

Each small redemption could yield a slightly inflated amount of ETH due to rounding and the shrinkage factor. In aggregate, the total ETH extracted through dozens of small transactions significantly exceeded the amount receivable from a single bulk redemption. This difference became the attacker's profit.

Lessons Learned: Security Beyond Code Vulnerabilities

This incident underscores a critical lesson for the DeFi space. Security audits must look beyond classic vulnerabilities like reentrancy or overflows.

The mathematical soundness of economic models is as vital as code security. Any algorithm handling asset pricing, exchange ratios, and state calculations must be rigorously validated mathematically. Properties like split invariance are fundamental for financial contracts and must be proven.

For users, it's a reminder of the inherent risks in nascent DeFi protocols, especially those involving complex financial engineering. Protocols require thorough, multi-layered audits from independent teams that examine both code and underlying mathematical models before launch.