Skip to content
Memory corruption Advisory Advanced CVE-2026-79097

Use after free in V8 (CVE-2026-79097)

A race condition in V8's JSDispatchTable allows the mutator thread to clear a mark bit set by concurrent marking when JSFunction::ResetIfCodeFlushed updates a dispatch entry using SKIP_WRITE_BARRIER. This can cause the live entry to be swept and freed, leading to a use-after-free and potential V8 sandbox bypass.

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 race condition in V8's JSDispatchTable allows the mutator thread to overwrite and erase a newly-set mark bit during concurrent marking when JSFunction::ResetIfCodeFlushed updates a dispatch entry using SKIP_WRITE_BARRIER. This causes the live entry to be swept and freed during the garbage collection cycle, leading to a use-after-free (UAF) and potential V8 sandbox bypass.

Affected files:

  • v8/src/objects/js-function-inl.h

Estimated timestamp from git blame: 2025-12-09

Root Cause Analysis

When incremental marking is active, the garbage collector concurrently marks objects and JSDispatchTable entries. JSDispatchEntry::Mark() is a single-shot, non-looping compare-and-swap (CAS) operation whose correctness relies on the invariant that any concurrent updates on the mutator thread will be followed by a write barrier to restore the mark bit if a race occurs (v8/src/sandbox/js-dispatch-table-inl.h:237-246):

C++
void JSDispatchEntry::Mark() {
  Address old_value = encoded_word_.load(std::memory_order_relaxed);
  Address new_value = old_value | kMarkingBit;
  // We don't need this cas to succeed. If marking races with
  // `SetCodeAndEntrypointPointer`, then we are bound to re-set the mark bit in
  // the write barrier.
  static_assert(JSDispatchTable::kWriteBarrierSetsEntryMarkBit);
  encoded_word_.compare_exchange_strong(old_value, new_value,
                                        std::memory_order_relaxed);
}

However, JSFunction::ResetIfCodeFlushed hard-codes SKIP_WRITE_BARRIER when calling UpdateCode (v8/src/objects/js-function-inl.h:608-637):

C++
void JSFunction::ResetIfCodeFlushed(...) {
  ...
  if (kBytecodeCanFlush && NeedsResetDueToFlushedBytecode(isolate)) {
    ResetTieringRequests(isolate);
    UpdateCode(isolate, *BUILTIN_CODE(isolate, CompileLazy),
               SKIP_WRITE_BARRIER);
    raw_feedback_cell()->reset_feedback_vector(gc_notify_updated_slot);
    return;
  }
  ...
  if (kBaselineCodeCanFlush && NeedsResetDueToFlushedBaselineCode(isolate)) {
    ResetTieringRequests(isolate);
    UpdateCode(isolate, *BUILTIN_CODE(isolate, InterpreterEntryTrampoline),
               SKIP_WRITE_BARRIER);
  }
}

When UpdateCode is called, it triggers SetCodeAndEntrypointPointer which loads the current payload, modifies it (preserving the snapshotted mark bit), and writes it back (v8/src/sandbox/js-dispatch-table-inl.h:186-200):

C++
void JSDispatchEntry::SetCodeAndEntrypointPointer(Address new_object,
                                                  Address new_entrypoint) {
  Address old_payload = encoded_word_.load(std::memory_order_relaxed);   // [A] snapshot mark bit
  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);            // [B] blind store
}

Race Interleaving Sequence

If the mutator is context-switched out between loading the old_payload [A] (which has marking_bit == 0) and writing the new_payload [B], the following race can occur:

  1. Incremental marking is active; the entry mark bit is initially 0.
  2. The mutator enters SetCodeAndEntrypointPointer via ResetIfCodeFlushed and loads old_payload (with marking_bit == 0).
  3. The concurrent marking thread visits the JSFunction or its FeedbackCell, invokes Mark(), and successfully sets the entry's mark bit to 1 in memory via CAS.
  4. The mutator resumes and writes new_payload (with marking_bit == 0) via a blind store, clearing the mark bit back to 0.
  5. The write barrier WriteBarrier::ForJSDispatchHandle early-returns because SKIP_WRITE_BARRIER was passed (v8/src/heap/heap-write-barrier-inl.h:293-305), so the mark bit is never restored.
  6. During the atomic pause, the sweep phase (JSDispatchTable::Sweep via GenericSweep) deallocates the unmarked entry and moves it to the freelist (v8/src/sandbox/external-entity-table-inl.h:387).
  7. The JSFunction still holds the now-freed JSDispatchHandle. A subsequent allocation of a new entrypoint can reuse this index, resulting in a Use-After-Free (UAF) and potential control flow hijacking when the original JSFunction is invoked.

