SIMD load/store lane always accesses memory 0 on x86_64
A bug in SpiderMonkey's WebAssembly SIMD load/store lane implementation causes an out-of-bounds write on x86_64, crashing the engine. An attacker could potentially exploit this memory corruption by supplying a crafted wasm module.
- Fixed in 8 days
- Paid in 22 days
- Disclosed after 8 days
Created attachment 9432711
2.js
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Steps to reproduce:
version:
commit 3618a8a64555259091cff07cddebbe58ded841ac (HEAD -> bookmarks/central, origin/bookmarks/central, refs/cinnabar/refs/heads/bookmarks/central)
Author: Lee Salzman <[address removed]>
Date: Sun Oct 20 15:47:44 2024 +0000
Bug 1925561 - Use a quicker radius calculation for ArcParams. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D226242
build spidermonkey with:
../configure --enable-debug --enable-wasm-js-string-builtins --enable-optimize --disable-tests --enable-wasm-simd --enable-wasm-avx --enable-wasm-moz-intgemm
run with:
js poc.js
Actual results:
oob write,gdb crash:
Thread 1 "js" received signal SIGSEGV, Segmentation fault.
0x00001e6e4b85c06b in ?? ()
LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA
───────────────────────────────────────────[ REGISTERS / show-flags off / show-compact-regs off ]───────────────────────────────────────────
RAX 0x7dfc2dc01000 ◂— 0
RBX 0x7ffeed7abaf0 —▸ 0x7dfe34736200 ◂— 0
RCX 1
RDX 0x3015c41
RDI 0x64
RSI 0
R8 1
R9 5
R10 0x7ffeed7abe38 ◂— 0x64 /* 'd' */
R11 0x3fff
R12 0x7ffeed7ab9f8 —▸ 0x7ffeed7abaf0 —▸ 0x7dfe34736200 ◂— 0
R13 0x7dfe34719c00 —▸ 0x7dfe32001000 ◂— 0
R14 0x7dfe34719c00 —▸ 0x7dfe32001000 ◂— 0
R15 0x7dfe32001000 ◂— 0
RBP 0x7ffeed7ab980 —▸ 0x7ffeed7ab9e0 —▸ 0x7ffeed7abef0 —▸ 0x7ffeed7abf60 —▸ 0x7ffeed7abfc0 ◂— ...
RSP 0x7ffeed7ab980 —▸ 0x7ffeed7ab9e0 —▸ 0x7ffeed7abef0 —▸ 0x7ffeed7abf60 —▸ 0x7ffeed7abfc0 ◂— ...
RIP 0x1e6e4b85c06b ◂— vmovlps qword ptr [r15 + rdx + 0x601], xmm0
────────────────────────────────────────────────────[ DISASM / x86-64 / set emulate on ]────────────────────────────────────────────────────
► 0x1e6e4b85c06b vmovlps qword ptr [r15 + rdx + 0x601], xmm0
0x1e6e4b85c075 jmp 0x1e6e4b85c030 <0x1e6e4b85c030>
↓
0x1e6e4b85c030 cmp dword ptr [r14 + 0x40], 0 0 - 0 EFLAGS => 0x10246 [ cf PF af ZF sf IF df of ]
0x1e6e4b85c035 jne 0x1e6e4b85c080 <0x1e6e4b85c080>
0x1e6e4b85c03b cmp dword ptr [r14 + 0x40], 0 0 - 0 EFLAGS => 0x10246 [ cf PF af ZF sf IF df of ]
0x1e6e4b85c040 jne 0x1e6e4b85c084 <0x1e6e4b85c084>
0x1e6e4b85c046 sub ecx, 1 ECX => 0 (1 - 1)
0x1e6e4b85c049 test ecx, ecx 0 & 0 EFLAGS => 0x10246 [ cf PF af ZF sf IF df of ]
0x1e6e4b85c04b ✔ je 0x1e6e4b85c077 <0x1e6e4b85c077>
↓
0x1e6e4b85c077 mov eax, dword ptr [r14 + 0x368] EAX, [0x7dfe34719f68] => 1
0x1e6e4b85c07e pop rbp RBP => 0x7ffeed7ab9e0
─────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────
00:0000│ rbp rsp 0x7ffeed7ab980 —▸ 0x7ffeed7ab9e0 —▸ 0x7ffeed7abef0 —▸ 0x7ffeed7abf60 —▸ 0x7ffeed7abfc0 ◂— ...
01:0008│+008 0x7ffeed7ab988 —▸ 0x1e6e4b85c0ff ◂— test spl, 0xf
02:0010│+010 0x7ffeed7ab990 —▸ 0x7dfe34719c00 —▸ 0x7dfe32001000 ◂— 0
03:0018│+018 0x7ffeed7ab998 —▸ 0x5b4a8d3168cd (js::CheckContextLocal::check() const+109) ◂— test al, al
04:0020│+020 0x7ffeed7ab9a0 —▸ 0x5b4a8f902970 (__afl_area_initial) ◂— 0x10000000012
05:0028│+028 0x7ffeed7ab9a8 —▸ 0x7dfe34736200 ◂— 0
06:0030│+030 0x7ffeed7ab9b0 ◂— 0
07:0038│+038 0x7ffeed7ab9b8 —▸ 0x7dfe34736320 —▸ 0x7dfe34736200 ◂— 0
If can not reproduce,please try several times
Expected results:
parse wasm module normally
Reporter credit as:
Sun ZhiWei From Lenovo GIC CLS
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
What the attacker needed
Ability to run a crafted wasm module; x86_64 platform
How it was found
- Build SpiderMonkey with the listed configure flags enabling wasm SIMD and AVX.
- Run the JavaScript proof-of-concept file with the js shell.
- Observe the out-of-bounds write and crash in gdb.
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.
WebAssembly (wasm) is a fast, low-level code format that browsers run. SpiderMonkey is Firefox's JavaScript engine, which also runs wasm. A SIMD instruction lets code process several values at once, and a bug in how one such instruction writes to memory caused the engine to write outside the intended buffer, crashing it.
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.