VulnWatch by ve1ve2
medium 6.3 EPSS 0.44%

GHSA-hj9c-qx2w-g7mh / CVE-2026-107853: tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak

Source:
GitHub Security Advisories
Published:
Fetched:
Updated:
Affects:
tiny-secp256k1

https://github.com/advisories/GHSA-hj9c-qx2w-g7mh ↗

ghsanpmCWE-252

tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak ### Summary The three-argument `xOnlyPointAddTweakCheck` path ignores the wasm failure return and compares an unchanged input buffer. When the tweak result is the point at infinity, this stale-buffer comparison can return `true` for an invalid derivation. ### Details `xOnlyPointAddTweakCheck` in `index.ts` has two code paths. The path taken when the caller omits `tweakParity` discards the return value of the wasm call and compares whatever the shared input buffer holds. ```ts try { X_ONLY_PUBLIC_KEY_INPUT.set(point); X_ONLY_PUBLIC_KEY_INPUT2.set(resultToCheck); TWEAK_INPUT.set(tweak); if (hasParity) { return wasm.xOnlyPointAddTweakCheck(tweakParity) === 1; } else { wasm.xOnlyPointAddTweak(); const newKey = X_ONLY_PUBLIC_KEY_INPUT.slice( 0, validate.X_ONLY_PUBLIC_KEY_SIZE ); return compare(newKey, resultToCheck) === 0; } ``` `x_only_point_add_tweak` in `lib.rs` returns `-1` and leaves `X_ONLY_PUBLIC_KEY_INPUT` untouched when the tweak addition fails. ```rust pub extern "C" fn x_only_point_add_tweak() -> i32 { unsafe { let mut xonly_pk = jstry!(x_only_pubkey_parse(X_ONLY_PUBLIC_KEY_INPUT.as_ptr()), 0); let mut pubkey = PublicKey::new(); if secp256k1_xonly_pubkey_tweak_add( get_context(), &mut pubkey, &xonly_pk, TWEAK_INPUT.as_ptr(), ) != 1 { // infinity point return -1; } ``` The buffer still holds `point`, which the caller wrote immediately before the call. `newKey` therefore equals `point`, and the comparison against `resultToCheck` succeeds whenever the caller passes `resultToCheck` equal to `point`. `secp256k1_xonly_pubkey_tweak_add` in upstream `main_impl.h` returns 0 only when the internal key fails to load or the tweak helper fails. ```c if (!secp256k1_xonly_pubkey_load(ctx, &pk, internal_pubkey) || !secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32)) { return 0; } ``` The helper in `secp256k1.c` fails on scalar overflow or on an infinite result. ```c static int secp256k1_ec_pubkey_tweak_add_helper(secp256k1_ge *p, const unsigned char *tweak32) { secp256k1_scalar term; int overflow = 0; secp256k1_scalar_set_b32(&term, tweak32, &overflow); return !overflow && secp256k1_eckey_pubkey_tweak_add(p, &term); } ``` `validateTweak` in `validate.ts` already rejects a tweak at or above the group order, so overflow is excluded and the only remaining cause is `lift_x(point) + tweak * G` reaching the point at infinity. The parity path is correct for the same input. `secp256k1_xonly_pubkey_tweak_add_check` returns 0 in that case. The two documented forms of the same check disagree. `xOnlyPointAddTweak` also disagrees with the check, returning `null` for the exact inputs the check accepts. The condition is untested. `schnorr.js` skips every `xOnlyPointAddTweakCheck` assertion for the infinity vectors present in its own fixtures. Affected packages: npm:@bitcoin-js/tiny-secp256k1-asmjs, npm:tiny-secp256k1 Patched: tiny-secp256k1 2.2.5, @bitcoin-js/tiny-secp256k1-asmjs 2.2.5

Linked vulnerabilities (2)

CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak

CWE: CWE-252Aliases: CVE-2026-107853
CVE-2026-107853 medium 6.3 EPSS 0.44% (p39) NVDCVE.orgGHSA
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak

CWE: CWE-252Aliases: GHSA-hj9c-qx2w-g7mhNVD: Received

Also reported by (1)