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
~$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.