Back to Blog

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

October 10, 2022

引言

10月1日,BSC上的BabySwap和TransitSwap遭受攻击。一些攻击交易被一个机器人抢先执行。有趣的是,这个机器人存在Profanity工具漏洞,我们成功地恢复了它的私钥。我们还设法逆向工程了机器人合约,并将资金从机器人合约中提取到我们的安全账户。我们已将资金转移至TransitSwap,目前正在联系BabySwap。

时间线

BabySwap攻击的检测

2022年10月1日14:47(UTC),我们的内部系统报告一笔攻击交易。我们进一步分析表明,这是由于智能路由合约中的受控工厂导致的。然而,当时我们没有披露细节,因为项目仍然存在漏洞。我们通过Twitter DM和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
Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation
Security Insights

Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation

On April 1, 2026 (UTC), Drift Protocol on Solana suffered a $285.3M loss after an attacker exploited Solana's durable nonce mechanism to delay the execution of phished multisig approvals, ultimately transferring administrative control of the protocol's 2-of-5 Squads governance with zero timelock. With full admin privileges, the attacker created a malicious collateral market (CVT), inflated its oracle price, relaxed withdrawal protections, and drained USDC, JLP, SOL, cbBTC, and other assets through 31 rapid withdrawals in approximately 12 minutes. This incident highlights how durable nonce-based delayed execution can decouple signer intent from on-chain execution, bypassing the temporal assumptions that multisig security implicitly relies on.

Weekly Web3 Security Incident Roundup | Mar 23 – Mar 29, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 23 – Mar 29, 2026

This BlockSec weekly security report covers eight DeFi attack incidents detected between March 23 and March 29, 2026, across Ethereum and BNB Chain, with total estimated losses of approximately $1.53M. Incidents include a $679K flawed burn mechanism exploit on the BCE token, a $512K spot-price manipulation attack on Cyrus Finance's PancakeSwap V3 liquidity withdrawal, a $133.5K flash-loan-driven referral reward manipulation on a TUR staking contract, and multiple integer overflow, reentrancy, and accounting error vulnerabilities in DeFi protocols. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Newsletter -  March 2026
Security Insights

Newsletter - March 2026

In March 2026, the DeFi ecosystem experienced three major security incidents. Resolv Protocol lost ~$80M due to compromised privileged infrastructure keys, BitcoinReserveOffering suffered ~$2.7M from a double-minting logic flaw, and Venus Protocol incurred ~$2.15M following a donation attack combined with market manipulation.