Potential Steps to Trigger

Note: These are potential steps and have not been executed, as our tooling does not currently have the capability to run code.

  1. Define a JS function f and invoke it to allocate a compiled JSFunction and a JSDispatchHandle in the JSDispatchTable.
  2. Stop calling f long enough for its SFI bytecode to be aged and marked flushable, and trigger a GC cycle that flushes the bytecode to UncompiledData.
  3. Initiate a subsequent GC cycle with concurrent marking active.
  4. Invoke f to trigger compilation and enter ResetIfCodeFlushed on the mutator thread.
  5. Force/time a concurrent marking thread to visit f and mark its dispatch entry after the mutator thread snapshots the old_payload but before it stores the new_payload in SetCodeAndEntrypointPointer.
  6. Let GC run to completion, sweeping and recycling the JSDispatchEntry into the freelist.
  7. Allocate new closures to reuse the freed dispatch index, then call the original function f to trigger a type confusion or jump to an unexpected entrypoint.

Suggested Fix

To resolve this race, avoid using SKIP_WRITE_BARRIER in JSFunction::ResetIfCodeFlushed. Use UPDATE_WRITE_BARRIER instead, ensuring that the write barrier is always executed to restore/re-set the mark bit if a race with concurrent marking occurs.

In v8/src/objects/js-function-inl.h, update the UpdateCode invocations to use UPDATE_WRITE_BARRIER:

C++
// v8/src/objects/js-function-inl.h
  if (kBytecodeCanFlush && NeedsResetDueToFlushedBytecode(isolate)) {
    ResetTieringRequests(isolate);
    UpdateCode(isolate, *BUILTIN_CODE(isolate, CompileLazy),
               UPDATE_WRITE_BARRIER);
    raw_feedback_cell()->reset_feedback_vector(gc_notify_updated_slot);
    return;
  }
  ...
  if (kBaselineCodeCanFlush && NeedsResetDueToFlushedBaselineCode(isolate)) {
    ResetTieringRequests(isolate);
    UpdateCode(isolate, *BUILTIN_CODE(isolate, InterpreterEntryTrampoline),
               UPDATE_WRITE_BARRIER);
  }

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 the use of SKIP_WRITE_BARRIER in JSFunction::ResetIfCodeFlushed means that a concurrent mark bit set by the marking thread can be overwritten and not restored, breaking the invariant that the write barrier would re-set it.

Impact

A use-after-free could lead to a V8 sandbox bypass and potential control flow hijacking, though the report notes the steps are potential and have not been executed.

What the attacker needed

Ability to run JavaScript in V8; Trigger GC with concurrent marking; Precise timing of GC and function calls

The fix

The fix should avoid using SKIP_WRITE_BARRIER in JSFunction::ResetIfCodeFlushed and use UPDATE_WRITE_BARRIER instead, so the write barrier always runs and restores the mark bit if a race occurs.

How it was found

  1. Define a JS function and invoke it to allocate a compiled JSFunction and a JSDispatchHandle.
  2. Stop calling the function long enough for its bytecode to be aged and marked flushable, then trigger a GC cycle that flushes the bytecode.
  3. Initiate a subsequent GC cycle with concurrent marking active.
  4. Invoke the function to trigger compilation and enter ResetIfCodeFlushed on the mutator thread.
  5. Force a concurrent marking thread to visit the function and mark its dispatch entry after the mutator snapshots the old payload but before it stores the new payload.
  6. Let GC run to completion, sweeping and recycling the JSDispatchEntry into the freelist.

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 uses a garbage collector to free memory that is no longer needed. A race condition happens when two parts of the program try to change the same thing at the same time, and the order of their actions is unpredictable. Here, one part could mark an object as 'in use' while another part accidentally clears that mark, so the garbage collector frees memory that is still being used. Using freed memory can let an attacker run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.