[Hardening] Validate legacy block_headers length before slicing (F-007)

オープン 初心者向け
#236 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@notmandatory がすでに取り組んでいます。

2026年11月9日 から。

  • #238 @notmandatory による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

対象のリビジョンの raw_client.rs の1062~1068行目から始め、プロトコル1.4における旧形式の blockchain.block.headers 応答の処理を追ってください。デコードされたヘッダーの長さと count がスライス処理の前にどう使われるかを確認し、空または途中で切れたヘッダー、および個数が一致しない場合の回帰テストを追加してください。不正な応答がパニックを起こさずプロトコルエラーを返し、有効なヘッダー応答は引き続き機能すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug

Summary

In rust-electrum-client 0.25.2 (reported upstream commit 7c1d759e2789b5e46fcae1525ab06ff4012bc668), the pre-1.6 legacy response path for blockchain.block.headers trusts the server-controlled result.count and slices the decoded header bytes in fixed 80-byte chunks without validating the available length. A malicious or compromised Electrum server (or an attacker able to alter the Electrum connection) can make a release build panic, causing client/wallet availability loss.

Reproduction

  1. Build the client in release mode.
  2. Connect to a mock TCP Electrum server.
  3. Negotiate protocol version 1.4.
  4. Return this response to blockchain.block.headers:
{"jsonrpc":"2.0","id":1,"result":{"count":1,"max":8,"hex":""}}

Observed:

range end index 80 out of range for slice of length 0

A negative control containing one valid 80-byte header with count=1 returns normally. A count=3 response containing only one header panics at the second slice.

Source

Reported source location: raw_client.rs lines 1062–1068 (in the affected revision).

Suggested hardening

  • Validate the decoded header byte length (and its consistency with count) before fixed-size slicing.
  • Return a normal protocol error on mismatch instead of panicking.
  • Add regression tests for empty/truncated headers and mismatched counts.

This is a hardening issue: the demonstrated impact is availability loss in release mode; no fund or privacy compromise was observed.

主要言語
Rust
スター
89
フォーク
87
平均マージ
1時間 25分
マージ済み PR(30日)
4

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bitcoindevkit/rust-electrum-client のほかの issue

bitcoindevkit/rust-electrum-client の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。