Assertion failure: is_intn(imm, kJumpOffsetBits), at js/src/jit/riscv64/extension/base-riscv-i.h
A crafted JavaScript file causes the SpiderMonkey JavaScript engine, when built for the riscv64 simulator, to hit an assertion failure while patching a short-range branch in the JIT assembler. The crash is a debug assertion in the engine's own code, not a demonstrated memory-safety exploit against users.
Originally disclosed on Mozilla
- Fixed in 30 days
- Paid in 36 days
- Disclosed after 30 days
Created attachment 9522903 poc.js
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Steps to reproduce:
The attached js file crashes the SpiderMonkey (riscv64 simulator build) and here is the reproduce step:
- System Environment
OS: Linux 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Firefox Version: 251eeab1c468eb1557269952c712580e4cc16e29
- Build Script
$ cd firefox
$ cat build.sh
cat << EOF > .mozconfig
ac_add_options --enable-application=js
ac_add_options --enable-optimize
ac_add_options --enable-debug
ac_add_options --disable-shared-js
ac_add_options --enable-fuzzing
ac_add_options --enable-gczeal
ac_add_options --enable-simulator=riscv64
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-fuzzbuild-riscv64
EOF
export MOZCONFIG=$PWD/.mozconfig
./mach build
$ ./build.sh
- Run the poc.js
$ ./obj-fuzzbuild-riscv64/dist/bin/js --baseline-warmup-threshold=10 --ion-warmup-threshold=100 --ion-check-range-analysis --ion-extra-checks --fuzzing-safe --disable-oom-functions poc.js
Actual results:
Spidermonkey crashes with the following output:
[211668] Assertion failure: is_intn(imm, kJumpOffsetBits), at /home/lain/firefox/js/src/jit/riscv64/extension/base-riscv-i.h:113
#01: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x36c31b3]
#02: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x36c7ccc]
#03: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x32f43fa]
#04: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x32f3d9a]
#05: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x32f388b]
#06: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x32f1467]
#07: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x36f9070]
#08: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x371bf2f]
#09: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x33a9aa8]
#10: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x339c2ba]
#11: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x3396e71]
#12: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x3396cc8]
#13: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x37b216c]
#14: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x37b42f3]
#15: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x37b4667]
#16: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x37450c2]
#17: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x37413bc]
#18: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x376fa61]
#19: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x37701c8]
#20: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x37b01f1]
#21: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x26238a6]
#22: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x261cc1b]
#23: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x261fc8e]
#24: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x26200ef]
#25: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x27b8672]
#26: JS_ExecuteScript(JSContext*, JS::Handle<JSScript*>)[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x27b8854]
#27: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x254f857]
#28: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x254ed5a]
#29: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x250735b]
#30: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x24fe9a6]
#31: ???[/lib/x86_64-linux-gnu/libc.so.6 +0x29d90]
#32: __libc_start_main[/lib/x86_64-linux-gnu/libc.so.6 +0x29e40]
#33: ???[/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js +0x24c5fc9]
#34: ??? (???:???)
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==211668==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x6358f91ff1cb bp 0x7ffeb8176aa0 sp 0x7ffeb8176a80 T211668)
==211668==The signal is caused by a WRITE memory access.
==211668==Hint: address points to the zero page.
#0 0x6358f91ff1cb in MOZ_CrashSequence(void*, long) /home/lain/firefox/obj-fuzzbuild-riscv64/dist/include/mozilla/Assertions.h:237:3
#1 0x6358f91ff1cb in js::jit::AssemblerRISCVI::SetJalOffset(int, int, int) /home/lain/firefox/js/src/jit/riscv64/extension/base-riscv-i.h:113:5
#2 0x6358f9203ccb in js::jit::Assembler::PatchShortRangeBranchToVeneer(js::jit::AssemblerBufferWithConstantPools<1024ul, 4ul, js::jit::Instruction, js::jit::Assembler, 2u>*, unsigned int, js::jit::BufferOffset, js::jit::BufferOffset) /home/lain/firefox/js/src/jit/riscv64/Assembler-riscv64.cpp:1578:36
#3 0x6358f8e303f9 in js::jit::AssemblerBufferWithConstantPools<1024ul, 4ul, js::jit::Instruction, js::jit::Assembler, 2u>::finishPool(unsigned long) /home/lain/firefox/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h:1004:7
#4 0x6358f8e2fd99 in js::jit::AssemblerBufferWithConstantPools<1024ul, 4ul, js::jit::Instruction, js::jit::Assembler, 2u>::insertEntryForwards(unsigned int, unsigned int, unsigned char*, unsigned char*) /home/lain/firefox/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h:776:7
#5 0x6358f8e2f88a in js::jit::AssemblerBufferWithConstantPools<1024ul, 4ul, js::jit::Instruction, js::jit::Assembler, 2u>::allocEntry(unsigned long, unsigned int, unsigned char*, unsigned char*, js::jit::AssemblerBufferWithConstantPools<1024ul, 4ul, js::jit::Instruction, js::jit::Assembler, 2u>::PoolEntry*) /home/lain/firefox/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h:841:22
#6 0x6358f8e2d466 in js::jit::AssemblerBufferWithConstantPools<1024ul, 4ul, js::jit::Instruction, js::jit::Assembler, 2u>::putInt(unsigned int) /home/lain/firefox/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h:883:14
#7 0x6358f8e2d466 in js::jit::Assembler::emit(int) /home/lain/firefox/js/src/jit/riscv64/Assembler-riscv64.h:388:36
#8 0x6358f923506f in js::jit::MacroAssemblerRiscv64::ma_store(js::jit::Register, js::jit::Address, js::jit::LoadStoreSize, js::jit::LoadStoreExtension) /home/lain/firefox/js/src/jit/riscv64/MacroAssembler-riscv64.cpp:1262:7
#9 0x6358f9257f2e in js::jit::MacroAssemblerRiscv64Compat::store32(js::jit::Imm32, js::jit::Address const&) /home/lain/firefox/js/src/jit/riscv64/MacroAssembler-riscv64.cpp:1643:10
#10 0x6358f8ee5aa7 in js::jit::BaselineCodeGen<js::jit::BaselineCompilerHandler>::emit_InitElemArray() /home/lain/firefox/js/src/jit/BaselineCodeGen.cpp:3287:8
#11 0x6358f8ed82b9 in js::jit::BaselineCompiler::emitBody() /home/lain/firefox/js/src/jit/BaselineCodeGen.cpp:7011:7
#12 0x6358f8ed2e70 in js::jit::BaselineCompiler::compileImpl() /home/lain/firefox/js/src/jit/BaselineCodeGen.cpp:283:8
#13 0x6358f8ed2cc7 in js::jit::BaselineCompiler::compile(JSContext*) /home/lain/firefox/js/src/jit/BaselineCodeGen.cpp:254:8
#14 0x6358f92ee16b in js::jit::BaselineCompile(JSContext*, JSScript*, js::EnumFlags<js::jit::BaselineOption>) /home/lain/firefox/js/src/jit/BaselineJIT.cpp:442:34
#15 0x6358f92f02f2 in CanEnterBaselineJIT(JSContext*, JS::Handle<JSScript*>, js::AbstractFramePtr) /home/lain/firefox/js/src/jit/BaselineJIT.cpp:549:10
#16 0x6358f92f0666 in js::jit::BaselineCompileFromBaselineInterpreter(JSContext*, js::jit::BaselineFrame*, unsigned char**) /home/lain/firefox/js/src/jit/BaselineJIT.cpp:695:25
#17 0x6358f92810c1 in js::jit::Simulator::SoftwareInterrupt() /home/lain/firefox/js/src/jit/riscv64/Simulator-riscv64.cpp:1630:7
#18 0x6358f927d3bb in js::jit::Simulator::InstructionDecode(js::jit::Instruction*) /home/lain/firefox/js/src/jit/riscv64/Simulator-riscv64.cpp:1832:7
#19 0x6358f92aba60 in void js::jit::Simulator::execute<false>() /home/lain/firefox/js/src/jit/riscv64/Simulator-riscv64.cpp:1942:5
#20 0x6358f92aba60 in js::jit::Simulator::callInternal(unsigned char*) /home/lain/firefox/js/src/jit/riscv64/Simulator-riscv64.cpp:4061:5
#21 0x6358f92ac1c7 in js::jit::Simulator::call(unsigned char*, int, ...) /home/lain/firefox/js/src/jit/riscv64/Simulator-riscv64.cpp:4126:3
#22 0x6358f92ec1f0 in EnterBaseline(JSContext*, EnterJitData&) /home/lain/firefox/js/src/jit/BaselineJIT.cpp:147:5
#23 0x6358f92ec1f0 in js::jit::EnterBaselineInterpreterAtBranch(JSContext*, js::InterpreterFrame*, unsigned char*) /home/lain/firefox/js/src/jit/BaselineJIT.cpp:202:26
#24 0x6358f815f8a5 in js::Interpret(JSContext*, js::RunState&) /home/lain/firefox/js/src/vm/Interpreter.cpp:2036:17
#25 0x6358f8158c1a in js::RunScript(JSContext*, js::RunState&) /home/lain/firefox/js/src/vm/Interpreter.cpp:460:13
#26 0x6358f815bc8d in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, js::AbstractFramePtr, JS::MutableHandle<JS::Value>) /home/lain/firefox/js/src/vm/Interpreter.cpp:851:13
#27 0x6358f815c0ee in js::Execute(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::MutableHandle<JS::Value>) /home/lain/firefox/js/src/vm/Interpreter.cpp:884:10
#28 0x6358f82f4671 in ExecuteScript(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSScript*>, JS::MutableHandle<JS::Value>) /home/lain/firefox/js/src/vm/CompilationAndEvaluation.cpp:548:10
#29 0x6358f82f4853 in JS_ExecuteScript(JSContext*, JS::Handle<JSScript*>) /home/lain/firefox/js/src/vm/CompilationAndEvaluation.cpp:572:10
#30 0x6358f808b856 in RunFile(JSContext*, char const*, _IO_FILE*, CompileUtf8, bool, bool) /home/lain/firefox/js/src/shell/js.cpp:1315:10
#31 0x6358f808ad59 in Process(JSContext*, char const*, bool, FileKind) /home/lain/firefox/js/src/shell/js.cpp
#32 0x6358f804335a in ProcessArgs(JSContext*, js::cli::OptionParser*) /home/lain/firefox/js/src/shell/js.cpp:12051:10
#33 0x6358f804335a in Shell(JSContext*, js::cli::OptionParser*) /home/lain/firefox/js/src/shell/js.cpp:12304:12
#34 0x6358f803a9a5 in main /home/lain/firefox/js/src/shell/js.cpp:12707:12
#35 0x7ac2f6029d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#36 0x7ac2f6029e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#37 0x6358f8001fc8 in _start (/home/lain/firefox/obj-fuzzbuild-riscv64/dist/bin/js+0x24c5fc8) (BuildId: fa41a80b5498d13baaf635a8dc39da52)
==211668==Register values:
rax = 0x0000000000000000 rbx = 0x0000000000100000 rcx = 0x0000000000000071 rdx = 0x00007ac2f621b723
rdi = 0x00007ac2f621ca60 rsi = 0x0000000000000000 rbp = 0x00007ffeb8176aa0 rsp = 0x00007ffeb8176a80
r8 = 0x0000000000000000 r9 = 0x0000000000000003 r10 = 0x0000000000000000 r11 = 0x0000000000000293
r12 = 0x00000000ffffffff r13 = 0x0000000000000001 r14 = 0x000000000000006f r15 = 0x0000000000000b78
UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV /home/lain/firefox/obj-fuzzbuild-riscv64/dist/include/mozilla/Assertions.h:237:3 in MOZ_CrashSequence(void*, long)
==211668==ABORTING
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 RISC-V assembler's veneer patching for short-range branches computes a jump offset that does not fit the immediate field, tripping the is_intn assertion when a constant pool is flushed during Baseline compilation.
Impact
The engine aborts on a debug assertion in a simulator build; the report does not show memory corruption or any effect on a released browser.
What the attacker needed
Riscv64 simulator debug build; attacker-supplied JavaScript file
How it was found
- Build the JavaScript shell with the riscv64 simulator and fuzzing options enabled.
- Run the shell against the attached poc.js with low warm-up thresholds and extra Ion checks.
- Observe the assertion failure and crash in the RISC-V assembler.
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; it compiles hot JavaScript into machine code at runtime. This report shows that a particular JavaScript file makes the engine's code generator trip an internal safety check (an assertion) and abort. It only happens in a special simulator build for the RISC-V processor, so it is a robustness bug rather than a proven way to attack a normal user.
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.