Skip to content
Memory corruption Disclosed report Advanced CVE-2023-32211

Incorrect validation for repeated catch blocks

A crafted WebAssembly module crashes the JavaScript engine's WebAssembly compiler on ARM64 builds, causing a null-pointer read during bounds-check code generation. The text only demonstrates a crash in a debug build and does not show any way to gain control of execution.

P1umer Follow

Originally disclosed on Mozilla

  • Fixed in 23 days
  • Paid in 29 days
  • Disclosed after 23 days

Created attachment 9323912 poc.js

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36

Steps to reproduce:

The vulnerability exists in the Javascript engine under the ARM64 architecture, so it needs to be reproduced in the gecko in ARM64. The configuration for building is as follows:

ac_add_options --enable-fuzzing ac_add_options --enable-gczeal ac_add_options --enable-project=js ac_add_options --enable-optimize ac_add_options --enable-debug

Commit: 8ed22fcd56968c95a73a6c82b42f732f01a4bdae

Actual results:

This is the full crash log of the debug build:

UndefinedBehaviorSanitizer:DEADLYSIGNAL
==15739==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000024 (pc 0x000103a5abbc bp 0x00016db0ead0 sp 0x00016db0ea70 T644387)
==15739==The signal is caused by a READ memory access.
==15739==Hint: address points to the zero page.
    #0 0x103a5abbc in (anonymous namespace)::FunctionCompiler::checkOffsetAndAlignmentAndBounds(js::wasm::MemoryAccessDesc*, js::jit::MDefinition**)+0xd0 (js:arm64+0x10176ebbc) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #1 0x103a5c2d8 in (anonymous namespace)::FunctionCompiler::store(js::jit::MDefinition*, js::wasm::MemoryAccessDesc*, js::jit::MDefinition*)+0x134 (js:arm64+0x1017702d8) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #2 0x103a173e0 in EmitStore((anonymous namespace)::FunctionCompiler&, js::wasm::PackedType<js::wasm::ValTypeTraits>, JS::Scalar::Type)+0x2a0 (js:arm64+0x10172b3e0) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #3 0x1039c2700 in EmitBodyExprs((anonymous namespace)::FunctionCompiler&)+0x9cc (js:arm64+0x1016d6700) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #4 0x1039c08fc in js::wasm::IonCompileFunctions(js::wasm::ModuleEnvironment const&, js::wasm::CompilerEnvironment const&, js::LifoAlloc&, mozilla::Vector<js::wasm::FuncCompileInput, 8ul, js::SystemAllocPolicy> const&, js::wasm::CompiledCode*, mozilla::UniquePtr<char [], JS::FreePolicy>*)+0xdb4 (js:arm64+0x1016d48fc) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #5 0x10396e914 in ExecuteCompileTask(js::wasm::CompileTask*, mozilla::UniquePtr<char [], JS::FreePolicy>*)+0x19c (js:arm64+0x101682914) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #6 0x103970870 in js::wasm::ModuleGenerator::finishFuncDefs()+0x40 (js:arm64+0x101684870) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #7 0x10393d138 in bool DecodeCodeSection<js::wasm::Decoder>(js::wasm::ModuleEnvironment const&, js::wasm::Decoder&, js::wasm::ModuleGenerator&)+0x44c (js:arm64+0x101651138) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #8 0x10393cbd4 in js::wasm::CompileBuffer(js::wasm::CompileArgs const&, js::wasm::ShareableBytes const&, mozilla::UniquePtr<char [], JS::FreePolicy>*, mozilla::Vector<mozilla::UniquePtr<char [], JS::FreePolicy>, 0ul, js::SystemAllocPolicy>*, JS::OptimizedEncodingListener*)+0x300 (js:arm64+0x101650bd4) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #9 0x1039d8f60 in js::WasmModuleObject::construct(JSContext*, unsigned int, JS::Value*)+0x21c (js:arm64+0x1016ecf60) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #10 0x1023cee90 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&)+0x1a4 (js:arm64+0x1000e2e90) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #11 0x1023ddf00 in CallJSNativeConstructor(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), JS::CallArgs const&)+0xa4 (js:arm64+0x1000f1f00) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #12 0x1023d0400 in InternalConstruct(JSContext*, js::AnyConstructArgs const&, js::CallReason)+0x368 (js:arm64+0x1000e4400) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #13 0x1023c5c74 in Interpret(JSContext*, js::RunState&)+0x6830 (js:arm64+0x1000d9c74) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #14 0x1023bf030 in js::RunScript(JSContext*, js::RunState&)+0x1e8 (js:arm64+0x1000d3030) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #15 0x1023d111c in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, js::AbstractFramePtr, JS::MutableHandle<JS::Value>)+0x288 (js:arm64+0x1000e511c) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #16 0x1023d1624 in js::Execute(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::MutableHandle<JS::Value>)+0x200 (js:arm64+0x1000e5624) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #17 0x10251df58 in ExecuteScript(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSScript*>, JS::MutableHandle<JS::Value>)+0x100 (js:arm64+0x100231f58) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #18 0x10251e160 in JS_ExecuteScript(JSContext*, JS::Handle<JSScript*>)+0xd8 (js:arm64+0x100232160) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #19 0x102358d30 in RunFile(JSContext*, char const*, __sFILE*, CompileUtf8, bool, bool)+0x450 (js:arm64+0x10006cd30) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #20 0x1023582ac in Process(JSContext*, char const*, bool, FileKind)+0x8a4 (js:arm64+0x10006c2ac) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #21 0x1022fc88c in Shell(JSContext*, js::cli::OptionParser*)+0x115c (js:arm64+0x10001088c) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #22 0x1022f6d48 in main+0x690 (js:arm64+0x10000ad48) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00)
    #23 0x195867e4c  (<unknown module>)
    #24 0xda46fffffffffffc  (<unknown module>)

