llamaCVEVulnerability Intelligence
/
Advisory · GitHub · npm · tiny-secp256k1

GHSA-RM9W-7FV8-3RHX

Unchecked recovery IDs trigger traps that leave backend stack state damaged

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

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer 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 2.2.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-RM9W-7FV8-3RHX divulgada
Remediación Parche 2.2.5 tiny-secp256k1 · 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

The WebAssembly build of `tiny-secp256k1` does not validate the recovery ID at runtime before calling its native public-key recovery function. An out-of-range ID can reach a native argument check and trigger a WASM trap.

The generated `@bitcoin-js/tiny-secp256k1-asmjs` backend has the same missing validation and translated trap path.

The trap bypasses shadow-stack cleanup. Repeated calls with invalid IDs can exhaust the stack of the shared module instance and cause later valid signing or verification calls to fail.

Details

`recover(hash, signature, recoveryId)` uses a TypeScript type for recovery IDs, but types do not enforce values at runtime. A JavaScript caller can pass 4 even though valid IDs are integers from 0 through 3.

The wrapper checks the hash and signature but does not reject that ID. Given otherwise suitable inputs, it reaches libsecp256k1's argument check. The check traps inside WASM rather than returning normally. The interrupted frame does not restore the shadow-stack pointer.

The WASM loader shares one instance. Catching the exception outside the call does not restore its stack pointer, so the damage accumulates across calls.

Static inspection of the integrity-checked asm.js packages shows that recovery decrements its translated mutable stack pointer before the invalid-ID argument check. The failure callback calls `wasm2js_trap()` before the restoration code can run. WASM exhaustion thresholds and downstream effects have not been measured for asm.js.

Fractional IDs and non-finite values also need explicit rejection: numeric coercion at the WASM boundary is not a substitute for validating an integer in the allowed range.

Example

With tiny-secp256k1 2.2.4 in an isolated process:

import * as ecc from "tiny-secp256k1";

const hash = new Uint8Array(32).fill(7);
const privateKey = new Uint8Array(32);
privateKey[31] = 1;
const { signature, recoveryId } = ecc.signRecoverable(hash, privateKey);
ecc.recover(hash, signature, recoveryId, true); // Valid control succeeds.

try {
  ecc.recover(hash, signature, 4, true);
} catch (error) {
  console.log(error.name, error.message); // RuntimeError: unreachable
}

This single invalid call and successful valid control were confirmed against npm 2.2.4 on Node 20.19.4. They establish the trap, not stack exhaustion. The reporter separately observed exhaustion after repeated invalid-ID calls on the tested WASM binary. The threshold depends on the binary and stack layout. The example uses a public test key and belongs in an isolated process.

Impact

An application that forwards attacker-controlled recovery IDs can lose the use of its shared cryptographic module. Later valid operations can fail until the instance is replaced. A network attacker requires an application path that exposes this parameter; the library does not receive network requests by itself.

This report establishes a stateful denial-of-service path. It does not establish private-key disclosure or a valid recovered key for an invalid recovery ID.

Affected versions
  • `tiny-secp256k1`: 2.2.0 through 2.2.4.
  • `@bitcoin-js/tiny-secp256k1-asmjs`: 2.2.2 through 2.2.4, based on the generated code's invalid-ID trap and skipped-restoration path.

The `recover` API first appears in tiny-secp256k1 2.2.0, so earlier releases are not included in this issue.

Remediation and workarounds

Upgrade `tiny-secp256k1` and `@bitcoin-js/tiny-secp256k1-asmjs`, as applicable, to 2.2.5 or a later patched release. The JavaScript wrapper now requires `Number.isInteger(recoveryId)` and a value between 0 and 3 before calling the backend. The native wrapper also rejects out-of-range IDs by returning an error code before calling libsecp256k1. JavaScript handles that code after the backend call returns normally.

Applications can apply the runtime integer and range check before calling `recover`. Restart a worker or replace the module instance if it has already processed invalid IDs through this path.

References
  • tiny-secp256k1 2.2.4 on npm https://www.npmjs.com/package/tiny-secp256k1/v/2.2.4
  • tiny-secp256k1 asm.js 2.2.4 on npm https://www.npmjs.com/package/@bitcoin-js/tiny-secp256k1-asmjs/v/2.2.4
  • Fix: Validate recovery IDs before entering the backend https://github.com/bitcoinjs/tiny-secp256k1/commit/feacfcc4b1d3810ca2e3975d1b2d5469fad062e3
Versiones

Rangos afectados

Afectada Corregida Última
tiny-secp256k1≥ 2.2.0 ≤ 2.2.4
@bitcoin-js/tiny-secp256k1-asmjs≥ 2.2.2 ≤ 2.2.4
2.2.0
2.2.2
2.2.4
2.2.5
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
npmtiny-secp256k1
Corregida 2.2.5 0 d 2.2.5 no afectada
Versiones corregidas2.2.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/tiny-secp256k1/security/advisories/GHSA-rm9w-7fv8-3rhx

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