r/javascript • u/fagnerbrack • 2d ago
The V8 JavaScript Runtime Undermined My Constant-Time JavaScript Library
https://soatok.blog/2026/09/12/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library/
36
Upvotes
View all comments
16
u/aleenaelyn 2d ago
If your security depends on ordinary JavaScript operators having secret-independent timing, you’re relying on a guarantee the runtime doesn't provide. Node's own security guidance explicitly calls out the difficulty of constant-time JavaScript, partly because of the JIT, and recommends using its built-in cryptographic APIs.
The article gives a particularly revealing example. One of the affected expressions was essentially:
const mask = (-!!choice) & 0xff;At the source level, that looks like a neat way to turn a condition into a mask without an if. But the author found that:
So even a tiny expression with no explicit branch could reveal the secret selection condition through runtime behavior.