Back to Blog

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

Code Auditing
January 28, 2022

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

Best Security Auditor for Web3

Validate design, code, and business logic before launch. Aligned with the highest industry security standards.

BlockSec Audit