[Hardening] Reject non-object JSON notifications without panicking (F-008)

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

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

2026年11月9日 から。

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

評価

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

調査の方向性

raw_client.rs の764~773行付近で、通知経路がJSONレスポンスのフィールドを読み取る箇所から始めてください。オブジェクト以外のJSON値がどのように処理されるかを確認し、スカラー、配列、nullの通知に対する回帰テストを追加してください。無効な通知形式がpanicを起こさず通常のプロトコルエラーまたはパースエラーを返し、nullのネガティブコントロールでは引き続きpingが完了すれば完了です。

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

説明

bug

Summary

In rust-electrum-client 0.25.2 (reported upstream commit 7c1d759e2789b5e46fcae1525ab06ff4012bc668), the reader notification path accesses resp["method"].take(). A server-pushed JSON scalar without an id is treated as a notification, but mutable indexing a scalar JSON value panics. A malicious or compromised Electrum server (or an attacker able to alter the Electrum connection) can therefore cause client/wallet availability loss in a release build.

Reproduction

  1. Build the client in release mode.
  2. Negotiate protocol version 1.4.
  3. While a request is in flight, send this line:
5

Observed:

serde_json panic: cannot access key "method" in JSON number

A null notification was tested as a negative control and the subsequent ping completed normally.

Source

Reported source location: raw_client.rs lines 764–773 (in the affected revision).

Suggested hardening

  • Require a JSON object before reading notification fields, or use non-panicking accessors such as get("method").
  • Return a normal protocol/parse error for invalid notification shapes.
  • Add regression tests for scalar, array, and null notifications.

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 を短くまとめたダイジェスト。