Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#186 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu với vector locktime-zero trong api/firmware/testdata/btc-transaction-test-vectors.json và tái hiện lệnh gọi được mô tả trong issue. Đọc các handler PREVTX_INIT, PREVTX_INPUT và PREVTX_OUTPUT trong api/firmware/btc.go, sau đó kiểm tra quyền truy cập NonWitnessUtxo quanh psbt.go:456. Hoàn tất khi các đầu vào không hợp lệ trả về lỗi, bao gồm cả outpoint nằm ngoài phạm vi, thay vì gây ra panic.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Go
Star
7
Fork
23
Merge trung bình
9 ngày 10 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.