Vulnerabilities in pkg:npm/tiny-secp256k1
PACKAGECVE-2026-107853 is a MODERATE stale buffer after ignored wasm vulnerability (CWE-252: Unchecked Return Value) affecting tiny-secp256k1 libraries in the npm ecosystem. The issue involves stale buffer after ignored wasm failure accepts invalid infinity tweak. Remediation is available by upgrading affected packages to version 2.2.5.
pkg:npm/tiny-secp256k1
Vulnerability advisories affecting package pkg:npm/tiny-secp256k1. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-hj9c-qx2w-g7mh | CVE-2026-107853 | MODERATE | tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak |
| GHSA-5vhg-9xg4-cv9m | CVE-2024-49365 | HIGH | tiny-secp256k1 allows for verify() bypass when running in bundled environment |
| GHSA-7mc2-6phr-23xc | CVE-2024-49364 | HIGH | tiny-secp256k1 vulnerable to private key extraction when signing a malicious JSON-stringifyable message in bundled environment |
CVE-2026-107853 at a Glance
How to Fix CVE-2026-107853
To remediate this vulnerability, upgrade all affected tiny-secp256k1 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install tiny-secp256k1@2.2.5
npm install @bitcoin-js/tiny-secp256k1-asmjs@2.2.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls tiny-secp256k1
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-107853, inspect your project dependencies using npm:
npm ls tiny-secp256k1
Analyze the terminal output to locate any version of tiny-secp256k1 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.2.5), your application is affected.
Note: The npm ls tiny-secp256k1 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-252: Unchecked Return Value, where the product does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions. In tiny-secp256k1, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-107853 Affected tiny-secp256k1 Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tiny-secp256k1
|
npm |
≥ 2.1.0
< 2.2.5
|
2.2.5
|
|
@bitcoin-js/tiny-secp256k1-asmjs
|
npm |
≥ 2.2.2
< 2.2.5
|
2.2.5
|
References
Frequently Asked Questions
What is CVE-2026-107853?
Which tiny-secp256k1 versions are affected?
What version fixes CVE-2026-107853?
Is tiny-secp256k1 affected?
Is @bitcoin-js/tiny-secp256k1-asmjs affected?
What CWE is associated with CVE-2026-107853?
How can I check npm dependencies for CVE-2026-107853?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-hj9c-qx2w-g7mh",
"modified" : "2026-11-19T22:43:45Z",
"published" : "2026-11-19T22:43:45Z",
"aliases" : [ "CVE-2026-107853" ],
"summary" : "tiny-secp256k1: Stale buffer after ignored wasm failure accepts invalid infinity tweak",
"details" : "### 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```js\nconst res = secp256k1.xOnlyPointAddTweak(f.pubkey, f.tweak);\nif (f.result === null) {\n t.same(res, f.result, `xOnlyPointAddTweak returns null when G pubkey and n - 1 tweak used`);\n continue;\n}\n```\n\n### PoC\nBoth witnesses are already present in the project fixtures at `schnorr.json` as the two vectors with a null result, and both pass every validator in `validate.ts`.\n\n```js\nimport * as secp256k1 from \"tiny-secp256k1\";\n\nconst hex = (s) => Uint8Array.from(Buffer.from(s, \"hex\"));\n\n// x coordinate of G, and the tweak n - 1\nconst point = hex(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\");\nconst tweak = hex(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\");\n\n// lift_x(point) + tweak * G is the point at infinity, no tweaked key exists\nconsole.log(secp256k1.xOnlyPointAddTweak(point, tweak));\n// null\n\nconsole.log(secp256k1.xOnlyPointAddTweakCheck(point, tweak, point, 0));\n// false correct, the parity form uses the C check\n\nconsole.log(secp256k1.xOnlyPointAddTweakCheck(point, tweak, point));\n// true wrong, the three argument form compares point against itself\n```\n\nA second witness from the same fixture uses the x coordinate of `2 * G` with tweak `n - 2`.\n\n```js\nconst point2 = hex(\"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\");\nconst tweak2 = hex(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413f\");\nconsole.log(secp256k1.xOnlyPointAddTweakCheck(point2, tweak2, point2)); // true\n```\n\nBoth were executed against the published `secp256k1.wasm` from npm 2.2.4 under `wasmtime`, driving the exports through the exact write, call, slice, zero sequence `index.ts` performs.\n\n```\n-- witness x(G), n-1\n xOnlyPointAddTweak(P, t) = None\n check(P, t, P, parity=0) = False\n check(P, t, P, parity=1) = False\n check(P, t, P) 3-arg form = True\n raw wasm return = -1\n buffer after call unchanged = True 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\n\n-- witness x(2G), n-2\n xOnlyPointAddTweak(P, t) = None\n check(P, t, P, parity=0) = False\n check(P, t, P, parity=1) = False\n check(P, t, P) 3-arg form = True\n raw wasm return = -1\n buffer after call unchanged = True c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\n\n-- control, ordinary tweak 5 on x(G)\n xOnlyPointAddTweak = (1, 'fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556')\n check 3-arg with correct result = True\n check 3-arg with wrong result = False\n```\n\nThe control confirms the three argument form is otherwise correct, so the defect is specific to the failure path.\n\nAn attacker generated witness follows the same construction with a hash derived tweak.\n\n```\ntweak = 2ae431167097f01e131d3e3fd000044e79eb64f5391d594ec311d4a56a38c1e3\npoint = d14530c85d0169da4e4be4642f2cdaad14fb0421b690df617d00366b5f1ca832\nlift_x(point) + tweak * G = infinity\nxOnlyPointAddTweakCheck(point, tweak, point) === true\n```\n\n### Impact\nThe three-argument helper can return `true` for an internal key and tweak whose derived point is at infinity. Protocols that use this result to validate a derived output can accept an invalid key when the caller controls the point, tweak, and comparison value.\n\n### Affected versions\n\n- `tiny-secp256k1`: 2.1.0 through 2.2.4.\n- `@bitcoin-js/tiny-secp256k1-asmjs`: 2.2.2 through 2.2.4.\n\nThe `xOnlyPointAddTweakCheck` API first appears in tiny-secp256k1 2.1.0. Static inspection of the integrity-checked asm.js releases confirms the same ignored return value and unchanged-buffer path when the tweak result is infinity. The WASM reproduction above is not an asm.js runtime measurement.\n\n### Remediation\n\nUpgrade `tiny-secp256k1` and `@bitcoin-js/tiny-secp256k1-asmjs`, as applicable, to 2.2.5 or a later patched release. The path without `tweakParity` now checks the backend's failure result before reading and comparing the output buffer. A tweak that produces the point at infinity returns `false`.\n\n### References\n\n- [Fix: Reject failed infinity tweaks before comparing the output](https://github.com/bitcoinjs/tiny-secp256k1/commit/ba1af1fceea95967a172c6438ed9302730bb7c01)",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "tiny-secp256k1"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.1.0"
}, {
"fixed" : "2.2.5"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@bitcoin-js/tiny-secp256k1-asmjs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.2.2"
}, {
"fixed" : "2.2.5"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/bitcoinjs/tiny-secp256k1/security/advisories/GHSA-hj9c-qx2w-g7mh"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-107853"
}, {
"type" : "WEB",
"url" : "https://github.com/bitcoinjs/tiny-secp256k1/commit/ba1af1fceea95967a172c6438ed9302730bb7c01"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/bitcoinjs/tiny-secp256k1"
}, {
"type" : "WEB",
"url" : "https://github.com/bitcoinjs/tiny-secp256k1/releases/tag/v2.2.5"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-252" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-11-19T22:43:45Z",
"nvd_published_at" : "2026-11-17T20:17:35Z"
}
}