AddressSanitizer: TRAP on unknown address in js::wasm::Instance::callExport
A crafted JavaScript file causes the SpiderMonkey JavaScript engine to crash with an AddressSanitizer TRAP when a WebAssembly export is called. The crash occurs inside the engine's WebAssembly instance code, indicating a memory-safety fault reachable from script.
- Fixed in 7 days
- Paid in 8 days
- Disclosed after 7 days
Created attachment 9442834 poc.js
Reproduce
- Download linux-asan-debug spidermonkey
- run poc.js
ASAN LOG
/home/sakura/.cache/autobisect/builds/js-m-c-linux-asan-debug-b16c09f16ef5/dist/bin/js poc.js
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1915891==ERROR: AddressSanitizer: TRAP on unknown address 0x000000000000 (pc 0x1ef308b5010d bp 0x7ffe78c211d0 sp 0x7ffe78c21150 T0)
/home/sakura/.cache/autobisect/builds/js-m-c-linux-asan-debug-b16c09f16ef5/dist/bin/llvm-symbolizer: error: '[anon:js-executable-memory]': No such file or directory
#0 0x1ef308b5010d ([anon:js-executable-memory]+0x2010d)
#1 0x1ef308b50b3e ([anon:js-executable-memory]+0x20b3e)
#2 0x557cdc9c01df in js::wasm::Instance::callExport(JSContext*, unsigned int, JS::CallArgs const&, js::wasm::CoercionLevel) /builds/worker/checkouts/gecko/js/src/wasm/WasmInstance.cpp:3695:10
#3 0x557cdc9be4c3 in WasmCall(JSContext*, unsigned int, JS::Value*) /builds/worker/checkouts/gecko/js/src/wasm/WasmInstance.cpp:3479:19
#4 0x557cd986c122 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:532:13
#5 0x557cd986ada6 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:628:12
#6 0x557cd988cfcc in js::CallFromStack(JSContext*, JS::CallArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:700:10
#7 0x557cd988cfcc in js::Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:3338:16
#8 0x557cd98690a5 in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:502:13
#9 0x557cd98714e4 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, js::AbstractFramePtr, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:893:13
#10 0x557cd9872179 in js::Execute(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:926:10
#11 0x557cd9bb9b0a in ExecuteScript(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSScript*>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/CompilationAndEvaluation.cpp:601:10
#12 0x557cd9bb9f8f in JS_ExecuteScript(JSContext*, JS::Handle<JSScript*>) /builds/worker/checkouts/gecko/js/src/vm/CompilationAndEvaluation.cpp:625:10
#13 0x557cd95ddbae in RunFile(JSContext*, char const*, _IO_FILE*, CompileUtf8, bool, bool) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:1307:10
#14 0x557cd95dc555 in Process(JSContext*, char const*, bool, FileKind) /builds/worker/checkouts/gecko/js/src/shell/js.cpp
#15 0x557cd9501512 in ProcessArgs(JSContext*, js::cli::OptionParser*) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:11741:10
#16 0x557cd9501512 in Shell(JSContext*, js::cli::OptionParser*) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:11993:12
#17 0x557cd94ef02e in main /builds/worker/checkouts/gecko/js/src/shell/js.cpp:12408:12
#18 0x7fc795a29d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
==1915891==Register values:
rax = 0x000033fc75300080 rbx = 0x00002241d35710e0 rcx = 0x0000507000000480 rdx = 0x0000507000004310
rdi = 0x0000000000000000 rsi = 0x0000000000000000 rbp = 0x00007ffe78c211d0 rsp = 0x00007ffe78c21150
r8 = 0x00000fffcf1842dd r9 = 0x00007ffe78c21700 r10 = 0x00007ffe78c21428 r11 = 0x00000000ffffffff
r12 = 0x00007ffe78c21248 r13 = 0x00007ffe78c21428 r14 = 0x0000519000086b80 r15 = 0x00007fc58b3ab000
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: TRAP ([anon:js-executable-memory]+0x2010d)
==1915891==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 a memory-safety flaw in the WebAssembly export-call path, where the engine jumps to an invalid address during callExport.
Impact
A crafted script could crash the JavaScript engine, and the memory-safety nature suggests possible further exploitation, though the report only demonstrates a crash.
What the attacker needed
Ability to run a crafted script in the 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.
SpiderMonkey is the JavaScript engine inside Firefox. WebAssembly lets a web page run compiled code inside that engine. Here a specially crafted script made the engine jump to an invalid memory address and crash, which is a memory-safety bug rather than a normal error.
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.