Two bitcoinjs-lib bugs can make Bitcoin apps underestimate transaction fees

The flaws affect applications that rely on the library’s fee calculations or excessive-fee checks, potentially obscuring the true cost of a transaction.

Two bitcoinjs-lib bugs can make Bitcoin apps underestimate transaction fees https://kaboompics.com/

Two flaws in bitcoinjs-lib can cause applications to miscalculate a Bitcoin transaction’s fee, potentially leading a user to approve a transaction that pays miners far more than the app indicates. The risk concerns software using affected library versions that trusts the library’s fee calculation or excessive-fee safeguard without independently checking the values of the outputs being spent.

A transaction fee is the difference between the value of its inputs and outputs. When software counts an input as worth less than it is, it can show a lower fee than the transaction actually carries. The flaws do not create signatures or take funds on their own; a valid, authorized transaction still has to be broadcast and accepted by the network, and any excess value is paid to miners as a fee.

How the fee checks fail

In one flaw, signing and fee calculation may rely on different records for the same input. Signing uses the full previous transaction, while fee accounting may instead use a conflicting record that assigns the input a lower value. In a bitcoinjs-lib 7.0.1 demonstration, the actual fee was 900,000,000 satoshis, but the library reported 200 satoshis. The signature verified, and extracting the transaction did not trigger the default fee-rate warning.

The other flaw concerns finalized inputs for which both records of the previous output’s value are missing. The calculator counts those inputs as zero, allowing an already-signed PSBT imported from another party to be miscalculated without further signing. In a hypothetical example, a true fee of 91,000 satoshis was reported as 1,000. A finalized script and signature alone do not establish the value of a missing input.

Affected versions and safeguards

The conflicting-record flaw affects versions 5.2.0–5.2.1, 6.0.0–6.1.8—including 6.1.0-rc.0—and 7.0.0-rc.0–7.0.3. The missing-record flaw affects 5.1.0–5.2.1, along with the same listed v6 and v7 ranges. The advisory does not identify specific affected apps or state a fixed release number.

The remediation uses a shared method for signing and fee accounting to resolve previous outputs, rejects conflicting values or scripts, and requires an amount for every input during fee calculation. It also clears cached fees and extracted transactions when relevant metadata changes or PSBTs are combined. Developers who cannot upgrade should verify every referenced output value independently and reject conflicting records before signing or relying on a fee estimate.

This report draws on information from cryptonews.net.

Editorial checks passed Facts, figures and quotes checked against 1 source

Add Bitcoin Altcoin & Crypto Coin News Analysis as a preferred source on Google

Related stories