Back to Blog

神経橋セキュリティインシデントの分析

Code Auditing
November 18, 2021
4 min read

0x.1 前言

2021年11月15日,我们的内部监控系统在BSC上发现了可疑的闪电贷交易。 经过调查,我们发现这是针对Nerve Bridge的攻击,包括fUSDT和UST的MetaPool。

图1:攻击交易示例
图1:攻击交易示例

截至本报告撰写时,攻击者已耗尽Nerve质押池中fUSDT和UST的流动性,并获得了900 BNB的利润。

令人惊讶的是,我们发现易受攻击的代码是从Saddle.Finance分叉而来的,而Saddle.Finance的代码已导致Synapse Bridge在2021年11月6日遭受了8亿美元的损失。 具体而言,该漏洞的根本原因在于不同库中计算代币兑换金额的实现不一致。

然而,目前没有任何公开可用的报告来分析此次安全事件。 因此,在本博客中,我们旨在提供全面的分析,包括项目的机制、漏洞和攻击。

0x2. 背景

0x2.1 什么是MetaPool?

Curve提供了两种稳定币兑换池:标准StableSwap Pool和MetaPool。前者是完全的AMM,用于在不同的稳定币之间创建跨市场交易 [1]。它是最广泛使用的池类型,例如Curve.3pool,其中包含DAI、USDC和USDT。但是,此池无法隔离稳定币之间的风险,这可能导致LP提供者遭受巨大损失。

因此,提出了MetaPool来解决这个问题。 正如Curve [2]所述,“它允许单个币与另一个(基础)池中的所有币进行兑换,而不会稀释其流动性”。它本质上是稳定币与标准StableSwap Pool(包含其他几种稳定币)的LP代币之间的兑换池。在我们的上下文中,我们将这两种稳定币分别称为池稳定币底层稳定币

例如,本次事件的一个受害者就是fUSDT的MetaPool和Nerve.3pool的LP代币(包含BUSD、USD和USDC),该池的结构本质上是[fUSDT, LP代币(BUSD, USD, USDC)]。因此,fUSDT是池稳定币,而BUSD、USD和USDC是底层稳定币。

图2:Nerve.3pool
图2:Nerve.3pool

0x2.2 易受攻击代码的来源

Curve的MetaPool是用Vyper实现的。为了支持Solidity的开发,Saddle.Finance的开发团队用Solidity重写了代码。由于此漏洞的出现,它已被 Synapse 和 Nerve 分别分叉并采用。11月6日,Synapse遭到攻击。

图3:针对Synapse的攻击交易
图3:针对Synapse的攻击交易

MetaPool中约有820万美元的资金被提取,但由于攻击者“愚蠢”的错误,实际上没有资金损失 [3]

此后,Saddle.Finance采取了紧急行动,通过暂停所有MetaPool合约来保证资金安全。然而,Nerve Bridge并未采取任何行动,这不可避免地导致了此次安全事件。

相关合约地址如下:

  • MetaSwap: 0xd0fBF0A224563D5fFc8A57e4fdA6Ae080EbCf3D3
  • SwapUtils: 0x02338Ee742ddCDe44488640F4edf1Aa947E670E7

0x3. 漏洞分析

在MetaPool中,有两个重要函数:swapswapUnderlying。具体来说,前者用于兑换LP代币和池稳定币,后者用于兑换池稳定币和底层稳定币。

swap: _calculateSwap函数
swap: _calculateSwap函数
swapUnderlying: _calculateSwapUnderlying函数
swapUnderlying: _calculateSwapUnderlying函数

然而,这两个函数实现不一致。如上两图所示。红色矩形中的代码片段用于通过测量LP代币的“虚拟价格”来调整LP代币的价值(随着更多费用的产生,该价格从基线值1开始增加)。而swap函数忽略了虚拟价格的影响,这意味着LP代币的价值将被低估。换句话说,可以兑换出更多的LP代币。

结果是,可以通过首先用相应的LP代币提取底层稳定币的流动性,然后通过调用swapUnderlying函数来兑换池稳定币,从而可以获得更多的池稳定币。

