Skip to content
Memory corruption Disclosed report Advanced CVE-2024-7520

Assertion failure: superSTV, at /builds/worker/checkouts/gecko/js/src/wasm/WasmTypeDef.h:872

Nan Wang Follow

Originally disclosed on Mozilla

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

Created attachment 9407870 poc.js

Reproduce

  1. Clone the Firefox mirror from https://github.com/mozilla/gecko-dev
  2. Run build command mkdir fuzzbuild_OPT.OBJ && cd fuzzbuild_OPT.OBJ && ../configure --enable-address-sanitizer --disable-jemalloc --enable-debug --enable-optimize --disable-shared-js --enable-application=js --enable-gczeal && make -j64 in the js/src directory of the firefox checkout
  3. Run poc: js/src/fuzzbuild_OPT.OBJ/dist/bin/js poc.js
  • my test spidermonkey commit hash
commit 30dfc0e2fcfec889f94fbd0ec5f20822c276c0fb (HEAD -> master, origin/master, origin/HEAD)
Author: Makoto Kato <[address removed]>
Date:   Mon Jun 17 02:03:33 2024 +0000

    Bug 1899411 - Part 6. Adjust test results after upgrading ICU4X to 1.5. r=jfkthame,spidermonkey-reviewers,anba
    
    Differential Revision: https://phabricator.services.mozilla.com/D213011

Bisect

Additionally, I ran autobisect, which bisected to the point where wasm-gc was enabled by default, so I believe this bug has existed since that code was introduced.

https://github.com/mozilla/gecko-dev/commit/827fdc584e706875a4293ab7e5700766fcc68602

Debug Log

(autobisect-py3.10) ➜  autobisect git:(master) ✗ /home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js poc.js
[1879183] Assertion failure: superSTV, at /builds/worker/checkouts/gecko/js/src/wasm/WasmTypeDef.h:872
#01: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x68088d4]
#02: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x6807313]
#03: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x6f69525]
#04: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x6fc3f41]
#05: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x6f75620]
#06: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x6bf3cd1]
#07: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x6cf9e2b]
#08: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x3c965cb]
#09: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x3cf5565]
#10: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x3c99718]
#11: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x3cb4d01]
#12: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x3c93767]
#13: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x3c9ba61]
#14: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x3c9c70a]
#15: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x407278a]
#16: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x4072c38]
#17: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x39a1007]
#18: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x399f900]
#19: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x38c088f]
#20: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x38b0dde]
#21: ???[/lib/x86_64-linux-gnu/libc.so.6 +0x29d90]
#22: __libc_start_main[/lib/x86_64-linux-gnu/libc.so.6 +0x29e40]
#23: ???[/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js +0x37bd079]
#24: ??? (???:???)
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1879183==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x56402d3e1909 bp 0x7fff47706280 sp 0x7fff47706260 T0)
==1879183==The signal is caused by a WRITE memory access.
==1879183==Hint: address points to the zero page.
    #0 0x56402d3e1909 in js::wasm::TypeDef::isSubTypeOf(js::wasm::TypeDef const*, js::wasm::TypeDef const*) /builds/worker/checkouts/gecko/js/src/wasm/WasmTypeDef.h:872:5
    #1 0x56402d3e0312 in js::wasm::RefType::isSubTypeOf(js::wasm::RefType, js::wasm::RefType) /builds/worker/checkouts/gecko/js/src/wasm/WasmTypeDef.h:1461:12
    #2 0x56402db42524 in js::wasm::PackedType<js::wasm::StorageTypeTraits>::isSubTypeOf(js::wasm::PackedType<js::wasm::StorageTypeTraits>, js::wasm::PackedType<js::wasm::StorageTypeTraits>) /builds/worker/checkouts/gecko/js/src/wasm/WasmValType.h:889:14
    #3 0x56402db9cf40 in js::wasm::StructType::canBeSubTypeOf(js::wasm::StructType const&, js::wasm::StructType const&) /builds/worker/checkouts/gecko/js/src/wasm/WasmTypeDef.h:366:12
    #4 0x56402db4e61f in DecodeTypeSection(js::wasm::Decoder&, js::wasm::ModuleEnvironment*) /builds/worker/checkouts/gecko/js/src/wasm/WasmValidate.cpp:1885:14
    #5 0x56402db4e61f in js::wasm::DecodeModuleEnvironment(js::wasm::Decoder&, js::wasm::ModuleEnvironment*) /builds/worker/checkouts/gecko/js/src/wasm/WasmValidate.cpp:3023:8
    #6 0x56402d7cccd0 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*) /builds/worker/checkouts/gecko/js/src/wasm/WasmCompile.cpp:806:29
    #7 0x56402d8d2e2a in js::WasmModuleObject::construct(JSContext*, unsigned int, JS::Value*) /builds/worker/checkouts/gecko/js/src/wasm/WasmJS.cpp:1514:7
    #8 0x56402a86f5ca in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:487:13
    #9 0x56402a8ce564 in CallJSNativeConstructor(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:503:8
    #10 0x56402a872717 in InternalConstruct(JSContext*, js::AnyConstructArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:709:14
    #11 0x56402a88dd00 in js::ConstructFromStack(JSContext*, JS::CallArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:756:10
    #12 0x56402a88dd00 in js::Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:3276:16
    #13 0x56402a86c766 in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:459:13
    #14 0x56402a874a60 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:846:13
    #15 0x56402a875709 in js::Execute(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:878:10
    #16 0x56402ac4b789 in ExecuteScript(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSScript*>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/CompilationAndEvaluation.cpp:494:10
    #17 0x56402ac4bc37 in JS_ExecuteScript(JSContext*, JS::Handle<JSScript*>) /builds/worker/checkouts/gecko/js/src/vm/CompilationAndEvaluation.cpp:518:10
    #18 0x56402a57a006 in RunFile(JSContext*, char const*, _IO_FILE*, CompileUtf8, bool, bool) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:1194:10
    #19 0x56402a5788ff in Process(JSContext*, char const*, bool, FileKind) /builds/worker/checkouts/gecko/js/src/shell/js.cpp
    #20 0x56402a49988e in ProcessArgs(JSContext*, js::cli::OptionParser*) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:11255:10
    #21 0x56402a49988e in Shell(JSContext*, js::cli::OptionParser*) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:11507:12
    #22 0x56402a489ddd in main /builds/worker/checkouts/gecko/js/src/shell/js.cpp:12033:12
    #23 0x7f83eac29d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #24 0x7f83eac29e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #25 0x56402a396078 in _start (/home/test/.cache/autobisect/builds/js-m-c-linux-asan-debug-12d5ea126a22/dist/bin/js+0x37bd078) (BuildId: 562e16ed839a2453983df25de4080114854810c8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /builds/worker/checkouts/gecko/js/src/wasm/WasmTypeDef.h:872:5 in js::wasm::TypeDef::isSubTypeOf(js::wasm::TypeDef const*, js::wasm::TypeDef const*)
==1879183==ABORTING

The original report as published on Mozilla's Bugzilla, by Nan Wang. 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.

What is known

A high-severity memory corruption bug in JavaScript: WebAssembly. Mozilla made it public on 12 July 2024 as CVE-2024-7520.

About 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.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

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 Nan Wang

View all

13 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.