Stale GC heap base pointer in compiled code lets a Wasm guest abort the host process
Description
A Wasm guest that never allocates GC objects or accesses GC fields itself, but which does test or downcast GC references it is explicitly given from an imported host function, can interpret the GC reference as relative to the initial null GC heap base pointer, rather than the real GC heap base pointer, and trigger loads within the first ~4GiB of host memory. The Wasm guest cannot read the loaded values, only trigger the loads, but they can (and likely will) will hit an unmapped page and abort the host process.
Details
A Store allocates its GC heap lazily, and until it is allocated, the GC heap's base pointer is null (technically NonNull::<u8>::dangling() aka 1). When instantiating a Wasm module in a store, if the module as marked as needs_gc_heap, then the GC heap is allocated before the Wasm module is instantiated. The needs_gc_heap flag is set during Wasm compilation whenever translating a GC object allocation (such as struct.new, field or array access (such as array.get), etc... via the use of a GcCompiler. However, there are a small handful of GC operations that are agnostic to whichever garbage collector is configured and only operate on the common GC header word shared by all of Wasmtime's collectors (such as ref.test).
Translating these operations does not construct a GcCompiler and so they do not set needs_gc_heap. In common configurations, and the default configuration on many platforms, the GC heap does not move in host memory (i.e. it is resized in-place via the virtual memory system), and so its loads can be deduplicated (GVN) and lifted out of loops (LICM) in compiled Wasm code.
When needs_gc_heap was incorrectly not set, the compiled Wasm code could therefore load the null GC heap base pointer before the GC heap was allocated, then call an imported host function that allocates an object (allocating the GC heap in the process) and returns it to Wasm, and then Wasm could perform some collector-agnostic operation like ref.test on the object, which would reuse the null GC heap base pointer it read earlier, resulting in the GC reference being interpreted relative to that null base pointer rather than the real GC heap base pointer, allowing for Wasm code to trigger loads within the first 4GiB of host memory, most likely hitting an unmapped page and aborting the host process.
Note that the Wasm guest cannot actually read the the host memory and inspect the bytes, it can only trigger Wasmtime to load from it and compare it against a small handful of fixed values.
Impact
Denial of service of the host process by a guest.
If you disable the Wasm GC proposal, you are not affected.
If you do not expose a host function that allocates and returns GC objects to Wasm, you are not affected.