Back to Blog

「セーフミント」が危険になる時:HypeBearsセキュリティインシデントからの教訓

Code Auditing
February 3, 2022

2月3日午前(+8時台)、当社のシステムは、HypeBears NFTコントラクトに対する攻撃トランザクション0xfa97c3476aa8aeac662dae0cc3f0d3da48472ff4e7c55d0e305901ec37a2f704を報告しました。調査の結果、ERC721の_safeMint関数によって引き起こされたリエントランシー攻撃であることが判明しました。

原因

プロジェクトには、アカウントがミントできるNFTの数に制限があります。基本的に、NFTをミントしたかどうかを記録するaddressMintedというマップがあります。

NFTをミントする際、コードはOZリファレンス実装の_safeMint関数を使用します。この関数は、受信者がERC721トークンを受信できるかどうかを確認するため、safeです。これにより、ERC721トークンを処理できないコントラクトにNFTがミントされるのを防ぐことができます。以下は、ドキュメントによると:

toがスマートコントラクトを参照する場合、IERC721Receiver.onERC721Receivedを実装する必要があります。これはセーフ転送時に呼び出されます。以下のコードは、_safeMint関数のOZ実装を示しています。

しかし、この外部関数呼び出しはセキュリティ上の脆弱性を生み出します。具体的には、攻撃者はonERC721Receivedコールバック内でリエントラント呼び出しを実行できます。例えば、脆弱なHypeBearsコントラクトでは、攻撃者はonERC721Receivedコールバック内でmintNFT関数を再度呼び出すことができます(addressMintedがまだ更新されていないため)。

攻撃

以下のスクリーンショットは、攻撃トランザクションを示しています。

教訓

SafeMintによって引き起こされるリスクは、セキュリティ研究者によって議論されてきました。link1 link2。しかし、依然として脆弱なコードと実際の攻撃を目にすることができます。QBridgeセキュリティインシデントsafeTransferで示されているように、安全な関数を使用しても、安全なコントラクトが保証されるわけではありません😃。

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