Back to Blog

我们如何为TransitSwap和BabySwap追回被盗资金

October 10, 2022
4 min read

引言

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联系。

救援更新

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

  • 有多少地址易受攻击?
  • 该漏洞的影响如何,即有多少资产因该漏洞面临风险?
  • 该漏洞的攻击情况如何?

请继续关注并保持安全。

启示

确保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
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.