llamaCVEVulnerability Intelligence
/
Advisory · GitHub · npm · bitcoinjs-lib

GHSA-4VM8-79JJ-J6W4

Proof-of-work verification accepts invalid compact targets

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS 3.1
7.5
Alta
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche2 versionesPrimer parche el mismo día de la divulgación
Exposición25 dDesde la divulgación, 26 oct 2026, 1:40 p. m.
Detección23 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 7.0.5
Monitoreo
Detectada +1
26 oct 26
18 nov 26
21 nov 26
26 oct 26
2 nov 26
8 nov 26
14 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-4VM8-79JJ-J6W4 divulgada · CVSS 7.5 (GitHub)
Remediación Parche 7.0.5 bitcoinjs-lib · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

`Block.checkProofOfWork()` in `bitcoinjs-lib` compares a header hash against the magnitude returned by `Block.calculateTarget()` without first validating the compact target in the header's `nBits` field. It can therefore return `true` for a header whose proof-of-work target is invalid under Bitcoin's rules.

Impact

An attacker who can supply headers to an application using this method may cause it to accept invalid headers as having valid proof of work. This affects applications that rely on the result without independently validating the compact target and the applicable consensus rules. The resulting impact depends on what the application trusts or authorizes based on those headers.

Details

The compact format has an exponent, a mantissa and a sign bit. The conversion masks off the sign bit, so `checkProofOfWork()` treats a negative target as a positive magnitude instead of rejecting it.

Overflow handling depends on the version:

  • Versions 2.2.0 and 2.3.0 use indexed Buffer writes. V7 uses indexed Uint8Array writes. Out-of-range writes are discarded, so an overflowing target can become a large 256-bit value that passes the hash comparison. For example, `0x2101ffff` is invalid because its target exceeds 256 bits, but truncation leaves a value starting with `ffff`.
  • V3 through v6 use checked Buffer writes. Those versions throw for that overflow example rather than accepting it. They remain affected by the missing negative-target check for compact encodings that fit their write bounds.

These are version-dependent manifestations of the same missing compact-target validation before the proof-of-work comparison.

Affected versions

The affected API was introduced in 2.2.0. Inspection of the published package contents confirms the following affected releases:

| Version line | Affected releases |
| --- | --- |
| v2 through v4 | 2.2.0 through 4.0.5 |
| v5 | 5.0.0 through 5.2.2 |
| v6 | 6.0.0 through 6.1.9, including 6.1.0-rc.0 |
| v7 | 7.0.0-rc.0 through 7.0.4 |

Patched npm releases are 5.2.3, 6.1.10 and 7.0.5. Versions below v5 have no backport; affected users must upgrade to a fixed version on one of those lines.

Reproduction

On the published `bitcoinjs-lib@7.0.4`, this CommonJS example prints `true` for both invalid targets:

const { Block } = require('bitcoinjs-lib');

for (const bits of [0x20ffffff, 0x2101ffff]) {
  const block = new Block();
  block.version = 1;
  block.prevHash = new Uint8Array(32);
  block.merkleRoot = new Uint8Array(32);
  block.timestamp = 0;
  block.bits = bits;
  block.nonce = 0;

  const parsed = Block.fromHex(block.toHex(true));
  console.log(bits.toString(16), parsed.checkProofOfWork());
}

The first target is negative. The second overflows 256 bits. Both must be rejected regardless of the header hash. This example uses the actual serialized headers and their computed hashes.

Remediation and workaround

Upgrade to bitcoinjs-lib 5.2.3, 6.1.10 or 7.0.5, or a later patched release on the corresponding line. The fix rejects negative, zero and overflowing compact targets before comparing the header hash, using the compact-target validity rules in Bitcoin Core. Applications that cannot upgrade must perform this validation independently before relying on `checkProofOfWork()`.

Applications must also enforce their network's proof-of-work limit and the difficulty required at that point in the chain. The method has no network or chain context, so even a corrected `true` result is not a complete validation of a header or chain.

References
  • Bitcoin Core compact-target decoding https://github.com/bitcoin/bitcoin/blob/master/src/arith_uint256.cpp
  • Bitcoin Core proof-of-work validation https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp
  • Fix: Reject invalid compact proof-of-work targets https://github.com/bitcoinjs/bitcoinjs-lib/commit/0486f08d475c84c258e40703bf83a598caa41a4b

Reported by ARSB (@ARSB1).

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:N
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
10.0/ 10Muy alto
Vector 10.0 (muy fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
bitcoinjs-lib≥ 2.2.0 < 5.0.0
bitcoinjs-lib≥ 5.0.0 ≤ 5.2.2
bitcoinjs-lib≥ 6.0.0 ≤ 6.1.9
bitcoinjs-lib≥ 7.0.0-rc.0 ≤ 7.0.4
2.2.0
5.0.0
5.2.2
6.0.0
6.1.9
7.0.0-rc.0
7.0.4
7.0.5
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
npmbitcoinjs-lib
Corregida 7.0.5 0 d 7.0.5 no afectada
Versiones corregidas5.0.07.0.5
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/bitcoinjs/bitcoinjs-lib/security/advisories/GHSA-4vm8-79jj-j6w4

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.