0x4. 攻击分析

我们将以示例交易为例来说明攻击。

图6:攻击的五个步骤
图6:攻击的五个步骤

图6显示攻击者采取了以下五个步骤发起攻击:

  • 步骤1:从Fortube使用闪电贷借入50,000 BUSD。
  • 步骤2:用50,000 BUSD从Ellipsis兑换36,959 Nerve 3-LP,滑点相对较大。
  • 步骤3:调用MetaSwap的swap函数,将50,351 fUSDT兑换为36,959 Nerve 3-LP,滑点相对较大。
  • 步骤4:使用LP代币(在上一步中收到)调用Nerve.3pool的removeLiquidityOneCoin函数,提取BUSD流动性,即37,071 BUSD。
  • 步骤5:调用MetaSwap的swapUnderlying函数,用BUSD兑换fUSDT,并收到51,494 fUSDT。

攻击者重复执行上述五个步骤(约200多笔交易)耗尽了MetaPool的流动性,最终获利900 BNB。

有趣的是,攻击者仅仅采用了与Synapse事件相同的攻击方法,但这并不是一种最优的实现目标的方式。或者,可以通过更有效率的方式发起攻击,例如应用优化的参数在一次交易中耗尽流动性。结果表明,攻击者可能并未完全理解此漏洞的根本原因。

参考

[1] https://curve.fi/files/stableswap-paper.pdf

[2] https://resources.curve.fi/lp/depositing/depositing-into-a-metapool/

[3] https://synapseprotocol.medium.com/11-06-2021-post-mortem-of-synapse-metapool-exploit-3003b4df4ef4

致谢:Hailin Wang, Lei Wu, Yajin Zhou @BlockSec

Twitter: https://twitter.com/BlockSecTeam

Sign up for the latest updates
The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis
Security Insights

The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis

This BlockSec deep-dive analyzes the KelpDAO $290M rsETH cross-chain bridge exploit (April 18, 2026), attributed to the Lazarus Group, tracing a causal chain across three layers: how a single-point DVN dependency enabled the attack, how DeFi composability cascaded the damage through Aave V3 lending markets to freeze WETH liquidity exceeding $6.7B across Ethereum, Arbitrum, Base, Mantle, and Linea, and how the crisis forced decentralized governance to exercise centralized emergency powers. The article examines three parameters that shaped the cascade's severity (LTV, pool depth, and cross-chain deployment count) and provides an exclusive technical breakdown of Arbitrum Security Council's forced state transition, an atomic contract upgrade that moved 30,766 ETH without the holder's signature.

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026

This BlockSec weekly security report covers four attack incidents detected between April 13 and April 19, 2026, across multiple chains such as Ethereum, Unichain, Arbitrum, and NEAR, with total estimated losses of approximately $310M. The highlighted incident is the $290M KelpDAO rsETH bridge exploit, where an attacker poisoned the RPC infrastructure of the sole LayerZero DVN to fabricate a cross-chain message, triggering a cascading WETH freeze across five chains and an Arbitrum Security Council forced state transition that raises questions about the actual trust boundaries of decentralized systems. Other incidents include a $242K MMR proof forgery on Hyperbridge, a $1.5M signed integer abuse on Dango, and an $18.4M circular swap path exploit on Rhea Finance's Burrowland protocol.

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026

This BlockSec weekly security report covers four DeFi attack incidents detected between April 6 and April 12, 2026, across Linea, BNB Chain, Arbitrum, Optimism, Avalanche, and Base, with total estimated losses of approximately $928.6K. Notable incidents include a $517K approval-related exploit where a user mistakenly approved a permissionless SquidMulticall contract enabling arbitrary external calls, a $193K business logic flaw in the HB token's reward-settlement logic that allowed direct AMM reserve manipulation, a $165.6K exploit in Denaria's perpetual DEX caused by a rounding asymmetry compounded with an unsafe cast, and a $53K access control issue in XBITVault caused by an initialization-dependent check that failed open. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Best Security Auditor for Web3

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

BlockSec Audit