On this page (7 sections)

bitcoinjs-lib, a widely used JavaScript Bitcoin library for Node.js and browsers, has a critical flaw in how it validates a block's merkle root. A malicious peer can hand your software a block whose transaction list was altered, while the merkle root, block header, proof of work and block id all still look correct. The issue is tracked as CVE-2026-107846 and fixed in 5.2.1, 6.1.8 and 7.0.2.

If you run a block explorer, an exchange indexer, an SPV-style wallet or any service that parses blocks received from peers with this library, you should check your version today. Apps that only build and sign transactions are far less likely to touch the affected code path.

What happened

The maintainers published a GitHub security advisory describing a gap in block integrity checking. The advisory is titled around undetected merkle node duplication: the library can recompute a merkle root from a transaction list and accept it, without noticing that the list was padded with repeated transactions.

The advisory itself says this behavior corresponds to the older, well-known Bitcoin issue CVE-2012-2459. Bitcoin Core has long rejected this case. bitcoinjs-lib did not, until the fixed releases.

This article relies mainly on the vendor advisory and the CVE record. At the time of writing only one independent publisher covers the story, so details beyond the advisory are not independently confirmed.

How the weakness works

A block commits to its transactions through a merkle tree. Transaction hashes are paired and hashed upward level by level until one root remains, and that root sits in the block header. When a level has an odd number of nodes, Bitcoin's scheme hashes the last node with itself to fill the gap.

That padding rule creates an ambiguity. A list that already ends in a repeated transaction can produce exactly the same root as the shorter, honest list. Because the header does not change, the proof of work and the block id do not change either. Bitcoin Core closes the hole by scanning each level for two adjacent identical hashes, flagging the block as mutated and rejecting it with the reason bad-txns-duplicate, per the advisory.

According to the advisory, bitcoinjs-lib's fastMerkleRoot function performs the same padding but reports nothing back. Block.calculateMerkleRoot returns the value unchanged, and the internal root check only compares it with the header field. Nothing in the library looked for adjacent duplicate hashes or repeated transaction ids. checkTxRoots, described in the advisory as the library's advertised block integrity gate, inherits that gap. The advisory notes the affected verifier was introduced in 2.3.0, which is why the vulnerable range starts there.

Who is realistically exposed

The CVE record describes the consumers at risk as those that rely on block-root validation, including explorers, exchange indexers and SPV clients. The practical consequences it lists are:

  • A duplicated transaction can be processed twice, which can corrupt balances, history or deposit logic downstream.
  • A service can blacklist the shared block hash after seeing the forged variant, then reject the honest block that carries the same hash.
  • Any logic that treats a passing root check as proof the transaction list is the one the miner committed to can be misled.

Exposure depends on how you use the library. If your code never calls checkTxRoots or the older Block.checkMerkleRoot, and you only parse blocks you obtained from a source you already trust, your risk is lower. If you accept blocks from arbitrary peers, treat the library's check as unreliable until you update.

How to check if you are affected

Start with the installed version, including copies pulled in by other packages. The command below is read-only. Run it in your project directory and look at every bitcoinjs-lib version it prints, including nested ones.

List every installed copy of bitcoinjs-lib in a Node.js projectShell
npm ls bitcoinjs-lib

Compare the result with the fixed releases. Anything below 5.2.1 on the 5.x line (and 2.3.0 or later), below 6.1.8 on the 6.x line, or below 7.0.2 on the 7.x line is in the affected range. Then see whether your own code uses the affected checks. This search through your source is read-only and shows where block validation happens.

Find block-root validation calls in your own source (run from the project root)Shell
grep -rn --include=*.js --include=*.ts -e checkTxRoots -e checkMerkleRoot src/

Adjust the directory if your code does not live in src/. Any hit is a place where a forged transaction list could pass as valid on a vulnerable version.

What to do now

  1. Run npm ls bitcoinjs-lib in every project and service, and record each version found, including transitive dependencies.
  2. Upgrade to the fixed release on your major line: 5.2.1, 6.1.8 or 7.0.2 (or newer).
  3. Check your lockfile after updating so no older nested copy is still resolved.
  4. Rebuild, run your tests and redeploy the services that parse peer blocks, such as indexers and explorers.
  5. If you cannot upgrade immediately, add your own check that rejects any block whose transaction list contains repeated transaction ids, mirroring what Bitcoin Core does.
  6. Review recent data from the affected period for double-counted transactions or blocks that were wrongly rejected or blacklisted.

The example below installs the fixed version for the 6.x line. Use 5.2.1 or 7.0.2 instead if you are on those lines.

Caution. Upgrading a library used by a live indexer or wallet service means a rebuild and redeploy. Test against known blocks in a staging environment first, and do not skip the lockfile review, because a nested older copy can keep the vulnerable code in production.
Install the fixed release on the 6.x line, then confirm the version (run in the project directory)Shell
npm install bitcoinjs-lib@6.1.8
npm ls bitcoinjs-lib

The fixes are visible in the project's commits, for example this one, if you want to review the change before upgrading.

Detection and ongoing monitoring

No exploitation has been reported, so there is no confirmed indicator to hunt for. You can still look for the symptoms the advisory describes. Search your stored blocks for transaction lists that contain the same transaction id twice in a row, and compare the transaction count of a stored block with the count reported by a trusted full node for the same block id. A mismatch for an identical id is a red flag.

Add dependency auditing to your build so a vulnerable range is caught early. Running npm audit in continuous integration will surface advisories like this one. For the web-facing side of a wallet or explorer, a regular outside-in check of your site with a free malware scanner and monitoring of certificates and headers helps catch unrelated problems, though it cannot see inside your Node.js dependencies.

For broader habits that reduce supply chain risk, see our guide to small business website security.

Timeline

Dates as given in the sources
DateEvent
2026-10-26GitHub advisory GHSA-8vv3-6qpc-gpw6 published
2026-11-04CVE-2026-107846 published
2026-11-10GitHub advisory last updated

Sources

This article is based on the public sources below. Details can change as vendors and researchers publish more; check the original advisories before acting on version numbers.

  1. CVE-2026-107846 - GitHub Advisory Databasegithub.com
  • bitcoinjs-lib
  • npm
  • merkle tree
  • CVE-2026-107846
  • Bitcoin
  • supply chain