AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 51 Bitcoin

Merge bitcoin/bitcoin#36076: psbt: preserve sighash type when merging inputs

Public commit record

What the developer wrote

Authored by Ava Chow

91/100 · Strong
Merge bitcoin/bitcoin#36076: psbt: preserve sighash type when merging inputs

ea785a31f783e67adc9b4f0c4a8e54acd2794904 psbt: preserve sighash type when merging inputs (Thomas)

Pull request description:

`PSBTInput::Merge` copies every optional input field from the other input when it is absent locally, except `PSBT_IN_SIGHASH_TYPE`. So `combinepsbt` silently drops the sighash type whenever the first PSBT does not carry it, making the result depend on the argument order.

The field is what lets finalizers enforce the sighash type of existing signatures (BIP 174). When it is lost, `FinalizePSBT` falls back to the default type (`SIGHASH_ALL`, or `SIGHASH_DEFAULT` for taproot inputs), rejects signatures made with any other type as a sighash mismatch, and the PSBT can no longer be finalized. Combining a PSBT signed with `ALL|ANYONECANPAY` after a merely updated copy of the same PSBT reproduces this: `finalizepsbt` reports it as incomplete, while the reverse order finalizes and broadcasts fine.

Merge the sighash type like the other optional fields, keeping the one already present, and test both combine orders.

ACKs for top commit:
achow101:
ACK ea785a31f783e67adc9b4f0c4a8e54acd2794904
winterrdog:
Re-ACK ea785a31f783e67adc9b4f0c4a8e54acd2794904
vicjuma:
ACK ea785a31f783e67adc9b4f0c4a8e54acd2794904
rkrux:
lgtm ACK ea785a31f783e67adc9b4f0c4a8e54acd2794904

Tree-SHA512: 3487368509926c3dc0218dfab2e08273676504ad5ed4635e12e56c0484bda4cd94f4ba6f2df26ee4a902ce9a274546f727f8eca4a62eb0add3a700b2141eb272
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a bug in Bitcoin Core's handling of Partially Signed Bitcoin Transactions (PSBTs). When two PSBTs for the same transaction were combined, the intended signature hash (sighash) type could be silently dropped depending on the order the PSBTs were provided. This could cause a valid, already-signed PSBT to become impossible to finalize, because the finalizer would fall back to a default sighash type and reject the existing signatures. The fix makes the merge behave like other optional fields: keep the local value if present, otherwise copy it from the other PSBT. A new test verifies both argument orders now produce the same, finalizable result.

Recommended action

No immediate action beyond applying the fix. Users who relied on combinepsbt with PSBTs carrying non-default sighash types should upgrade and, if necessary, re-combine affected PSBTs. The bug is a correctness/data-integrity issue rather than a direct theft vector.

Security signals we found

01

Data-loss bug in PSBT merge logic

02

Order-dependent behavior in combinepsbt

03

Sighash type enforcement bypassed during finalization

04

Functional test added for both combine orders

Risk score

Why this scored 51/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 10/15
Affected reach 7/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.