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
Tether Freezes $6.76M USDT Linked to Iran's IRGC & Houthi Forces: Why On-Chain Compliance is Now a Geopolitical Battlefield
Security Insights

Tether Freezes $6.76M USDT Linked to Iran's IRGC & Houthi Forces: Why On-Chain Compliance is Now a Geopolitical Battlefield

Looking ahead, targeted freezing events like this $6.76M USDT action will only become more common. On-chain data analysis is improving. Stablecoin issuers are also working closely with regulators. As a result, hidden illicit financial networks will be exposed.

Weekly Web3 Security Incident Roundup | Mar 2 – Mar 8, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 2 – Mar 8, 2026

During the week of March 2 to March 8, 2026, seven blockchain security incidents were reported with total losses of ~$3.25M. The incidents occurred across Base, BNB Chain, and Ethereum, exposing critical vulnerabilities in smart contract business logic, token deflationary mechanics, and asset price manipulation. The primary causes included a double-minting logic flaw during full token deposits that allowed an attacker to exponentially inflate their balances through repeated burn-and-mint cycles, a price manipulation vulnerability in an AMM-based lending market where artificially inflated vault shares created divergent price anchors to incorrectly force healthy positions into liquidation, and a flawed access control implementation relying on trivially spoofed contract interfaces that enabled attackers to bypass authorization to batch-mint and dump arbitrary tokens.

Weekly Web3 Security Incident Roundup | Feb 23 – Mar 1, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Feb 23 – Mar 1, 2026

During the week of February 23 to March 1, 2026, seven blockchain security incidents were reported with total losses of ~$13M. The incidents affected multiple protocols, exposing critical weaknesses in oracle design/configuration, cryptographic verification, and core business logic. The primary drivers included oracle manipulation/misconfiguration that led to the largest loss at YieldBloxDAO (~$10M), a crypto-proof verification flaw that enabled the FOOMCASH (~$2.26M) exploit, and additional token design and logic errors impacting Ploutos, LAXO, STO, HedgePay, and an unknown contract, underscoring the need for rigorous audits and continuous monitoring across all protocol layers.