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
Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation
Security Insights

Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation

On April 1, 2026 (UTC), Drift Protocol on Solana suffered a $285.3M loss after an attacker exploited Solana's durable nonce mechanism to delay the execution of phished multisig approvals, ultimately transferring administrative control of the protocol's 2-of-5 Squads governance with zero timelock. With full admin privileges, the attacker created a malicious collateral market (CVT), inflated its oracle price, relaxed withdrawal protections, and drained USDC, JLP, SOL, cbBTC, and other assets through 31 rapid withdrawals in approximately 12 minutes. This incident highlights how durable nonce-based delayed execution can decouple signer intent from on-chain execution, bypassing the temporal assumptions that multisig security implicitly relies on.

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

Weekly Web3 Security Incident Roundup | Mar 23 – Mar 29, 2026

This BlockSec weekly security report covers eight DeFi attack incidents detected between March 23 and March 29, 2026, across Ethereum and BNB Chain, with total estimated losses of approximately $1.53M. Incidents include a $679K flawed burn mechanism exploit on the BCE token, a $512K spot-price manipulation attack on Cyrus Finance's PancakeSwap V3 liquidity withdrawal, a $133.5K flash-loan-driven referral reward manipulation on a TUR staking contract, and multiple integer overflow, reentrancy, and accounting error vulnerabilities in DeFi protocols. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Newsletter -  March 2026
Security Insights

Newsletter - March 2026

In March 2026, the DeFi ecosystem experienced three major security incidents. Resolv Protocol lost ~$80M due to compromised privileged infrastructure keys, BitcoinReserveOffering suffered ~$2.7M from a double-minting logic flaw, and Venus Protocol incurred ~$2.15M following a donation attack combined with market manipulation.

Best Security Auditor for Web3

Validate design, code, and business logic before launch. Aligned with the highest industry security standards.

BlockSec Audit