Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

BTCSignPSBT panics with nil pointer dereference when a non-Taproot input lacks non_witness_utxo

オープン
#186 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

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

調査の方向性

api/firmware/testdata/btc-transaction-test-vectors.json の locktime-zero ベクターから始め、issue に記載されている呼び出しを再現してください。api/firmware/btc.go の PREVTX_INIT、PREVTX_INPUT、PREVTX_OUTPUT ハンドラーを読み、その後 psbt.go:456 周辺の NonWitnessUtxo へのアクセスを調べてください。範囲外の outpoint を含む不正な入力が panic を発生させるのではなく、エラーを返すようになれば完了です。

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

説明

Device.BTCSignPSBT panics instead of returning an error when a PSBT input has witness_utxo but no non_witness_utxo and the firmware requests the previous transaction.

Reproduction (master 8bccc8b7c1ffeb1ecc984a2746411f6decef3abb, simulators v9.19.0 and v9.27.1): take the locktime-zero vector from api/firmware/testdata/btc-transaction-test-vectors.json, set packet.Inputs[0].NonWitnessUtxo = nil, call BTCSignPSBT(BTCCoin_TBTC, packet, nil).

panic: runtime error: invalid memory address or nil pointer dereference
  (*Device).nonAtomicBTCSign  api/firmware/btc.go:493   (prevtx.Version)
  (*Device).BTCSign            api/firmware/btc.go:580
  (*Device).BTCSignPSBT        api/firmware/psbt.go:622

newBTCTxFromPSBT leaves BTCTxInput.PrevTx nil in this case, and the PREVTX_INIT / PREVTX_INPUT / PREVTX_OUTPUT handlers at btc.go:487-514 dereference it without a check. BTCSignNeedsNonWitnessUTXOs correctly returns true beforehand, so this is only hit by callers that skip that helper, but a returned error would be friendlier than a panic. A similar unchecked index exists at psbt.go:456 (NonWitnessUtxo.TxOut[prevOutPoint.Index]) for a malformed PSBT.

No security impact: the device has not signed anything at that point, and it verifies the streamed prevtx hash and amounts before signing.

Suggested fix: return an error from the three handlers when PrevTx == nil, and bounds-check the outpoint index. A community fork carrying such a patch exists at 4xvgal/bitbox02-api-go@44800a0304155385374763a27457cc4387aaacfd.

主要言語
Go
スター
7
フォーク
23
平均マージ
9日 10時間
マージ済み PR(30日)
4

環境構築

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

はじめの一歩

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

似ている issue

Go の issue をもっと見る

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

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