Back to Blog

#8:SushiSwap事件:笨拙的救援导致一系列模仿攻击

Code Auditing
February 18, 2024
5 min read

2023年4月9日,SushiSwap因未经验证的外部参数成为攻击目标,总损失约330万美元。

作为以太坊上拥有庞大用户群的领先协议,此类顶级协议在合同升级过程中仍然容易引入严重的全新问题。这提醒DeFi社区,安全应始终是重中之重。 此外,此次安全事件是由一位白帽安全研究员试图进行救援而触发的,在社区内引发了广泛的辩论,本文将对此事件进行简要介绍,并将其列为2023年十大安全事件之一。

背景

SushiSwap

SushiSwap,一个著名的DEX,曾对Uniswap发动了一次吸血鬼攻击,并取得了巨大的成功。在其巅峰时期,其TVL达到了80亿美元,目前仍保持在4亿美元左右。

授权

简而言之:允许某个合约访问并转出您钱包中的特定代币的权限

为了方便起见,许多合约默认会请求无限授权。许多用户担心安全风险,只将少量资金存入各种协议。然而,这些用户却授予了协议无限额的资金授权。如果协议遭到泄露,账户中所有已授权的代币都可能丢失。

漏洞

未经验证的外部参数

RouteProcessor2合约的processRoute()函数允许用户完全控制调用流程(参数route)。 而在uniswapV3SwapCallback()中,safeTransferFrom()from参数是从用户提供的route中解码出来的。 结果,授权了RouteProcessor2合约的用户损失了他们的资产。

攻击过程

此事件涉及多个攻击交易,但我们将以第一个攻击交易为例。 交易:0x43ff7e01423044cfb501b4fe9ef1386725c0ddc117dadd6e6620cb68bdeaf4f9

  1. 攻击者通过精心构造的长参数route调用了易受攻击的RouteProcessor2合约的processRoute()
  2. processRouteInternal()根据用户提供的route创建一个InputStream
  3. 交易沿着攻击者的route执行,直到到达swapUniV3()。请注意,pool是从stream中解码出来的,这意味着攻击者控制了要在哪个pool中进行swap(),并将其设置为lastCalledPool
  4. 这调用了攻击者部署的恶意合约,然后攻击者只需传递恶意calldata以回调RouteProcessor2的uniswapV3SwapCallback()
  5. uniswapV3SwapCallback()需要msg.sender检查,但由于lastCalledPool已经被设置为恶意合约,攻击者绕过了检查。重要的是,safeTransferFrom()from参数是从攻击者构造的calldata中解码出来的。
  6. 受害者的资产被转移到攻击者部署的恶意合约中。

备受争议的白帽救援

值得一提的是,一位名为@trust__90的白帽安全研究员发现了这个问题,并试图进行资金救援,但这次救援尝试却造成了一场灾难。

  • 使用内存池(mempool)广播交易,而不是私有RPC。
  • 试图只救援100个以太坊,而不是所有面临风险的资金。

这为MEV机器人和其他攻击者执行多个模仿交易打开了方便之门,导致大部分资金被耗尽。在这些事件发生后,@trust__90面临了批评,并试图为其行为辩护

BlockSec救援

在此次攻击中,我们还救援了100个以太坊,并将资金返还给了受害者0xsifu。

迄今为止,我们已成功挫败了20多起真实黑客攻击,并挽救了价值超过1400万美元的资产。

安全建议

升级应始终经过审计

这提醒DeFi社区,安全应始终是重中之重。审计并非安全的保证,但缺乏审计也绝不能保证安全。

针对授权问题的缓解措施

2023年发生了多起与授权攻击相关的事件,我们借此机会重申管理授权的重要性。 一种安全实践是仅批准必要的金额,或者如果优先考虑便利性,则批准比所需金额稍大的金额。

BlockSec的MetaSuites提供了便捷的授权诊断功能。此外,像Revoke Cash这样的工具可以用来定期检查授权状态。

采用监控和自动响应机制

以太坊是一片黑暗森林,DeFi社区中的每个人都面临着各种风险和挑战,即使是安全专家。 2023年,我们推出了Phalcon Security,这是业内首个自动响应系统,不仅用于监控攻击,还用于实时主动阻止威胁。Phalcon经过实战检验的能力已被证明是有效的,成功挫败了20多起真实黑客攻击,并挽救了超过1400万美元的资产。这项创新确保所有利益相关者都能更安心地入睡,因为有主动措施来保护他们的投资。

阅读本系列的更多文章:

Sign up for the latest updates
~$15.9M Lost: Trusted Volumes & More | BlockSec Weekly
Security Insights

~$15.9M Lost: Trusted Volumes & More | BlockSec Weekly

This BlockSec bi-weekly security report covers 11 notable attack incidents identified between April 27 and May 10, 2026, across Sui, Ethereum, BNB Chain, Base, Blast, and Berachain, with total estimated losses of approximately $15.9M. Three incidents are analyzed in detail: the highlighted $1.14M Aftermath Finance exploit on Sui, where a signed/unsigned semantic mismatch in the builder-fee validation allowed an attacker to inject a negative fee that was converted into positive collateral during settlement; the $5.87M Trusted Volumes RFQ authorization mismatch on Ethereum; and the $5.7M Wasabi Protocol infrastructure-to-contract-control compromise across multiple EVM chains.

Newsletter - April 2026
Security Insights

Newsletter - April 2026

In April 2026, the DeFi ecosystem experienced three major security incidents. KelpDAO lost ~$290M due to an insecure 1-of-1 DVN bridge configuration exploited via RPC infrastructure compromise, Drift Protocol suffered ~$285M from a multisig governance takeover leveraging Solana's durable nonce mechanism, and Rhea Finance incurred ~$18.4M following a business logic flaw in its margin-trading module that allowed circular swap path manipulatio

~$7.04M Lost: GiddyDefi, Volo Vault & More | BlockSec Weekly
Security Insights

~$7.04M Lost: GiddyDefi, Volo Vault & More | BlockSec Weekly

This BlockSec weekly security report covers eight attack incidents detected between April 20 and April 26, 2026, across Ethereum, Avalanche, Sui, Base, HyperLiquid, and MegaETH, with total estimated losses of approximately $7.04M. The highlighted incident is the $1.3M GiddyDefi exploit, where the attacker did not break any cryptography or use a flash loan but simply replayed an existing on-chain EIP-712 signature with the unsigned `aggregator` and `fromToken` fields swapped out for a malicious contract, demonstrating how partial signature coverage turns any historical signature into a generic permit. Other incidents include a $3.5M Volo Vault operator key compromise on Sui, a $1.5M Purrlend privileged-role takeover, a $413K SingularityFinance oracle misconfiguration, a $142.7K Scallop cross-pool index injection, a $72.35K Kipseli Router decimal mismatch, a $50.7K REVLoans (Juicebox) accounting pollution, and a $64K Custom Rebalancer arbitrary-call exploit.

Best Security Auditor for Web3

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

BlockSec Audit