GHSA-4MFV-5394-26C7
Conflicting PSBT UTXO records can understate transaction fees
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 5.2.2 | bitcoinjs-lib · -13 d desde divulgación | |
| Remediación | Parche 6.1.9 | bitcoinjs-lib · -13 d desde divulgación | |
| Remediación | Parche 7.0.4 | bitcoinjs-lib · -13 d desde divulgación | |
| Divulgación | Publicada | GHSA-4MFV-5394-26C7 divulgada | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
In affected versions of `bitcoinjs-lib`, a PSBT input can contain conflicting `nonWitnessUtxo` and `witnessUtxo` records. Signing and fee accounting can select different records for the same input.
An application that trusts the reported fee can sign or extract a valid transaction that pays much more to miners than the application expects. The built-in `maximumFeeRate` check can also use the understated fee.
Details
`nonWitnessUtxo` contains the full previous transaction. `witnessUtxo` contains an output script and value. When both are supplied, affected signing code prefers `nonWitnessUtxo` and verifies its transaction hash against the input's outpoint. Fee accounting in `inputFinalizeGetAmts` instead prefers `witnessUtxo` without checking that its script and value agree with the referenced output:
if (input.witnessUtxo) {
inputAmount += input.witnessUtxo.value;
} else if (input.nonWitnessUtxo) {
// Read the referenced output from the previous transaction.
}A PSBT source can supply a real previous transaction together with a `witnessUtxo` value smaller than the real value. The signer uses the real output while fee calculation uses the smaller value. Other script and input-classification helpers also resolve the two fields inconsistently.
The conflicting metadata can arrive with an imported PSBT or through an update or combine operation. Changing this metadata does not change the transaction that an existing signature commits to.
Example
The reporter demonstrated this on bitcoinjs-lib 7.0.1 with an input worth 1,000,000,000 satoshi and an output worth 100,000,000 satoshi. The input's false `witnessUtxo` value was 100,000,200 satoshi.
- The actual transaction fee was 900,000,000 satoshi.
- `getFee()` reported 200 satoshi.
- The signature verified against the real input value.
- `extractTransaction()` returned without the default fee-rate warning.
This demonstrates the accounting and signature mismatch. Confirmation or a downstream loss is not required to reproduce the library behavior.
Impact
Wallets and other applications that sign or extract untrusted PSBTs can approve excessive miner fees if they rely on bitcoinjs-lib's fee calculation or fee-rate guard. Exploitation requires the application to accept the conflicting metadata and proceed without checking the actual prevouts independently.
The excess value becomes a miner fee. The defect does not by itself transfer that value to the PSBT author.
Affected versions
- v5: 5.2.0 through 5.2.1.
- v6: 6.0.0 through 6.1.8, including 6.1.0-rc.0.
- v7: 7.0.0-rc.0 through 7.0.3.
Version 5.2.0 introduced normal support for both UTXO fields on the same input. The earlier v5.1 releases use bip174 1.x, which rejects that combination during normal parsing and input updates.
Fix and workarounds
Upgrade to bitcoinjs-lib 5.2.2, 6.1.9 or 7.0.4 for the corresponding version line.
The fix uses a shared prevout resolver for signing, validation and accounting. It checks the non-witness transaction hash and output index and rejects a witness record whose script or value conflicts with that output. UTXO updates and combine operations also invalidate cached fees and extracted transactions.
Applications that cannot upgrade should verify the referenced outputs independently and reject any disagreement between the two UTXO records before signing or using the reported fee. Do not bypass fee checks as a workaround.
References
- bitcoinjs-lib 5.2.2 on npm
https://www.npmjs.com/package/bitcoinjs-lib/v/5.2.2 - bitcoinjs-lib 6.1.9 on npm
https://www.npmjs.com/package/bitcoinjs-lib/v/6.1.9 - bitcoinjs-lib 7.0.4 on npm
https://www.npmjs.com/package/bitcoinjs-lib/v/7.0.4 - Fix: Resolve PSBT input UTXOs consistently
https://github.com/bitcoinjs/bitcoinjs-lib/commit/202e4043abdf5de63cda3507baa1030eea4e8868
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmbitcoinjs-lib |
Corregida | 5.2.2, 6.1.9, 7.0.4 | -13 d · -13 d · -13 d | 7.0.5 no afectada |
5.2.26.1.97.0.4Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/bitcoinjs/bitcoinjs-lib/security/advisories/GHSA-4mfv-5394-26c7Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
