当“安全转账”变得不安全:QBridge 安全事件的教训

当“安全转账”变得不安全:QBridge 安全事件的教训

1月28日,QBridge遭到攻击,约8000万美元的资产被盗。经过分析,我们发现代码中的根本原因在于safeTransfer(和safeTransferFrom)函数的实现。

根本原因

首先,该项目没有使用流行的OpenZeppelin SafeERC20库进行代币转移。相反,他们实现了一个名为SafeToken的库。

其次,实现中没有检查目标是否为有效合约(或是否为零地址)。

第三,**当目标合约为零时,EVM的低级调用不会返回false。**这与开发者的常识相悖。

当然,此次事件还有其他原因,例如,零地址被加入了白名单。但是,如果代码能够妥善处理这种情况,那么就不会存在漏洞。

顺便说一下:还有其他项目使用了类似的代码,它们可能也容易受到类似问题的影响。

实验

为了证实VM在目标合约为零时不会返回false的第三个原因,我们开发了一个测试合约,如下所示。

执行TestSafeTransfer.test()不会回滚。

教训和风险缓解方法

我们建议:

  • 使用流行的库,而不是自己重新发明轮子,除非有非常非常充分的理由。
  • 在资产转移前后检查余额,以确保转移资产的数量符合预期。这也可以避免通缩和通胀代币的问题。

关于BlockSec

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

迄今为止,公司已为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
Weekly Web3 Security Incident Roundup | Feb 9 – Feb 15, 2026

Weekly Web3 Security Incident Roundup | Feb 9 – Feb 15, 2026

During the week of February 9 to February 15, 2026, three blockchain security incidents were reported with total losses of ~$657K. All incidents occurred on the BNB Smart Chain and involved flawed business logic in DeFi token contracts. The primary causes included an unchecked balance withdrawal from an intermediary contract that allowed donation-based inflation of a liquidity addition targeted by a sandwich attack, a post-swap deflationary clawback that returned sold tokens to the caller while draining pool reserves to create a repeatable price-manipulation primitive, and a token transfer override that burned tokens directly from a Uniswap V2 pair's balance and force-synced reserves within the same transaction to artificially inflate the token price.

Top 10 "Awesome" Security Incidents in 2025

Top 10 "Awesome" Security Incidents in 2025

To help the community learn from what happened, BlockSec selected ten incidents that stood out most this year. These cases were chosen not only for the scale of loss, but also for the distinct techniques involved, the unexpected twists in execution, and the new or underexplored attack surfaces they revealed.

#10 Panoptic Incident: XOR Linearity Breaks the Position Fingerprint Scheme

#10 Panoptic Incident: XOR Linearity Breaks the Position Fingerprint Scheme

On August 29, 2025, Panoptic disclosed a Cantina bounty finding and confirmed that, with support from Cantina and Seal911, it executed a rescue operation on August 25 to secure roughly $400K in funds. The issue stemmed from a flaw in Panoptic’s position fingerprint calculation algorithm, which could have enabled incorrect position identification and downstream fund risk.