Back to Blog

我们如何为TransitSwap(及BabySwap)追回被盗资金

Code Auditing
October 10, 2022

我们如何为 Transit Swap 和 Baby Swap 追回被盗资金

10 月 1 日,BSC 上的 BabySwap 和 TransitSwap 遭到攻击。一些攻击性交易被一个机器人抢跑。有趣的是,这个机器人容易受到 profanity 工具漏洞的攻击,我们成功地找回了它的私钥。我们还设法逆向工程了机器人合约,并将资金从机器人合约提取到我们的安全账户。我们已将资金转至 TransitSwap,目前正在对接 BabySwap。

BabySwap 攻击的检测

2022 年 10 月 1 日 14:47(UTC),我们的内部系统报告了一次攻击性交易。我们进一步分析表明,这是由于智能路由器合约中的受控工厂所致。然而,由于项目当时仍然存在漏洞,我们并未披露细节。我们通过 Twitter 私信和 TG 联系了 BabySwap,但没有收到回复。

在调查过程中,我们发现该交易是由一个机器人账户发出的,该机器人账户抢跑了原始攻击性交易。此外,该账户的八个前导零的模式,看起来是由易受 profanity 工具漏洞攻击的 profanity 工具生成的。

机器人私钥的找回

2022 年 10 月 1 日 16:10(UTC),我们的工具在约 20 分钟内成功找回了该机器人的私钥。对于找回的私钥,我们将资金转至一个安全账户(这是我们救援的典型流程)。否则,其他找回私钥的人可能会接管该账户,账户中的资金将面临风险。

从机器人中转移资金

挑战在于资金位于机器人部署的合约中,而不是机器人 EOA 账户本身。如何转移资金是一个挑战。

我们反编译了合约,并发现合约中有一个提取函数(如下图所示)。

该函数可用于从合约中提取资金。第一个参数是代币地址,第二个参数应为零。

我们发送了一笔交易,成功将合约中的资金提取到机器人,然后将资金转至我们的安全账户

另一场攻击来了!

几个小时后,我们的系统报告了对TransSwap的又一次攻击。有几笔来自不同地址的攻击性交易,其中一笔交易再次被该机器人抢跑!但是,由于机器人部署的合约是不同的,提取资金的函数也不同。

归还资金

经过内部讨论,我们决定将资金归还给受攻击的项目(而不是机器人),原因如下:

  • 首先,资金是通过机器人攻击易受攻击的合约获得的。虽然机器人抢跑了攻击性交易(而不是直接发起攻击),但我们仍然认为抢跑攻击性交易也是一种攻击。
  • 其次,资金属于攻击的受害者,即受影响的 DeFi 协议的用户。用户因 DeFi 协议的漏洞而遭受了巨大损失。他们应该从攻击者那里收到资金。

我们已将资金转至TransitFinance 官方资金接收地址,并正在联系 BabySwap

救援更新

我们仍在救援易受攻击地址的流程中。挑战在于,在找回私钥之前,你无法确定一个地址是否易受攻击。即使我们有优化的算法,由于计算能力的限制,我们仍然需要更多时间来完成整个救援。我们将稍后发布一份详细报告,阐述整个过程并回答以下问题:

  • 有多少地址易受攻击?
  • 漏洞的影响是什么,即有多少资产因漏洞而面临风险?
  • 这种漏洞攻击的整个情况是怎样的?

请继续关注并保持安全。

关于 BlockSec

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

迄今为止,该公司已为 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
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