Overview
Transaction malleability was a long-standing vulnerability in Bitcoin where a third party (or even the transaction signer) could modify the signature data in a transaction without invalidating it, causing the transaction ID to change. While the modified transaction would still transfer the same amount to the same recipient, the changed TXID broke any dependent transactions that referenced the original ID.
How It Worked
In pre-SegWit transactions, the signature (scriptSig) was included in the data that was hashed to produce the TXID. Because ECDSA signatures have multiple valid encodings for the same authorization, the signature bytes could be altered while remaining cryptographically valid:
Original Transaction:
TXID: abc123...
scriptSig: [signature_A] <-- Can be modified
Outputs: 1 BTC to Alice
Malleated Transaction:
TXID: def456... <-- Different TXID!
scriptSig: [signature_A'] <-- Different encoding, still valid
Outputs: 1 BTC to Alice <-- Same payment
Why It Was a Problem
- Transaction chaining: Any transaction that referenced the original TXID as an input would become invalid if the malleated version was mined instead.
- Exchange exploits: Attackers could withdraw from exchanges, malleate the TXID, and claim the withdrawal never arrived — leading the exchange to re-send funds.
- Lightning Network impossibility: Payment channels require reliable chains of pre-signed transactions. Malleability made this unsafe, as a malleated funding transaction would invalidate all subsequent commitment transactions.
The SegWit Fix
SegWit solved transaction malleability by moving witness data (signatures) to a separate structure that is not included in the TXID calculation:
Pre-SegWit: TXID = Hash(version + inputs + scriptSig + outputs + locktime)
^^^^^^^^^^
Malleable!
SegWit: TXID = Hash(version + inputs + outputs + locktime)
Witness data committed separately (not in TXID)
This fix was the critical prerequisite for building the Lightning Network, which relies on chains of pre-signed transactions with predictable TXIDs.
Historical Significance
The Mt. Gox exchange famously cited transaction malleability as a factor in its collapse in 2014, though subsequent investigations revealed that malleability was not the primary cause of their losses. Nevertheless, the incident brought widespread attention to the vulnerability and motivated the development of SegWit.