Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#186 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
api

Línea de trabajo

Empieza con el vector locktime-zero en api/firmware/testdata/btc-transaction-test-vectors.json y reproduce la llamada descrita en el issue. Lee los handlers PREVTX_INIT, PREVTX_INPUT y PREVTX_OUTPUT en api/firmware/btc.go; después, inspecciona el acceso a NonWitnessUtxo alrededor de psbt.go:456. La tarea estará terminada cuando las entradas malformadas devuelvan errores, incluido un outpoint fuera de rango, en lugar de provocar un panic.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
7
Forks
23
Merge medio
9 d 10 h
PR fusionados (30 d)
4

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.