Inappropriate implementation in V8 (CVE-2024-2174)
A bug in V8's WebAssembly implementation causes a segmentation fault when running a crafted JavaScript file. An attacker could potentially crash the browser or execute arbitrary code.
5f46f4ee2e17957ba7b39897fb376be8 Follow
Originally disclosed on Chrome VRP
- Fix shipped in 16 days
VULNERABILITY DETAILS
INTRODUCE
After bisect, it was determined that following commit caused this problem.
- Commit Info
- Version: 92235
- link: https://crrev.com/a8ebbdaa7682de435750db680d3e127c441c2d68
- Commit Message
commit a8ebbdaa7682de435750db680d3e127c441c2d68
Author: Clemens Backes <[email protected]>
Date: Wed Feb 7 15:07:13 2024 +0100
[wasm] Remove indirect function tables from instance data
All compilers are switched to use the WasmDispatchTable. Hence the
fields are unused and can be removed.
A follow-up CL will remove the whole WasmIndirectFunctionTable class.
[email protected]
Bug: v8:14564
Change-Id: I06469401ab6aa1b565cd8552e98b749b96f5985d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5272234
Reviewed-by: Andreas Haas <[email protected]>
Commit-Queue: Clemens Backes <[email protected]>
Cr-Commit-Position: refs/heads/main@{#92235}
CRASH LOG
- Debug output
# CMD: /tmp/d8-linux-debug-v8-component-92403/d8 --allow-natives-syntax --expose-gc --future --fuzzing --harmony --omit-quit --js-staging --wasm-staging poc.js
# OUTPUT ==============================================================
Received signal 11 SEGV_MAPERR 5b0000000000
==== C stack trace ===============================
[0x7ffff7faf873]
[0x7ffff7faf7c2]
[0x7ffff2642520]
[0x7ffff5a4feaa]
[0x7ffff5b4da52]
[0x7ffff5846a4e]
[0x7ffff5862cc9]
[0x7ffff5a45da6]
[0x7ffff5b4930f]
[0x7ffff5a3f5f9]
[0x7ffff5a3df6d]
[0x7ffff5a696b8]
[0x7ffff5a69146]
[0x7ffff6e9643b]
[end of stack trace]
Thread 1 "d8" received signal SIGSEGV, Segmentation fault.
0x000020ff8b22557d in ?? ()
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
──────────────────────────────────────────────────────────────────────────[ REGISTERS / show-flags off / show-compact-regs off ]───────────────────────────────────────────────────────────────────────────
*RAX 0x117b80000000 ◂— 0x0
RBX 0x0
*RCX 0x2
*RDX 0x5447c888
*RDI 0x555559de9510 (__start___sancov_guards+3621040) ◂— 0x2e073000403b3
*RSI 0x12df00042269 ◂— 0xf90040040000001f
R8 0x0
R9 0x0
*R10 0x20ff8b225567 ◂— mov qword ptr [r13 + 0x70], 0 /* 0x7045c749 */
*R11 0x246
*R12 0x174594
*R13 0x55555a6ed080 —▸ 0x5555597b6800 (Builtins_AdaptorWithBuiltinExitFrame) ◂— mov ecx, dword ptr [rdi + 0xf]
*R14 0x117800000000 ◂— 0x10240
*R15 0x59b00234
*RBP 0x7fffffffcde0 —▸ 0x7fffffffce18 —▸ 0x7fffffffcfe8 —▸ 0x7fffffffd088 —▸ 0x7fffffffd0e8 ◂— ...
*RSP 0x7fffffffcbd8 —▸ 0x55555a6ed280 —▸ 0x117800000941 ◂— 0x326000000000004
*RIP 0x20ff8b22557d ◂— movzx ecx, byte ptr [rax + rdx + 0x2b2b] /* 0x2b2b108cb60f */
───────────────────────────────────────────────────────────────────────────────────[ DISASM / x86-64 / set emulate on ]────────────────────────────────────────────────────────────────────────────────────
► 0x20ff8b22557d movzx ecx, byte ptr [rax + rdx + 0x2b2b]
0x20ff8b225585 mov edx, dword ptr [rbp - 0xe4]
0x20ff8b22558b mov r10, rsp
0x20ff8b22558e sub rsp, 8
0x20ff8b225592 and rsp, 0xfffffffffffffff0
0x20ff8b225596 mov qword ptr [rsp], r10
0x20ff8b22559a mov esi, ecx
0x20ff8b22559c mov edi, edx
0x20ff8b22559e mov rax, qword ptr [rip - 0x1536]
0x20ff8b2255a5 lea r10, [rip + 0xa]
0x20ff8b2255ac mov qword ptr [r13 + 0x78], r10
─────────────────────────────────────────────────────────────────────────────────────────────────[ STACK ]─────────────────────────────────────────────────────────────────────────────────────────────────
00:0000│ rsp 0x7fffffffcbd8 —▸ 0x55555a6ed280 —▸ 0x117800000941 ◂— 0x326000000000004
01:0008│-200 0x7fffffffcbe0 —▸ 0x7fffffffcc20 —▸ 0x7fffffffccc0 —▸ 0x55555a6ed280 —▸ 0x117800000941 ◂— ...
02:0010│-1f8 0x7fffffffcbe8 —▸ 0x555557d7aad3 (v8::internal::(anonymous namespace)::ClearThreadInWasmScope::~ClearThreadInWasmScope()+467) ◂— mov dword ptr [rbx], 1
03:0018│-1f0 0x7fffffffcbf0 —▸ 0x55555a5d91c0 (__afl_area_initial) ◂— 0x0
04:0020│-1e8 0x7fffffffcbf8 —▸ 0x55555a6ed000 —▸ 0x117800000000 ◂— 0x10240
05:0028│-1e0 0x7fffffffcc00 —▸ 0x555559a66000 (v8::internal::v8_flags) ◂— 0x100000000000000
06:0030│-1d8 0x7fffffffcc08 —▸ 0x55555a7600c0 —▸ 0x55555a6ec1e8 ◂— 0x0
07:0038│-1d0 0x7fffffffcc10 —▸ 0x1178001d5d91 ◂— 0xfd0000fffd0000ff
───────────────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]───────────────────────────────────────────────────────────────────────────────────────────────
► 0 0x20ff8b22557d
1 0x55555a6ed280
2 0x7fffffffcc20
3 0x555557d7aad3 v8::internal::(anonymous namespace)::ClearThreadInWasmScope::~ClearThreadInWasmScope()+467
4 0x555557d7aad3 v8::internal::(anonymous namespace)::ClearThreadInWasmScope::~ClearThreadInWasmScope()+467
5 0x555559869c4a Builtins_JSToWasmWrapperAsm+138
6 0x55555998fbd3 Builtins_JSToWasmWrapper+2835
7 0x5555597c672d Builtins_InterpreterEntryTrampoline+301
──────────────────────────────────────────────────────────────────────────────────────────[ THREADS (49 TOTAL) ]───────────────────────────────────────────────────────────────────────────────────────────
► 1 "d8" stopped: 0x20ff8b22557d
2 "V8 DefaultWorke" stopped: 0x7ffff7c91117 <__futex_abstimed_wait_cancelable64+231>
3 "V8 DefaultWorke" stopped: 0x7ffff7c91117 <__futex_abstimed_wait_cancelable64+231>
4 "V8 DefaultWorke" stopped: 0x7ffff7c91117 <__futex_abstimed_wait_cancelable64+231>
Not showing 45 thread(s). Use set context-max-threads <number of threads> to change this.
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
pwndbg> bt
#0 0x000020ff8b22557d in ?? ()
#1 0x000055555a6ed280 in ?? ()
#2 0x00007fffffffcc20 in ?? ()
#3 0x0000555557d7aad3 in v8::internal::trap_handler::SetThreadInWasm () at ../../src/trap-handler/trap-handler.h:164
#4 v8::internal::(anonymous namespace)::ClearThreadInWasmScope::~ClearThreadInWasmScope (this=<optimized out>) at ./../../src/runtime/runtime-wasm.cc:111
#5 0x0000555559869c4a in Builtins_JSToWasmWrapperAsm ()
#6 0x000055555998fbd3 in Builtins_JSToWasmWrapper ()
#7 0x00005555597c672d in Builtins_InterpreterEntryTrampoline ()
#8 0x0000117800143891 in ?? ()
#9 0x0000117800000061 in ?? ()
#10 0x0000117800000061 in ?? ()
#11 0x0000117800000061 in ?? ()
#12 0x000011780016a5e5 in ?? ()
#13 0x000011780016a5f5 in ?? ()
#14 0x000011780016a63d in ?? ()
#15 0x0000117800169df1 in ?? ()
#16 0x0000117800168b9d in ?? ()
#17 0x000011780016a659 in ?? ()
#18 0x000011780016a5e5 in ?? ()
#19 0x000011780016a5f5 in ?? ()
#20 0x0000117800000061 in ?? ()
#21 0x00000000000000de in ?? ()
#22 0x000012df000421dd in ?? ()
#23 0x0000000000000001 in ?? ()
#24 0x000011780016811d in ?? ()
#25 0x00001178001438ed in ?? ()
#26 0x00007fffffffd0e8 in ?? ()
#27 0x00005555597c672d in Builtins_InterpreterEntryTrampoline ()
#28 0x0000117800143891 in ?? ()
#29 0x00001178001680e5 in ?? ()
#30 0x000011780016811d in ?? ()
#31 0x0000117800000061 in ?? ()
#32 0x0000117800000061 in ?? ()
#33 0x000000000000006c in ?? ()
#34 0x000012df00042151 in ?? ()
#35 0x0000000000000002 in ?? ()
#36 0x00001178001680e5 in ?? ()
#37 0x00001178001438ed in ?? ()
#38 0x00007fffffffd118 in ?? ()
#39 0x00005555597c381c in Builtins_JSEntryTrampoline ()
#40 0x0000117800143891 in ?? ()
#41 0x000011780016a66d in ?? ()
#42 0x00001178001680e5 in ?? ()
#43 0x000000000000002c in ?? ()
#44 0x00007fffffffd180 in ?? ()
#45 0x00005555597c3547 in Builtins_JSEntry ()
Other
Please note to include the flags --allow-natives-syntax --expose-gc --future --fuzzing --harmony --omit-quit --js-staging --wasm-staging for clusterfuzz classification.
VERSION Tested on v8 version: 12.3.0 - 12.4.0
REPRODUCTION CASE
- Download debug v8 from: gs://v8-asan/linux-debug/d8-linux-debug-v8-component-92403.zip
- Run:
d8 --allow-natives-syntax --expose-gc --future --fuzzing --harmony --omit-quit --js-staging --wasm-staging poc.js
FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION Type of crash: tab
CREDIT INFORMATION Reporter credit: Jerry
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 use-after-free or type confusion in WebAssembly indirect function table handling after a code change removed table fields from instance data.
What the attacker needed
Victim runs crafted JavaScript
How it was found
- Download the debug build of V8.
- Run the d8 shell with the provided flags on the poc.js file.
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.
This report describes a crash in V8, the JavaScript engine used by Chrome. A specially crafted JavaScript file can cause the engine to access invalid memory, leading to a crash. This could be exploited by an attacker to run malicious code on a victim's computer.
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.