Bitcoinjs-lib, a library used to construct Bitcoin purposes, has patched two bugs that may make software program understate the miner payment a sound transaction would pay if broadcast and accepted.
The Oct. 26 safety disclosures establish fixes in variations 5.2.2, 6.1.9 and seven.0.4 for the corresponding launch traces.
The affected format is {a partially} signed Bitcoin transaction (PSBT), and BIP 174 defines it as a approach to move transaction info and signatures between shoppers. Signing, combining signatures, finalizing inputs, and extracting the transaction are separate features, even when one utility performs a number of of them.
The chance considerations purposes that import these packages and belief bitcoinjs-lib’s payment calculation or excessive-fee safeguard with out independently checking the outputs being spent. Maintainers have to overview their dependency model and the way they validate imported PSBTs.
Why legitimate signatures can accompany deceptive charges
A Bitcoin transaction’s payment is the distinction between the worth of its inputs and its outputs, so understating an enter makes the calculated payment look smaller.
Within the first flaw, signing and payment accounting can use completely different values for a similar enter. Signing makes use of the complete earlier transaction, whereas payment accounting prefers a conflicting file containing a smaller worth. In consequence, the susceptible software program can authorize the actual transaction whereas evaluating the unsuitable payment.
The advisory describes an indication on bitcoinjs-lib 7.0.1 through which the precise payment was 900,000,000 satoshi, however the library reported 200 satoshi. The signature verified, and extraction returned with out the default fee-rate warning.
The second advisory describes finalized inputs with each input-value information lacking. The calculator counts these inputs as zero, and an already-signed PSBT imported from one other social gathering can attain this calculation without having one other signing operation.
Its hypothetical instance has a real payment of 91,000 satoshi however a reported payment of 1,000 satoshi. Finalized scripts and signatures alone don’t set up the lacking enter’s worth.
Precise loss requires a licensed, legitimate transaction to be broadcast and accepted by the community. These defects don’t create signatures, and extra worth turns into a miner payment.
For conflicting information, affected releases are 5.2.0 by 5.2.1, 6.0.0 by 6.1.8 together with 6.1.0-rc.0, and seven.0.0-rc.0 by 7.0.3. The missing-record flaw impacts the identical v6 and v7 ranges, plus 5.1.0 by 5.2.1 within the v5 line.
The remediation offers signing and accounting a shared methodology for resolving earlier outputs, rejects conflicting values or scripts, and requires an quantity for each enter throughout payment calculation. It additionally clears cached charges and extracted transactions after related metadata modifications or combos.
Maintainers unable to improve ought to independently confirm referenced output values. Reject conflicting information earlier than signing or trusting charges, and confirm each enter worth earlier than trusting charges or extracting a transaction.