secp256k1-native has a compiler-induced timing side channel in scalar multiplication
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| sgbettsecp256k1-native | — | Not listed |
| RubyGemssecp256k1-native |
< 0.18.0→ 0.18.0 |
0.18.0 |
Original description The description as published by the source.
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: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- package github.com
- web github.com
- web github.com
- web github.com
- web github.com
- web github.com
- web nvd.nist.gov
- web github.com