BTCSignPSBT panics with nil pointer dereference when a non-Taproot input lacks non_witness_utxo
まだ誰も着手していません。
評価
調査の方向性
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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
chaitin/agent-compose#770 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
kind/bug
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
kubernetes-sigs/vsphere-csi-driver#4351 ·
メンテナーはふだん 1 日以内に返信
-
component/gpu-kubelet-plugin component/helm needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
kubernetes-sigs/dra-driver-nvidia-gpu#1559 ·
メンテナーはふだん 1 日以内に返信
-
workflow: redundant goroutine in scheduleRetry対応中かも @moodbased が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信