<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx" -->

---
title: The V8 JavaScript Runtime Undermined My Constant-Time...
description: A security researcher disclosed a side-channel vulnerability in the constant-time-js JavaScript library, showing that V8's ToBoolean mechanism, its handling of...
canonical: https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The V8 JavaScript Runtime Undermined My Constant-Time JavaScript Library | daily.dev
og:description: A security researcher disclosed a side-channel vulnerability in the constant-time-js JavaScript library, showing that V8's ToBoolean mechanism, its handling of...
og:url: https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx
og:image: https://api.daily.dev/og/posts/G9jlr7QSx.png
og:image:alt: The V8 JavaScript Runtime Undermined My Constant-Time JavaScript Library
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The V8 JavaScript Runtime Undermined My Constant-Time JavaScript Library

**[Dhole Moments](https://daily.dev/sources/soatok)** · 19 min read · 6 upvotes · 2 comments

## Summary

A security researcher disclosed a side-channel vulnerability in the constant-time-js JavaScript library, showing that V8's ToBoolean mechanism, its handling of the true/false Oddball objects, and its treatment of signed zero (-0) versus -1 leak secret-dependent cache and instruction timing information. The maintainer verified the report by tracing V8 interpreter and code-stub-assembler source, confirmed the leakage, and released version 0.5.0 with a patch that avoids booleans entirely (using numeric 0/1 flags instead) and avoids unary negation in favor of subtraction from positive zero to sidestep V8's distinct handling of -0. A CVE and GitHub security advisory were requested so downstream consumers relying on npm audit would be prompted to upgrade. The piece closes by noting that true constant-time guarantees remain elusive even in WebAssembly or systems languages like Rust, since no formal constant-time proposal has matured for Wasm and LLVM work on this is still ongoing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://soatok.blog/2026/09/12/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library>

## Questions this post answers

### Why does the double-negation trick (!!x) leak timing information in V8-based constant-time JavaScript code?

V8's ToBoolean conversion (Builtins_ToBoolean) reads the true and false Oddball objects from different memory addresses and cache lines, so a hardware read watchpoint can distinguish which branch executed even though instruction addresses may look identical. This means boolean conversions used in cryptographic selection functions like select() can leak the secret condition through data-cache access patterns, defeating naive constant-time JavaScript implementations.

_Developers hardening crypto code in JavaScript can track engine-level timing pitfalls like this one on daily.dev._

### Why is negating a value with unary minus (-x) unsafe for constant-time masking in JavaScript running on V8?

Unary negation produces a signed negative zero (-0) when the operand is zero, and V8 represents -0 differently from the Smi value -1, causing divergent code paths in the interpreter. The fix in constant-time-js version 0.5.0 replaces (-choice) & 0xff with (0 - (choice & 1)) & 0xff, since subtraction from positive zero takes a single, non-branching Smi subtraction path that avoids materializing -0.

_Anyone writing side-channel-resistant JavaScript can keep up with V8 quirks like this via daily.dev._

### What CVE and version fixed the side-channel vulnerability in the constant-time-js npm package?

Version 0.5.0 of constant-time-js fixes a side-channel disclosed by PhD student Yayu Wang and researchers at the University of British Columbia, affecting the select, select_alt, and select_ints functions. A GitHub security advisory and CVE were requested so that npm audit would flag dependent projects and prompt them to upgrade, even though the package had no known open-source dependents at the time.

_Teams auditing their dependency tree for crypto library CVEs can follow disclosures like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@springtofigh** · 0 upvotes

> Lovely JavaScript and its unstable behaviors!!

**@agustinbarrientos** · 0 upvotes

> Does `zero dependents` count private copies too?

## Similar posts on daily.dev

- [Node.js — Developing a minimally HashDoS resistant, yet quickly reversible integer hash for V8](https://daily.dev/posts/node-js-developing-a-minimally-hashdos-resistant-yet-quickly-reversible-integer-hash-for-v8-mp9ljns5l) · Node.js · 1 upvotes · 0 comments
- [Solidity 0.8.38 Release Announcement](https://daily.dev/posts/solidity-0-8-38-release-announcement-mu9kdosuj) · Solidity · 0 upvotes · 0 comments
- [Terned Backwards](https://daily.dev/posts/terned-backwards-mhttbx4wi) · The Daily WTF · 3 upvotes · 1 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#cryptography](https://daily.dev/tags/cryptography), [#v8](https://daily.dev/tags/v8)

[View this post on daily.dev](https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The V8 JavaScript Runtime Undermined My Constant-Time JavaScript Library","url":"https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx"},"datePublished":"2026-09-12T07:07:34.546Z","dateModified":"2026-09-12T07:08:16.748Z","description":"A security researcher disclosed a side-channel vulnerability in the constant-time-js JavaScript library, showing that V8's ToBoolean mechanism, its handling of...","image":"https://i0.wp.com/soatok.blog/wp-content/uploads/2026/09/BlogHeader-2026-ConstantTimeJS050.png?fit=1200%2C675\u0026ssl=1","thumbnailUrl":"https://i0.wp.com/soatok.blog/wp-content/uploads/2026/09/BlogHeader-2026-ConstantTimeJS050.png?fit=1200%2C675\u0026ssl=1","isAccessibleForFree":true,"articleSection":"Dhole Moments","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Dhole Moments","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/60eca77d8a44451797a63883262fcffb","url":"https://daily.dev/sources/soatok"},"commentCount":2,"discussionUrl":"https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"javascript,cryptography,v8","timeRequired":"PT19M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Dhole Moments","item":"https://daily.dev/sources/soatok"},{"@type":"ListItem","position":3,"name":"The V8 JavaScript Runtime Undermined My Constant-Time JavaScript Library"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx","comment":[{"@type":"Comment","text":"Lovely JavaScript and its unstable behaviors!!","datePublished":"2026-09-12T18:05:08.350Z","url":"https://daily.dev/posts/G9jlr7QSx#c-2c483BwOC","author":{"@type":"Person","name":"Spring Tofigh","url":"https://daily.dev/springtofigh","image":"https://avatars.githubusercontent.com/u/90114320?v=4"}},{"@type":"Comment","text":"Does zero dependents count private copies too?","datePublished":"2026-09-19T15:07:45.440Z","url":"https://daily.dev/posts/G9jlr7QSx#c-yuGVbFxxV","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library-g9jlr7qsx#faq","mainEntity":[{"@type":"Question","name":"Why does the double-negation trick (!!x) leak timing information in V8-based constant-time JavaScript code?","acceptedAnswer":{"@type":"Answer","text":"V8's ToBoolean conversion (Builtins_ToBoolean) reads the true and false Oddball objects from different memory addresses and cache lines, so a hardware read watchpoint can distinguish which branch executed even though instruction addresses may look identical. This means boolean conversions used in cryptographic selection functions like select() can leak the secret condition through data-cache access patterns, defeating naive constant-time JavaScript implementations. Developers hardening crypto code in JavaScript can track engine-level timing pitfalls like this one on daily.dev."}},{"@type":"Question","name":"Why is negating a value with unary minus (-x) unsafe for constant-time masking in JavaScript running on V8?","acceptedAnswer":{"@type":"Answer","text":"Unary negation produces a signed negative zero (-0) when the operand is zero, and V8 represents -0 differently from the Smi value -1, causing divergent code paths in the interpreter. The fix in constant-time-js version 0.5.0 replaces (-choice) \u0026 0xff with (0 - (choice \u0026 1)) \u0026 0xff, since subtraction from positive zero takes a single, non-branching Smi subtraction path that avoids materializing -0. Anyone writing side-channel-resistant JavaScript can keep up with V8 quirks like this via daily.dev."}},{"@type":"Question","name":"What CVE and version fixed the side-channel vulnerability in the constant-time-js npm package?","acceptedAnswer":{"@type":"Answer","text":"Version 0.5.0 of constant-time-js fixes a side-channel disclosed by PhD student Yayu Wang and researchers at the University of British Columbia, affecting the select, select_alt, and select_ints functions. A GitHub security advisory and CVE were requested so that npm audit would flag dependent projects and prompt them to upgrade, even though the package had no known open-source dependents at the time. Teams auditing their dependency tree for crypto library CVEs can follow disclosures like this on daily.dev."}}]}
```

