# CVE-2026-107853 — tiny-secp256k1: stale-buffer `xOnlyPointAddTweakCheck` accepts invalid tweak derivations
[ |
| **Fixed in** | **2.2.5** — commit `ba1af1fc` (GHSA-hj9c-qx2w-g7mh) |
| **CWE** | CWE-457 (Use of Uninitialized Variable), CWE-754 (Improper Check for Unusual/Exceptional Conditions) |
| **Impact** | 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 — an attacker can craft a tweak whose "checked" result equals the input itself and have it accepted by any consumer that trusts this check |
| **Vector** | Library callers (wallets/protocols) verifying tweaked output keys against attacker-influenced (point, tweak, claimed-result) triples |
| **Trigger** | `xOnlyPointAddTweakCheck(G, n−1, G)` — the derivation lands on the point at infinity and fails |
The vulnerable path discarded the wasm failure return:
X_ONLY_PUBLIC_KEY_INPUT2.set(resultToCheck);
return wasm.xOnlyPointAddTweakCheck(tweakParity) === 1;
wasm.xOnlyPointAddTweak(); // return ignored (-1 on failure)
const newKey = X_ONLY_PUBLIC_KEY_INPUT.slice(0, validate.X_ONLY_PUBLIC_KEY_SIZE);
return compare(newKey, resultToCheck) === 0; // stale buffer = the input itself
`x_only_point_add_tweak` in `lib.rs` returns `-1` and leaves
`X_ONLY_PUBLIC_KEY_INPUT` untouched when the tweak addition fails. The fix
refactors to remove `throw_error` calls in the wasm surface so every failure
returns a proper code and the check handles it.
`x_only_point_add_tweak` (Rust/wasm) returns `-1` when
`secp256k1_xonly_pubkey_tweak_add` fails — notably when
`P + G·t` lands on the point at infinity. The JS wrapper discarded that
return value and compared `X_ONLY_PUBLIC_KEY_INPUT` (which still holds the
original `point`) against the caller-supplied `resultToCheck`. Passing the
input as its own claimed result therefore yields `true` for a derivation
that failed: with `point = G` and `tweak = n−1` (the largest valid tweak),
the result is the point at infinity and the check still reports success.
The fix removes the wasm `throw_error` paths so failures return proper codes
and the check evaluates the real derivation result.
| `ecc-vuln` | `cve-2026-107853:vuln` | tiny-secp256k1 **2.2.4** from npm |
| `ecc-fixed` | `cve-2026-107853:fixed` | tiny-secp256k1 **2.2.5** from npm (vendor fix) |
| `poc` | `cve-2026-107853-poc:local` | stdlib-only Python driver |
The harness calls the real `xOnlyPointAddTweakCheck(G, n−1, G)` — the
generator point as both input and claimed result, with the largest valid
tweak `n−1` whose addition produces the point at infinity and therefore
fails. Both sides differ only in the npm package version.
./run-lab.sh build # installs 2.2.4 / 2.2.5 from npm (node:22-alpine)
./run-lab.sh up # cve107853lab network: ecc-vuln / ecc-fixed
* **check** — exit 1 when the invalid derivation is accepted (`true`), 0 when
the failed derivation returns `false`; 3 no worker, 2
* **exploit** — narrated chain: crafted infinity-tweak derivation → wasm
failure → stale-buffer comparison → `true` for the invalid case.
* **probe** — verdict and vulnerable flags.
* **mitigation** — 2.2.5 / commit `ba1af1fc` / failure-code refactor.
A standalone full-chain exploit ships at `exploit/exploit.py`:
python3 exploit/exploit.py --host=ecc-vuln
# exit 1 on confirmed invalid-derivation acceptance, 0 on a safe target
| call | `ecc-vuln` (2.2.4) | `ecc-fixed` (2.2.5) |
| `xOnlyPointAddTweakCheck(G, n−1, G)` (derivation fails) | **`true` — invalid derivation accepted** | **`false` — failure handled** |
Captured runs: `evidence/check-*-run.txt`, `evidence/exploit-*-run.txt`,
`evidence/probe-*-run.txt`, `evidence/mitigation-*-run.txt`,
`evidence/exploit-standalone-run.txt`, `evidence/exploit-standalone-fixed-run.txt`,
`evidence/versions.txt`, `evidence/0day-sweep.txt`.
* Podman (or Docker); bounded containers on the isolated `cve107853lab`
* Real-world impact applies to consumers that rely on
`xOnlyPointAddTweakCheck` to validate tweaked output keys against
attacker-influenced (point, tweak, result) triples — e.g. taproot
## 7. Additional findings (0-day sweep on the fixed line)
The same commit `ba1af1fc` removes `throw_error` calls across the whole wasm
surface so every failure path returns a proper code. The four-argument path
(explicit `tweakParity`) already compared the wasm return value and was not
affected. The fix also bumps the package version metadata so dependents pin
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
poc/poc.py the PoC (check / exploit / probe / mitigation)
exploit/exploit.py standalone full-chain exploit
lab/lab.Dockerfile installs tiny-secp256k1 2.2.4 / 2.2.5 from npm
lab/test.js the real xOnlyPointAddTweakCheck invocation
lab/service.py HTTP wrapper (POST /check)
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)
* CVE record —
* GitHub advisory —
* Fix commit —
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
