Home/Research/Post

GHSA-vp2j-gqfm-r3cf: secp256k1-native has a compiler-induced timing side channel in scalar multiplication

  • Severity: MEDIUM
  • CVE: CVE-2026-63410
  • Ecosystems: rubygems
  • Packages: secp256k1-native

## Summary

`Point#mul` — the default, constant-time scalar multiplication and the library’s headline secret-scalar operation — could leak timing information about the secret scalar (a private key or ECDSA-style nonce in a downstream consumer) **not because of a source-level bug, but because the compiler reconstructed a branch from branchless source.**

The Montgomery ladder selects between point candidates with `uint256_select`, written deliberately branchlessly as `r = (a & ~mask) | (b & mask)` with a mask that is all-ones or all-zeros. GCC 15.2 at `-O2` recognises this select idiom, reconstructs the original boolean condition, and emits a secret-dependent conditional jump (`je`/`jne`). The branch’s taken/not-taken timing correlates with the secret scalar bits flowing through the ladder.

This silently undid the 0.17.0 fix for the historical |t|=875 infinity-branch leak, which had relied on `uint256_select` compiling to branchless code.

## Impact

A timing side-channel on the secret scalar in constant-time scalar multiplication. For a consumer that calls `Point#mul` (or the native `scalar_multiply_ct`) on a secret key or nonce and exposes timing to an attacker (e.g. an online signing oracle), repeated measurements can statistically recover scalar bits — the classic ECC private-key/nonce timing-attack setting (cf. Brumley–Boneh). The leak is in the *compiled binary*; the source is correct, so source review and the deterministic ctgrind check on a *non-reconstructing* toolch…

Source: GitHub Security Advisories · 2026-11-23