Back to Blog

Solanaネットワークの重大なバグ検知と迅速な修正方法

Code Auditing
June 7, 2022
6 min read

4月、当社の脆弱性検出システムはSolanaのrBPF(SolanaのdAppsがすべて動作する仮想マシンです。https://github.com/solana-labs/rbpf)に問題を発見しました。詳細な調査の結果、これはスマートコントラクトの不正な実行パスにつながる可能性のあるセキュリティ脆弱性であることが判明しました。このバグをSolanaのセキュリティチームに報告したところ、チームは直ちに脆弱性を確認し、修正しました。また、当社チームには80万米ドル相当のSoLトークンが付与されました。

この脆弱性は、rBPFの新しいバージョン(0.2.26から0.2.27)に存在します。当社が問題を報告した時点では、メインネットで使用されているバリデーターはこの影響を受けるバージョンにアップグレードされていませんでした。当社のシステムは、影響を受けるバージョンがマージされる前に問題を検出したため、メインネットのバリデーターはこの脆弱性の影響を受けずに済みました。

以下に、この脆弱性の詳細を説明します。

1. eBPFとrBPF

eBPF(Extended Berkeley Packet Filter)は、当初カーネルでのパケットフィルタリングのために開発されました。eBPFのセキュリティ、効率性、スケーラビリティにより、現在ではネットワーク、トレーシング、プロファイリングなど、さまざまな分野で使用されています(etc)。eBPFの豊富な機能性を考慮し、Solanaはそれをスマートコントラクトの実行エンジンとして使用しています。Solana上でdAppsを開発するために、開発者はRustでスマートコントラクトを開発し、コントラクトをeBPFバイトコードにコンパイルします。

Solanaは、Rustで書かれた仮想マシンであるrBPFを使用して、コンパイルされたBPFバイトコードを実行します。しかし、提案されている仮想マシン(つまりrBPF)が堅牢で安全かつ正確であるかは不明です。rBPFにセキュリティ上の問題が存在する場合、rBPFを含むすべてのバリデーターが影響を受け、Solanaネットワーク全体に多大な損失(例:資金の喪失)をもたらす可能性があります。

2. 原因

当社は、rBPFの実装バグを自動的に特定し、rBPFのコードを定期的にスキャンするツールを開発しました。スキャンプロセス中に、rBPF(バージョン0.2.26)で深刻な問題が特定されました。これは、コントラクトの不正な実行パスにつながる可能性があります。

具体的には、sdiv命令は符号付き除算命令として使用されており、rbpf 0.2.26でデフォルトで有効化された機能として導入されました。sdivは、32ビット(sdiv32)と64ビット(sdiv64)の両方のオペランドの除算をサポートしています。sdiv32命令の場合、計算結果は64ビットのbpfレジスタに格納されます。しかし、sdiv32命令の後の命令が計算結果を64ビットとして読み取った場合、結果が異なる可能性があります。これは、rBPFがJITコンパイル中にsdiv32の計算結果を64ビットの正しい値に拡張しないためです。

たとえば、正の数(12)を負の数(-4)でsdiv32で割った場合、正しい結果は32ビットと64ビットの両方で-3になるはずです。以下のコードはその例です。

JITモードとインタープリターモードの両方で実行およびトレースを行った後、両者の違いを観察することができました。

2.1 インタープリターモード

0 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    29: lddw r5, 0x10000000c
 1 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, 000000010000000C, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    31: sdiv32 r5, -4
 2 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, FFFFFFFFFFFFFFFD, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    32: jslt r5, 0, lbb_7
 3 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, FFFFFFFFFFFFFFFD, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    36: exit

2.2 JITモード

0 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    29: lddw r5, 0x10000000c
 1 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, 000000010000000C, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    31: sdiv32 r5, -4
 2 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, 00000000FFFFFFFD, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    32: jslt r5, 0, lbb_7
 3 [0000000000000000, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, 00000000FFFFFFFD, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    33: lddw r0, 0x1
 4 [0000000000000001, 0000000400000000, 0000000000000000, 0000000000000000, 0000000000000000, 00000000FFFFFFFD, 0000000000000000, 0000000000000000, 0000000000000000, 0000000000000000, 0000000200014000]    35: exit

インタープリターモードでは、レジスタr50xFFFFFFFFFFFFFFFD(32ビットおよび64ビットモードで-3)に設定されますが、JITモードではr50x00000000FFFFFFFDに設定されます。この場合、64ビット値を受け取るjslt命令にとっては、r5は正の数(0x00000000FFFFFFFD)として認識されます。その後、実行パスは完全に不正になります。

3. 影響

この不正な実装は、コントラクトの不正な実行パスにつながり、深刻な問題を引き起こす可能性があります。

例えば、スマートコントラクトにおける重要な操作がsdiv32命令の結果に依存している場合、不正な実行結果につながり、攻撃者によって悪用される可能性があります。

この問題はhttps://github.com/solana-labs/rbpf/pull/283で導入されたため、rBPFはバージョン0.2.26から脆弱性があります。当社はこの問題を特定し、2022年4月28日にSolanaのセキュリティチームに報告しました。チームは迅速に対応し、sdiv32命令に符号拡張処理を追加することで数時間で問題を修正しました。修正はhttps://github.com/solana-labs/rbpf/pull/310にあります。当社のチームによるタイムリーな検出と報告により、メインネットのバリデーターはこの脆弱性の影響を受けませんでした。

この問題はプロトコルのライブネスバグとして分類され、Solanaから80万米ドルのバグバウンティが付与されました。

タイムライン

  • 2022/04/28: Solanaセキュリティチームに問題を報告
  • 2022/04/29: 脆弱性が修正される
  • 2022/05/09: CVE-2022-23066が割り当てられる
  • 2022/06/01: バグバウンティが付与される

BlockSecについて

BlockSecチームは、ブロックチェーンエコシステムのセキュリティに注力し、主要なDeFiプロジェクトと協力して製品を保護しています。チームは、学界および産業界のトップクラスのセキュリティ研究者と経験豊富な専門家によって設立されました。著名なカンファレンスで複数のブロックチェーンセキュリティ論文を発表し、DeFiアプリケーションのゼロデイ攻撃を数件報告し、影響力の大きいセキュリティインシデントの詳細な分析レポートを公開しています。

Twitter: [BlockSecTeam]

Medium: https://blocksecteam.medium.com

Website: https://www.blocksec.com

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