==15739==Register values:
 x[0] = 0x0000000000000001   x[1] = 0x0000000000000001   x[2] = 0x000000016db0eae0   x[3] = 0x0000000000000000
 x[4] = 0x0000000105413d3c   x[5] = 0x00000001039c26f4   x[6] = 0x000000010409ad00   x[7] = 0x000000016db0ea18
 x[8] = 0x00000001054173e7   x[9] = 0x0000000000000001  x[10] = 0x00000001054173e7  x[11] = 0x0000000002000000
x[12] = 0xf8000000ffffffff  x[13] = 0x0000000000000001  x[14] = 0x0000000000000001  x[15] = 0x000000010409b8c4
x[16] = 0x0000000103a8d188  x[17] = 0x00000000000002a1  x[18] = 0x0000000000000000  x[19] = 0x000000016db0eae0
x[20] = 0x000000016db0f020  x[21] = 0x000000016db0eb38  x[22] = 0x0000000000000000  x[23] = 0x0000000002000000
x[24] = 0xaaaaaaaaaaaa0039  x[25] = 0x0000000000000039  x[26] = 0x000000016db0f954  x[27] = 0xaaaaaaaaaaaaaaaa
x[28] = 0x0000000105413d3c     fp = 0x000000016db0ead0     lr = 0x0000000103a5ab78     sp = 0x000000016db0ea70
UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV (js:arm64+0x10176ebbc) (BuildId: 4c4c44b255553144a1deaf01cdd3b98d32000000200000000100000000000b00) in (anonymous namespace)::FunctionCompiler::checkOffsetAndAlignmentAndBounds(js::wasm::MemoryAccessDesc*, js::jit::MDefinition**)+0xd0
==15739==ABORTING

The original report as published on Mozilla's Bugzilla, by P1umer. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 WebAssembly compiler's bounds-check and alignment logic dereferences a missing or invalid value when handling certain store operations, which the report does not diagnose further.

Impact

The crafted module crashes the engine on ARM64 debug builds; the text does not claim memory corruption or code execution.

What the attacker needed

ARM64 build of the JS shell; debug build with sanitizers; run the supplied script

How it was found

  1. Build the JavaScript shell for ARM64 with the listed fuzzing and debug options.
  2. Run the attached proof-of-concept script in that shell.
  3. Observe the sanitizer crash in the WebAssembly compiler.

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 is a compact binary format that browsers compile to fast machine code. Here, a specially built WebAssembly module makes the compiler read from a bad memory address, so the browser process crashes. The report shows only a crash, not a way to run an attacker's 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.

More by P1umer

View all

4 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.