BTCSignPSBT panics with nil pointer dereference when a non-Taproot input lacks non_witness_utxo
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 76/100
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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
copilot-api domain:platform go
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
docs: clarify gh api -f vs -F and @-file expansion in the gh skillPosiblemente ocupada @MatiasOlivera la tomó hoy. Abiertoenhancement
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
cli/cli#14701 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
aws/aws-advanced-go-wrapper#612 ·
-
Say in the changelog that the text-index update cannot be rolled backPosiblemente ocupada @praetorianer777 la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
praetorianer777/GoTome#275 ·
Los mantenedores suelen responder en 1 día