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

`Psbt::sign` panics on `non_witness_utxo` with out-of-range vout (upstream fix pending in bitcoin 0.32.x)

Abierto
#554 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust
Área
cryptography

Línea de trabajo

Comienza con bitcoin-0.32.8/src/psbt/mod.rs alrededor de spend_utxo y los puntos de entrada Psbt::sign y sighash_ecdsa. Compara el fix upstream rust-bitcoin#5500 y decide si se debe hacer backport o actualizar la release de bitcoin. Se considera terminado cuando las entradas non_witness_utxo malformadas devuelven un error en lugar de provocar un panic, con una prueba de regresión que cubra un vout fuera de rango.

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

Descripción

bug

Describe the bug

bitcoin::Psbt::spend_utxo in the bitcoin 0.32.x line indexes non_witness_utxo.output[vout] without a bounds check, so Psbt::sign (and sighash_ecdsa) panic on a PSBT input whose non_witness_utxo has fewer outputs than previous_output.vout (e.g. a wrong or truncated previous transaction). This was fixed upstream on master in rust-bitcoin/rust-bitcoin#5500 (returns MissingSpendUtxo instead), but the fix is not in the 0.32.x branches as of 0.32.8.

Wallet::sign_with_signers is not affected, since it validates non_witness_utxo against the outpoint before signing. However, since #505 the recommended flow in docs and examples is to call bitcoin::Psbt::sign directly, which does reach the panic when given a malformed PSBT.

This issue tracks picking up the upstream fix (backport to 0.32.x or bump to a release that includes it).

This issue was found by AI.

To Reproduce

// psbt built by the wallet with a single wpkh input, then corrupted:
let mut psbt = builder.finish().unwrap();
psbt.inputs[0].witness_utxo = None;
psbt.inputs[0].non_witness_utxo = Some(Transaction {
    version: transaction::Version::TWO,
    lock_time: absolute::LockTime::ZERO,
    input: vec![],
    output: vec![], // no outputs
});
psbt.sign(&xpriv, wallet.secp_ctx()); // panics: index out of bounds at bitcoin-0.32.8/src/psbt/mod.rs:626

Expected behavior

Signing a PSBT with an inconsistent non_witness_utxo should return an error rather than panic.

Build environment

  • BDK tag/commit: 6fc68462 (master), bitcoin 0.32.8

Which backend(s) are relevant (if any)?

  • None / not backend-related (e.g. bdk_chain, bdk_core)

Is this blocking production use?

  • No
Lenguaje dominante
Rust
Estrellas
61
Forks
116
Merge medio
7 h 29 min
PR fusionados (30 d)
6

Preparar el entorno

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.

Más de bitcoindevkit/bdk_wallet

Todos los issues de bitcoindevkit/bdk_wallet

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.