Back to Blog

Solana rBPFでの新たな整数オーバーフローバグ発見

Code Auditing
December 30, 2021
3 min read

最近、当社の脆弱性検出システムは、Solana の rBPF(Solana の dApps がすべて実行される仮想マシンです:https://github.com/solana-labs/rbpf)において、重大な問題を発見しました。慎重な調査の結果、これは整数オーバーフローのバグであり、Solana ネットワーク全体をクラッシュさせるために悪用される可能性があることが判明しました。このバグを Solana セキュリティチームに報告したところ、チームは直ちに確認と修正に着手しました。本稿執筆時点では、ほぼすべてのバリデーターノードがパッチを受け取り最新バージョンにアップグレードしているため、公開開示しても安全であると言えます。

eBPFとrBPF

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

Solana の dApps をホストするには、eBPF 用の正確な仮想マシンが必要です。この場合、Solana は Rust で書かれた eBPF 用の仮想マシンである rBPF を使用します。しかし、提案されている仮想マシン(つまり rBPF)が堅牢で安全で正確であるかどうかは不明です。rBPF の内部にセキュリティ上の問題が存在すると、rBPF を含むすべてのバリデーターに影響が及ぶ可能性があり、Solana ネットワーク全体に甚大な損害(例:DDoS 攻撃)をもたらす可能性があります。

バグの根本原因

rBPF のバグを特定するためのツールを開発しました。このツールは現在も開発中です。このプロセス中に、rBPF(バージョン 0.2.16)で、ネットワーク全体をダウンさせる可能性のある深刻な問題が特定されました。

具体的には、「elf.rs」ファイル内の「load」関数は、ELF ファイル(スマートコントラクト)を解析および検証するために使用されます。「load」関数はまず ELF 構造を読み込み、「relocate」関数を呼び出して呼び出し元オフセットを設定します。しかし、「relocate」関数では、「sym.st_value」属性がELF ファイルから直接取得されます。「st_value」が十分に大きい場合、「sym.st_value」と「refd_pa」の合計である「addr」を計算する際に整数オーバーフローが発生する可能性があります。

この場合、攻撃者は悪意のある ELF ファイルをスマートコントラクトとして作成し、整数オーバーフローをトリガーすることができます。その後、すべてのバリデーターがターゲットの ELF ファイルを実行し、rBPF は「add with overflow」というエラーでパニックを起こします。

この時点で、rBPF はハングアップし、後続のトランザクションは実行されなくなるため、DoS 攻撃につながります。以下に示すように、ELF ファイルのロード中に整数オーバーフローが発生したため、ノードが「Finalizing transaction」でハングアップしていることがわかります。

この問題は https://github.com/solana-labs/rbpf/pull/200 で導入されたため、rBPF はバージョン 0.2.14 から脆弱でした。この問題を特定し、2021年12月6日に Solana セキュリティチームに報告しました。Solana は、報告後数時間で safemath 機構を使用して問題を修正しました。修正は https://github.com/solana-labs/rbpf/pull/236 にあります。本稿執筆時点(2021/12/30)で、バリデーターの 86% 以上が最新バージョンにアップグレードしています。

[1] https://en.wikipedia.org/wiki/Berkeley_Packet_Filter [2] https://ebpf.io/

タイムライン

  • 2021/12/06: Solana セキュリティチームに問題が報告されました。
  • 2021/12/06: 脆弱性が修正されました。
  • 2021/12/30: この脆弱性の情報が公開されました。
  • 2022/01/28: CVE-2021–46102 が割り当てられました。
Sign up for the latest updates
~$4.72M Lost: TAC, Transit Finance & More | BlockSec Weekly
Security Insights

~$4.72M Lost: TAC, Transit Finance & More | BlockSec Weekly

This BlockSec weekly security report covers 3 notable attack incidents identified between May 11 and May 17, 2026, across TRON, TON, and Ethereum, with total estimated losses of approximately $4.72M. Three incidents are analyzed in detail: the highlighted $1.88M Transit Finance exploit on TRON, where a deprecated swap bridge contract with lingering token approvals was exploited through arbitrary calldata forwarding; the $2.8M TAC TON-to-EVM bridge exploit caused by missing canonical wallet verification in the jetton deposit flow; and the $46.75K Boost Hook exploit on Ethereum, where spot price manipulation on a Uniswap V4 hook-based perpetual protocol forced the protocol to buy tokens at inflated prices using its own reserves.

~$15.9M Lost: Trusted Volumes, Wasabi & More | BlockSec Weekly
Security Insights

~$15.9M Lost: Trusted Volumes, Wasabi & More | BlockSec Weekly

This BlockSec bi-weekly security report covers 11 notable attack incidents identified between April 27 and May 10, 2026, across Sui, Ethereum, BNB Chain, Base, Blast, and Berachain, with total estimated losses of approximately $15.9M. Three incidents are analyzed in detail: the highlighted $1.14M Aftermath Finance exploit on Sui, where a signed/unsigned semantic mismatch in the builder-fee validation allowed an attacker to inject a negative fee that was converted into positive collateral during settlement; the $5.87M Trusted Volumes RFQ authorization mismatch on Ethereum; and the $5.7M Wasabi Protocol infrastructure-to-contract-control compromise across multiple EVM chains.

Newsletter - April 2026
Security Insights

Newsletter - April 2026

In April 2026, the DeFi ecosystem experienced three major security incidents. KelpDAO lost ~$290M due to an insecure 1-of-1 DVN bridge configuration exploited via RPC infrastructure compromise, Drift Protocol suffered ~$285M from a multisig governance takeover leveraging Solana's durable nonce mechanism, and Rhea Finance incurred ~$18.4M following a business logic flaw in its margin-trading module that allowed circular swap path manipulatio

Best Security Auditor for Web3

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

BlockSec Audit