Back to Blog

现实中的操纵价格攻击(又来了):RariCapital事件

Code Auditing
May 9, 2021

5月8日, Peckshield 报告了 Rari Capital 的一起安全事件。经过仔细调查,我们发现这是一种我们论文中描述的价格操纵攻击(间接操纵)。该论文标题为:“DeFiRanger: Detecting Price Manipulation Attacks on DeFi Applications”。在论文中,我们专注于检测 DeFi 应用上的两种新型攻击,包括直接和间接价格操纵攻击。前者意味着攻击者通过攻击易受攻击的 DeFi 应用,在同一个去中心化交易所(DEX)中执行不受欢迎的交易,从而直接操纵代币价格。后者意味着攻击者间接操纵易受攻击的 DeFi 应用的代币价格。此次安全事件是间接价格操纵攻击的一个例子。

根本原因

我们分析了攻击的根本原因,发现不安全的价格依赖是原因所在。具体来说,Rari 的 LP 代币价格取决于 Rari 持有的 LP 代币 ibEth 的价值(以以太计)。不幸的是,ibEth LP 代币的价格可以通过调用 ibEth 的 work 函数来操纵。

攻击者持有的 Rari 代币价值 = Rari 中的以太储备 * Rari 代币数量 / Rari 代币总供应量

Rari 持有的 ibEth 代币价值 = ibEth 中的以太储备 * ibEth 代币数量 / ibEth 代币总供应量

Rari 中的以太储备受到 Rari 持有的 ibEth 代币价值的影响,而 ibEth 代币价值又通过增加 ibEth 中的以太储备(通过调用 work 函数)来被攻击者操纵。

使用我们的 DefiRanger 系统,我们可以轻松恢复图中显示的 DeFi 语义。在流动性挖矿(存入以太获取 LP 代币)和流动性取消(提取 LP 代币获取以太)中,LP 代币的数量(用红色圆圈标出)与相同的以太数量(用绿色背景标出)是不同的。

攻击过程

攻击过程如下:

  1. 攻击者调用 ibEth 的 work 函数。
  2. 该函数调用 SushiswapGoblin.work 函数,该函数进一步调用了攻击者控制的合约(0x2f755e8980f0c2e81681d82cccd1a4bd5b4d5d46)。
  1. 合约首先将 58903.4755276693 以太(从闪电贷借入)存入 Rari,并获得 Rari 的 LP 代币(146281892117489076580650)。
  2. 攻击者向 ibEth 存入 3818.9022134987213 以太。这是关键步骤,它将提高 ibEth LP 代币的价格(而不影响其总供应量)。这会进一步影响 Rari 的 LP 代币价格。这是因为 Rari 池中的总以太储备因其持有的 ibEth LP 代币价格上涨而增加。请注意,攻击者无法通过添加流动性来操纵 Rari 或 ibEth 的代币价格,因为这也会增加代币的总供应量。
  3. 攻击者提取以太。由于 Rari 代币的价格更高,攻击者可以使用更少的 Rari LP 代币(146196247321127203315331,而不是 146281892117489076580650)来获取相同数量的以太以归还闪电贷。
  1. 攻击者在 work 函数的最后获得归还的以太。

总结

总而言之,Rari Capital 面临的安全漏洞 starkly 提醒我们,DeFi 应用面临着复杂的威胁。通过巧妙的利用策略,攻击者执行了间接价格操纵攻击。此次事件揭示了智能合约中使用不安全价格依赖的关键漏洞。此次攻击凸显了 DeFi 项目迫切需要采用像 DeFiRanger 这样的强大检测系统,以防范威胁新兴 DeFi 生态系统完整性和安全性的直接和间接操纵策略。

关于 BlockSec

BlockSec 是一家开创性的区块链安全公司,于 2021 年由一群全球知名的安全专家创立。该公司致力于提高新兴 Web3 世界的安全性和可用性,以促进其大规模采用。为此,BlockSec 提供智能合约和 EVM 链安全审计服务,用于安全开发和主动阻止威胁的 Phalcon 平台,用于资金追踪和调查的 MetaSleuth 平台,以及用于 Web3 构建者在加密世界高效冲浪的 MetaDock 扩展。

迄今为止,公司已为 MetaMask、Uniswap Foundation、Compound、Forta 和 PancakeSwap 等 300 多家知名客户提供服务,并在两轮融资中从 Matrix Partners、Vitalbridge Capital 和 Fenbushi Capital 等杰出投资者那里获得了数千万美元的投资。

官方网站:https://blocksec.com/

官方 Twitter 账号:https://twitter.com/BlockSecTeam

Sign up for the latest updates
Tether Freezes $6.76M USDT Linked to Iran's IRGC & Houthi Forces: Why On-Chain Compliance is Now a Geopolitical Battlefield
Security Insights

Tether Freezes $6.76M USDT Linked to Iran's IRGC & Houthi Forces: Why On-Chain Compliance is Now a Geopolitical Battlefield

Looking ahead, targeted freezing events like this $6.76M USDT action will only become more common. On-chain data analysis is improving. Stablecoin issuers are also working closely with regulators. As a result, hidden illicit financial networks will be exposed.

Weekly Web3 Security Incident Roundup | Mar 2 – Mar 8, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 2 – Mar 8, 2026

During the week of March 2 to March 8, 2026, seven blockchain security incidents were reported with total losses of ~$3.25M. The incidents occurred across Base, BNB Chain, and Ethereum, exposing critical vulnerabilities in smart contract business logic, token deflationary mechanics, and asset price manipulation. The primary causes included a double-minting logic flaw during full token deposits that allowed an attacker to exponentially inflate their balances through repeated burn-and-mint cycles, a price manipulation vulnerability in an AMM-based lending market where artificially inflated vault shares created divergent price anchors to incorrectly force healthy positions into liquidation, and a flawed access control implementation relying on trivially spoofed contract interfaces that enabled attackers to bypass authorization to batch-mint and dump arbitrary tokens.

Weekly Web3 Security Incident Roundup | Feb 23 – Mar 1, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Feb 23 – Mar 1, 2026

During the week of February 23 to March 1, 2026, seven blockchain security incidents were reported with total losses of ~$13M. The incidents affected multiple protocols, exposing critical weaknesses in oracle design/configuration, cryptographic verification, and core business logic. The primary drivers included oracle manipulation/misconfiguration that led to the largest loss at YieldBloxDAO (~$10M), a crypto-proof verification flaw that enabled the FOOMCASH (~$2.26M) exploit, and additional token design and logic errors impacting Ploutos, LAXO, STO, HedgePay, and an unknown contract, underscoring the need for rigorous audits and continuous monitoring across all protocol layers.