Back to Blog

通过主动威胁预防保障 Web3 安全

January 28, 2023
5 min read

引言

在过去三年中,我们观察到了 DeFi 生态系统中发生的数起安全事件。为了应对这些威胁,社区普遍采用了以代码为中心的方法,例如静态代码审计、智能合约扫描工具或动态模糊测试。尽管这些方法已经显示出有效性,但我们认为仅凭以代码为中心的方法无法完全解决安全问题并保护用户资产。例如,存在多个案例表明,易受攻击的合约已由多家信誉良好的代码审计公司进行审计

我们相信,除了现有的以代码为中心的方法之外,还应存在更主动的威胁防护解决方案来抵御威胁。我们在 2021 年底内部探讨了这一想法,并于 2022 年初开发了一个名为 IronDome 的系统。自那时以来,我们已在 BlockSec 内部部署了该系统。在 2022 年,IronDome 成功阻止了多次攻击,挽救了超过 500 万美元的用户资产,其中包括 2022 年 4 月阻止 Saddle Finance 被利用的事件,挽救了 380 万美元。

在本博客中,我们将详细阐述 IronDome 的系统架构及其成功案例。我们还将讨论我们系统的局限性以及对未来威胁防护方向的见解。

高层系统架构

IronDome 的基本理念是监听以太坊的待处理交易池,通过我们的 交易预执行系统 Mopsus 检测攻击交易,并通过自动合成一个救援交易来阻止攻击,该交易会将易受攻击的资产转移到我们的安全账户,并通过 FlashBot 抢先于攻击交易执行。下图显示了该架构。

系统架构概述
系统架构概述

内存池监控

IronDome 通过我们定制的 Geth 客户端监听内存池中的待处理交易。关键在于我们的系统应该及时监听尽可能多的交易。

攻击检测

每笔待处理交易都将输入攻击检测模块。由于这些交易尚未上链,我们将利用我们的交易预执行引擎 Mopsus 对这些交易进行预执行,并根据交易的运行时状态和结果来检测攻击(恶意)交易。

救援交易合成

对于攻击交易,IronDome 将自动合成一个救援交易及其辅助合约。救援交易将采用与攻击交易类似的方法来“利用”易受攻击的合约,但将利润转移到我们的安全账户(一个多签账户),而不是攻击者控制的账户。例如,我们可以自动部署类似于攻击合约的辅助合约,但将代币转移地址替换为我们的安全账户。当然,对于某些攻击交易需要使用更复杂的方法。

对于救援交易,我们需要确保其在攻击交易之前上链。在当前系统中,我们为此目的利用了 FlashBot。首先,我们必须确保其他人无法监听我们的救援交易。其次,我们可以采取一些策略来使我们的救援交易排在区块的最前面。

典型成功案例

我们在 2022 年初部署了 IronDome。该系统已成功检测并阻止了多次攻击。此表格 总结了一些成功案例。

以下时间线展示了我们的系统如何在 2022 年 4 月底为 Saddle Finance 挽救了 380 万美元。特别值得一提的是,我们的系统在不到一秒钟的时间内完成了检测攻击交易和自动合成救援交易的整个过程。我们已将所有被救出的资金返还给 Saddle Finance。点击链接查看 原始黑客交易我们的救援交易

道德考量

我们在系统中认真对待安全道德。尽管我们的系统“利用”了易受攻击的合约来挽救用户资产,但我们认为此行为没有道德问题。

  • 首先,我们的系统并未主动利用易受攻击的合约。它仅在检测到待处理的攻击交易时做出反应,并自动合成一个类似的交易(以阻止攻击交易)。它从不主动发起攻击交易。
  • 其次,我们积极与受影响的协议沟通,并返还被救出的资金。

局限性

尽管 IronDome 已显示其有效性,但该系统仍存在一些局限性。接下来,我们将阐述这些局限性,并讨论主动威胁防护的未来方向。

  • 首先,我们的系统监听内存池中的待处理交易。如果攻击者利用了某些私人交易服务(例如 FlashBot),攻击交易将不在内存池中,因此无法被检测到。为解决此问题,我们呼吁与私人交易服务提供商合作,以检测和阻止攻击交易(采用与我们系统检测恶意交易类似的方法)。此外,即使我们的系统无法在待处理池中阻止攻击交易,它仍然可以在链上检测攻击交易,并发送救援交易以阻止进一步的攻击交易。请注意,在许多情况下,攻击交易不止一个。
  • 其次,安全是一场军备竞赛。我们已经看到攻击者提高了合成救援交易的门槛。例如,他们可以将攻击交易分成多个交易,并混淆利润地址。虽然这些问题可以解决,但我们认为军备竞赛不会停止。我们正在研究解决方案来解决这些问题。
  • 第三,如何让救援交易在攻击交易之前上链仍然是一个悬而未决的问题。虽然一些竞价策略可以提高我们的救援交易被打包进区块的几率,但我们无法获得 100% 的保证。

参考资料和进一步阅读

[1] 如何使区块链攻击“可被阻止” | By BlockSec

[2] The Block:稳定币 DEX Saddle Finance 被盗 1000 万美元

[3] Lend 漏洞利用事后分析 — HomeCoin (mirror.xyz)

[4] Equalizer Finance 在 Twitter 上发布:“我们已经追回了以太坊和 BSC 上金库的资金。现在团队正在努力追回 Polygon 和 Optimism 链上的资金。非常感谢 @BlockSecTeam,他们成功阻止了攻击者,保护并返还了资产!” / Twitter

[5] FSWAP 在 Twitter 上发布:“FSWAP 流动性进展攻击细节” / Twitter

[6] https://forta.org/blog/blocksec-and-forta-work-to-secure-web3-beyond-audits/

[7] https://forta.org/blog/the-future-of-threat-prevention-in-web3/

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.