Back to Blog

「セーフ・トランスファー」が危険に:QBridgeセキュリティインシデントからの教訓

Code Auditing
January 28, 2022
3 min read

1月28日、QBridgeが攻撃を受け、約8000万米ドル相当の資産が盗まれました。分析の結果、コードの根本原因はsafeTransfer(およびsafeTransferFrom)関数の実装にあることが判明しました。

根本原因

まず、このプロジェクトでは、トークン転送に一般的なOpenZeppelin SafeERC20ライブラリを使用せず、代わりにSafeTokenというライブラリを実装していました。

次に、実装では、ターゲットが有効なコントラクトであるか(またはゼロアドレスであるか)を確認していませんでした。

第三に、EVMの低レベルコールは、ターゲットコントラクトがゼロである場合にfalseを返しません。これは開発者の常識に反します。

もちろん、このインシデントには、例えばゼロアドレスがホワイトリストに入れられていたなど、他の理由もいくつかあります。しかし、コードがこの特別なケースを適切に処理できれば、脆弱性はありません。

ちなみに、類似のコードを使用している他のプロジェクトも存在します。それらも同様の問題の影響を受ける可能性があります。

実験

VMがターゲットコントラクトがゼロの場合にfalseを返さないという3番目の理由を確認するために、以下に示すテストコントラクトを開発しました。

TestSafeTransfer.test()の実行はリバートしません。

教訓とリスク軽減策

私たちは以下を提案します。

  • 非常に良い理由がない限り、自分で車輪を再発明するのではなく、一般的なライブラリを使用してください。
  • 資産転送の前後に残高を確認し、転送された資産の数量が期待値と一致することを確認してください。これにより、デフレまたはインフレトークンの問題も回避できます。

BlockSecについて

BlockSecは、2021年に世界的に著名なセキュリティ専門家グループによって設立された、先駆的なブロックチェーンセキュリティ企業です。当社は、新興のWeb3世界におけるセキュリティとユーザビリティの向上に専念し、その普及を促進することを目指しています。この目的のために、BlockSecはスマートコントラクトおよびEVMチェーンのセキュリティ監査サービス、セキュリティ開発とプロアクティブな脅威ブロックのためのPhalconプラットフォーム、資金追跡と調査のためのMetaSleuthプラットフォーム、そしてWeb3開発者が仮想通貨の世界を効率的にサーフィンするためのMetaDock拡張機能を提供しています。

現在までに、当社はMetaMask、Uniswap Foundation、Compound、Forta、PancakeSwapなど300社以上の著名なクライアントにサービスを提供し、Matrix Partners、Vitalbridge Capital、Fenbushi Capitalなどの著名な投資家から2回の資金調達で数千万米ドルを受け入れています。

公式ウェブサイト:https://blocksec.com/

公式Twitterアカウント:https://twitter.com/BlockSecTeam

Sign up for the latest updates
The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis
Security Insights

The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis

This BlockSec deep-dive analyzes the KelpDAO $290M rsETH cross-chain bridge exploit (April 18, 2026), attributed to the Lazarus Group, tracing a causal chain across three layers: how a single-point DVN dependency enabled the attack, how DeFi composability cascaded the damage through Aave V3 lending markets to freeze WETH liquidity exceeding $6.7B across Ethereum, Arbitrum, Base, Mantle, and Linea, and how the crisis forced decentralized governance to exercise centralized emergency powers. The article examines three parameters that shaped the cascade's severity (LTV, pool depth, and cross-chain deployment count) and provides an exclusive technical breakdown of Arbitrum Security Council's forced state transition, an atomic contract upgrade that moved 30,766 ETH without the holder's signature.

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026

This BlockSec weekly security report covers four attack incidents detected between April 13 and April 19, 2026, across multiple chains such as Ethereum, Unichain, Arbitrum, and NEAR, with total estimated losses of approximately $310M. The highlighted incident is the $290M KelpDAO rsETH bridge exploit, where an attacker poisoned the RPC infrastructure of the sole LayerZero DVN to fabricate a cross-chain message, triggering a cascading WETH freeze across five chains and an Arbitrum Security Council forced state transition that raises questions about the actual trust boundaries of decentralized systems. Other incidents include a $242K MMR proof forgery on Hyperbridge, a $1.5M signed integer abuse on Dango, and an $18.4M circular swap path exploit on Rhea Finance's Burrowland protocol.

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026

This BlockSec weekly security report covers four DeFi attack incidents detected between April 6 and April 12, 2026, across Linea, BNB Chain, Arbitrum, Optimism, Avalanche, and Base, with total estimated losses of approximately $928.6K. Notable incidents include a $517K approval-related exploit where a user mistakenly approved a permissionless SquidMulticall contract enabling arbitrary external calls, a $193K business logic flaw in the HB token's reward-settlement logic that allowed direct AMM reserve manipulation, a $165.6K exploit in Denaria's perpetual DEX caused by a rounding asymmetry compounded with an unsafe cast, and a $53K access control issue in XBITVault caused by an initialization-dependent check that failed open. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Best Security Auditor for Web3

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

BlockSec Audit