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
Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure
Case Studies

Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure

An on-chain investigation into VerilyHK, a fraudulent platform that moved $1.6B in TRON USDT through a multi-layered fund-routing infrastructure of rotating wallets, paired payout channels, and exchange exit funnels, with traced connections to the FinCEN-sanctioned Huione Group.

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026

This BlockSec weekly security report covers nine DeFi attack incidents detected between March 30 and April 5, 2026, across Solana, BNB Chain, Arbitrum, and Polygon, with total estimated losses of approximately $287M. The week was dominated by the $285.3M Drift Protocol exploit on Solana, where attackers combined multisig signer social engineering with Solana's durable nonce mechanism to bypass a zero-timelock 2-of-5 Security Council, alongside notable incidents including a $950K flash loan TWAP manipulation against the LML staking protocol, a $359K Silo Finance vault inflation via an external `wstUSR` market donation exploiting a depegged-asset oracle and `totalAssets()` accounting flaw, and an EIP-7702 delegated-code access control failure. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident, covering flawed business logic, access control, price manipulation, phishing, and misconfiguration attack types.

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.

Best Security Auditor for Web3

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

BlockSec Audit