{"vuln_id":"CVE-2026-107853","aliases":["GHSA-hj9c-qx2w-g7mh"],"description":"tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak","published_at":"2026-11-17T20:17:35.633000Z","modified_at":"2026-11-19T23:00:36.643680Z","first_seen_at":"2026-11-21T19:15:19.422459Z","severity":"medium","severity_source":"nvd","cvss_score":6.3,"cvss_vector":"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","cwe":["CWE-252"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":0.00436,"epss_percentile":0.38682,"nvd_status":"Received","enriched_at":null,"links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2026-107853"},"matched_alias":null,"items":[{"id":10937,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-hj9c-qx2w-g7mh: tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak","summary":"tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak\n\n### Summary\nThe 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.\n\n### Details\n`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.\n\n```ts\ntry {\n    X_ONLY_PUBLIC_KEY_INPUT.set(point);\n    X_ONLY_PUBLIC_KEY_INPUT2.set(resultToCheck);\n    TWEAK_INPUT.set(tweak);\n    if (hasParity) {\n      return wasm.xOnlyPointAddTweakCheck(tweakParity) === 1;\n    } else {\n      wasm.xOnlyPointAddTweak();\n      const newKey = X_ONLY_PUBLIC_KEY_INPUT.slice(\n        0,\n        validate.X_ONLY_PUBLIC_KEY_SIZE\n      );\n      return compare(newKey, resultToCheck) === 0;\n    }\n```\n\n`x_only_point_add_tweak` in `lib.rs` returns `-1` and leaves `X_ONLY_PUBLIC_KEY_INPUT` untouched when the tweak addition fails.\n\n```rust\npub extern \"C\" fn x_only_point_add_tweak() -> i32 {\n    unsafe {\n        let mut xonly_pk = jstry!(x_only_pubkey_parse(X_ONLY_PUBLIC_KEY_INPUT.as_ptr()), 0);\n        let mut pubkey = PublicKey::new();\n        if secp256k1_xonly_pubkey_tweak_add(\n            get_context(),\n            &mut pubkey,\n            &xonly_pk,\n            TWEAK_INPUT.as_ptr(),\n        ) != 1\n        {\n            // infinity point\n            return -1;\n        }\n```\n\nThe 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`.\n\n`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.\n\n```c\nif (!secp256k1_xonly_pubkey_load(ctx, &pk, internal_pubkey)\n    || !secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32)) {\n    return 0;\n}\n```\n\nThe helper in `secp256k1.c` fails on scalar overflow or on an infinite result.\n\n```c\nstatic int secp256k1_ec_pubkey_tweak_add_helper(secp256k1_ge *p, const unsigned char *tweak32) {\n    secp256k1_scalar term;\n    int overflow = 0;\n    secp256k1_scalar_set_b32(&term, tweak32, &overflow);\n    return !overflow && secp256k1_eckey_pubkey_tweak_add(p, &term);\n}\n```\n\n`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.\n\nThe 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.\n\n`xOnlyPointAddTweak` also disagrees with the check, returning `null` for the exact inputs the check accepts.\n\nThe condition is untested. `schnorr.js` skips every `xOnlyPointAddTweakCheck` assertion for the infinity vectors present in its own fixtures.\n\n\n\nAffected: npm:@bitcoin-js/tiny-secp256k1-asmjs, npm:tiny-secp256k1\n\nFixed in: 2.2.5\n\nReferences:\nhttps://github.com/bitcoinjs/tiny-secp256k1/security/advisories/GHSA-hj9c-qx2w-g7mh\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-107853\nhttps://github.com/bitcoinjs/tiny-secp256k1/commit/ba1af1fceea95967a172c6438ed9302730bb7c01\nhttps://github.com/bitcoinjs/tiny-secp256k1\nhttps://github.com/bitcoinjs/tiny-secp256k1/releases/tag/v2.2.5","url":"https://osv.dev/vulnerability/GHSA-hj9c-qx2w-g7mh","published_at":"2026-11-19T22:43:45Z","updated_at":"2026-11-19T23:00:36.643680Z","fetched_at":"2026-11-21T19:15:55.946308Z","severity":"medium","cvss_score":6.3,"epss":0.00436,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"@bitcoin-js/tiny-secp256k1-asmjs","vuln_id":"CVE-2026-107853","vuln_ids":["CVE-2026-107853","GHSA-HJ9C-QX2W-G7MH"],"tags":["osv","npm","fix-available"],"cluster_id":2192,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10937","html":"https://vulnwatch.ve1ve2.com/item/10937"}},{"id":2379,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-hj9c-qx2w-g7mh / CVE-2026-107853: tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak","summary":"tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak\n\n### Summary\nThe 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.\n\n### Details\n`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.\n\n```ts\ntry {\n    X_ONLY_PUBLIC_KEY_INPUT.set(point);\n    X_ONLY_PUBLIC_KEY_INPUT2.set(resultToCheck);\n    TWEAK_INPUT.set(tweak);\n    if (hasParity) {\n      return wasm.xOnlyPointAddTweakCheck(tweakParity) === 1;\n    } else {\n      wasm.xOnlyPointAddTweak();\n      const newKey = X_ONLY_PUBLIC_KEY_INPUT.slice(\n        0,\n        validate.X_ONLY_PUBLIC_KEY_SIZE\n      );\n      return compare(newKey, resultToCheck) === 0;\n    }\n```\n\n`x_only_point_add_tweak` in `lib.rs` returns `-1` and leaves `X_ONLY_PUBLIC_KEY_INPUT` untouched when the tweak addition fails.\n\n```rust\npub extern \"C\" fn x_only_point_add_tweak() -> i32 {\n    unsafe {\n        let mut xonly_pk = jstry!(x_only_pubkey_parse(X_ONLY_PUBLIC_KEY_INPUT.as_ptr()), 0);\n        let mut pubkey = PublicKey::new();\n        if secp256k1_xonly_pubkey_tweak_add(\n            get_context(),\n            &mut pubkey,\n            &xonly_pk,\n            TWEAK_INPUT.as_ptr(),\n        ) != 1\n        {\n            // infinity point\n            return -1;\n        }\n```\n\nThe 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`.\n\n`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.\n\n```c\nif (!secp256k1_xonly_pubkey_load(ctx, &pk, internal_pubkey)\n    || !secp256k1_ec_pubkey_tweak_add_helper(&pk, tweak32)) {\n    return 0;\n}\n```\n\nThe helper in `secp256k1.c` fails on scalar overflow or on an infinite result.\n\n```c\nstatic int secp256k1_ec_pubkey_tweak_add_helper(secp256k1_ge *p, const unsigned char *tweak32) {\n    secp256k1_scalar term;\n    int overflow = 0;\n    secp256k1_scalar_set_b32(&term, tweak32, &overflow);\n    return !overflow && secp256k1_eckey_pubkey_tweak_add(p, &term);\n}\n```\n\n`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.\n\nThe 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.\n\n`xOnlyPointAddTweak` also disagrees with the check, returning `null` for the exact inputs the check accepts.\n\nThe condition is untested. `schnorr.js` skips every `xOnlyPointAddTweakCheck` assertion for the infinity vectors present in its own fixtures.\n\n\n\nAffected packages: npm:@bitcoin-js/tiny-secp256k1-asmjs, npm:tiny-secp256k1\nPatched: tiny-secp256k1 2.2.5, @bitcoin-js/tiny-secp256k1-asmjs 2.2.5","url":"https://github.com/advisories/GHSA-hj9c-qx2w-g7mh","published_at":"2026-11-19T22:43:45Z","updated_at":"2026-11-19T22:43:46Z","fetched_at":"2026-11-21T19:15:18.416792Z","severity":"medium","cvss_score":6.3,"epss":0.00436,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"tiny-secp256k1","vuln_id":"CVE-2026-107853","vuln_ids":["CVE-2026-107853","GHSA-HJ9C-QX2W-G7MH"],"tags":["ghsa","npm","CWE-252"],"cluster_id":2192,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2379","html":"https://vulnwatch.ve1ve2.com/item/2379"}},{"id":6617,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-107853: tiny-secp256k1 is a tiny secp256k1 native/JS wrapper. From 2.1.0 until 2.2.5 for tiny-secp256k1 and from 2.2.2 until 2.2.5 for @bitcoin-js/tiny-secp256k1-asmjs…","summary":"tiny-secp256k1 is a tiny secp256k1 native/JS wrapper. From 2.1.0 until 2.2.5 for tiny-secp256k1 and from 2.2.2 until 2.2.5 for @bitcoin-js/tiny-secp256k1-asmjs, the three-argument xOnlyPointAddTweakCheck path ignores the backend failure return from xOnlyPointAddTweak when a tweak produces the point at infinity. The shared X_ONLY_PUBLIC_KEY_INPUT buffer then still contains the original point, so a caller-controlled resultToCheck equal to that point can make the stale-buffer comparison return true even though no tweaked key exists. Protocols that rely on this helper to validate caller-controlled internal keys, tweaks, and comparison values can accept an invalid derived key. This issue is fixed in version 2.2.5.\n\nReferences:\nhttps://github.com/bitcoinjs/tiny-secp256k1/commit/ba1af1fceea95967a172c6438ed9302730bb7c01\nhttps://github.com/bitcoinjs/tiny-secp256k1/releases/tag/v2.2.5\nhttps://github.com/bitcoinjs/tiny-secp256k1/security/advisories/GHSA-hj9c-qx2w-g7mh\nhttps://github.com/bitcoinjs/tiny-secp256k1/security/advisories/GHSA-hj9c-qx2w-g7mh","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-107853","published_at":"2026-11-17T20:17:35.633000Z","updated_at":"2026-11-18T17:17:27.527000Z","fetched_at":"2026-11-21T19:15:31.482417Z","severity":"medium","cvss_score":6.3,"epss":0.00436,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-107853","vuln_ids":["CVE-2026-107853","GHSA-HJ9C-QX2W-G7MH"],"tags":["CWE-252"],"cluster_id":2193,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/6617","html":"https://vulnwatch.ve1ve2.com/item/6617"}}]}