Skip to content
Race condition Advisory Advanced CVE-2026-78901

Race condition in V8 (CVE-2026-78901)

A static-analysis report claims that V8's Code::SetMarkedForDeoptimization updates a JSDispatchTable entry without running the required write barrier, so a concurrent marker's mark bit can be erased by a blind store. If true, the entry could be swept and reused, giving trusted-space type confusion and a possible V8 sandbox bypass, though the authors did not dynamically verify it.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 2 months

Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.

Overview: A potential race condition exists in V8's concurrent marking and deoptimization logic where Code::SetMarkedForDeoptimization updates a dispatch table entry without running a write barrier. During concurrent marking, a background thread's CAS mark can be overwritten by the mutator's blind store, leading to a live entry being swept. This could result in trusted-space type confusion and a potential V8 sandbox bypass.

Affected files:

  • v8/src/objects/code.cc
  • v8/src/sandbox/js-dispatch-table-inl.h

Estimated timestamp from git blame: 2024-12-05

Root Cause Analysis

In V8's sandbox design, the JSDispatchTable acts as a protected control-flow integrity (CFI) table mapping JSDispatchHandles to (entrypoint, parameter_count) pairs. To ensure garbage collection correctness during concurrent marking, the table's entries must be marked.

JSDispatchEntry::Mark() is implemented as a single-shot, non-looping CAS:

C++
void JSDispatchEntry::Mark() {
  Address old_value = encoded_word_.load(std::memory_order_relaxed);
  Address new_value = old_value | kMarkingBit;
  static_assert(JSDispatchTable::kWriteBarrierSetsEntryMarkBit);
  encoded_word_.compare_exchange_strong(old_value, new_value,
                                        std::memory_order_relaxed);
}

Conversely, modifying an entry via SetCodeAndEntrypointPointer() performs a relaxed load, computes the new payload preserving the loaded marking bit, and writes it back via a blind store:

C++
void JSDispatchEntry::SetCodeAndEntrypointPointer(Address new_object,
                                                  Address new_entrypoint) {
  Address old_payload = encoded_word_.load(std::memory_order_relaxed);
  Address marking_bit = old_payload & kMarkingBit;
  ...
  Address new_payload = object | marking_bit | parameter_count;
  entrypoint_.store(new_entrypoint, std::memory_order_relaxed);
  encoded_word_.store(new_payload, std::memory_order_release);
}

Because of this design, if concurrent marking sets the mark bit (using Mark()) after the modifier has loaded old_payload but before it executes its blind store, the mark bit will be silently overwritten and erased. To prevent this, V8 enforces an invariant that every modifier must invoke WriteBarrier::ForJSDispatchHandle after modifying an entry, which re-runs jdt.Mark(handle) and restores the mark bit if it was erased.

However, Code::SetMarkedForDeoptimization() in v8/src/objects/code.cc violates this invariant. It updates dispatch table entries using jdt.SetCodeNoWriteBarrier() but fails to execute a follow-up write barrier:

C++
// v8/src/objects/code.cc
jdt.SetCodeNoWriteBarrier(
    handle, *BUILTIN_CODE(isolate, InterpreterEntryTrampoline));
...
jdt.SetCodeNoWriteBarrier(handle, *BUILTIN_CODE(isolate, CompileLazy));

Potential Trigger Path

Based on static analysis, the following sequence of events could potentially trigger this vulnerability:

  1. Optimized Code Creation: A function is compiled into optimized code, and its Code object has js_dispatch_handle set.
  2. Concurrent Marking: A major GC cycle begins. A background marking thread visits the JSFunction or its FeedbackCell, calling jdt.Mark(handle) and marking the entry.
  3. Deoptimization & Race: Concurrently, the main thread invalidates a code dependency (e.g., prototype change) and runs Code::SetMarkedForDeoptimization.
  4. Interleaved Execution:
    • The main thread executes SetCodeAndEntrypointPointer, loading the entry's state with marking_bit = 0 (assuming it is called before the marker's CAS succeeds or during a separate marking sweep where the marker re-evaluates the handle).
    • The background marking thread successfully executes Mark(), setting the marking bit to 1.
    • The main thread performs the blind store of new_payload (with marking_bit = 0), erasing the mark bit.
  5. Sweeping: Because the update was done via SetCodeNoWriteBarrier and no follow-up write barrier was executed, the entry remains unmarked. When the GC sweeps the JSDispatchTable via GenericSweep, it reclaims the entry and adds it to the free list.
  6. Use-After-Free: If the slot is subsequently reallocated for another function, calling the original JSFunction will jump to the new entry point with potentially mismatched signatures, leading to trusted-space type confusion.

Note: These steps are based on static code analysis; our tooling does not currently have the capability to run or dynamically verify this concurrent execution behavior.

Proposed Fix

To resolve this issue, a write barrier should be executed after updating the dispatch table entry in Code::SetMarkedForDeoptimization.

In v8/src/objects/code.cc:

C++
jdt.SetCodeNoWriteBarrier(
    handle, *BUILTIN_CODE(isolate, InterpreterEntryTrampoline));
WriteBarrier::ForJSDispatchHandle(this, handle);

And similarly for the CompileLazy path.

Evaluated with Chrome root at commit: 75203b87cbf6681eb7c7dda8e1d0bf781538c76a


Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:

  • If you are familiar with the severity guidelines, you may adjust the severity.
  • If this is a false positive, and there's no work to be done, please close as WAI.
  • If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.

Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a missing write barrier: Code::SetMarkedForDeoptimization uses SetCodeNoWriteBarrier, so a concurrent marker's CAS-set mark bit can be overwritten by the mutator's blind store and the entry is swept.

Impact

Could lead to trusted-space type confusion and a potential V8 sandbox bypass, but the report is based on static analysis only and was not dynamically verified.

What the attacker needed

Concurrent marking GC cycle; deoptimization of optimised code; precise thread interleaving

The fix

A write barrier should be executed after updating the dispatch table entry in Code::SetMarkedForDeoptimization, for both the interpreter trampoline and CompileLazy paths.

How it was found

  1. Compile a function into optimized code so its Code object has a js_dispatch_handle.
  2. Start a major GC so a background marking thread calls jdt.Mark(handle) on the entry.
  3. Concurrently trigger deoptimization on the main thread, which runs Code::SetMarkedForDeoptimization.
  4. Interleave so the main thread loads the entry with the mark bit clear, the marker sets it, then the main thread's blind store erases it.
  5. The GC sweeps the JSDispatchTable and reclaims the unmarked entry into the free list.
  6. If the slot is reallocated, calling the original function jumps to a mismatched entry point.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

V8 is the JavaScript engine in Chrome. It keeps a table of small records that say where each function's code starts, and the garbage collector (the part that frees unused memory) marks records it still needs. This report says one code path changes such a record without telling the collector, so the collector can wrongly free it and later hand the slot to a different function, which could let an attacker confuse the engine about what code is running.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.