[Hardening] Validate legacy block_headers length before slicing (F-007)
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
対象のリビジョンの raw_client.rs の1062~1068行目から始め、プロトコル1.4における旧形式の blockchain.block.headers 応答の処理を追ってください。デコードされたヘッダーの長さと count がスライス処理の前にどう使われるかを確認し、空または途中で切れたヘッダー、および個数が一致しない場合の回帰テストを追加してください。不正な応答がパニックを起こさずプロトコルエラーを返し、有効なヘッダー応答は引き続き機能すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- Build the client in release mode.
- Connect to a mock TCP Electrum server.
- Negotiate protocol version 1.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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bitcoindevkit/rust-electrum-client のほかの issue
-
[Hardening] Reject non-object JSON notifications without panicking (F-008)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
bitcoindevkit/rust-electrum-client#221 · コメント 1 件 ·
-
use-rustls-ring transitively enables rustls/default (aws-lc-rs), breaking ring-only builds対応中かも @EddieHouston が 130 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
discussion new feature
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
bitcoindevkit/rust-electrum-client#211 · コメント 2 件 ·
-
Rework CI to use `cargo-rbmt`再び着手できるかも @luisschwab が 205 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
bitcoindevkit/rust-electrum-client#202 · 担当者 1 名 ·
bitcoindevkit/rust-electrum-client の issue をすべて見る
似ている issue
-
Panic on live viewport resize when unstyled elements exist in display: none subtree対応中かも @GoCoder7 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
DioxusLabs/blitz#1488 ·
メンテナーはふだん 1 日以内に返信
-
🏷️ good first issue enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
S-Needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
vectordotdev/vrl#2042 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信