Fitzgen

#9358of 61,747
35Total CVSS
Vulnerabilities · 6
Low
1
Medium
5
PT-2021-22468
2021-09-17
6.3
CVE-2021-39216
Wasmtime
Wasmtime
The issue is related to a use-after-free bug when passing `externref`s from the host to guest Wasm content. To trigger the bug, multiple `externref`s must be passed from the host to a Wasm instance at the same time. The bug can be triggered by passing multiple `externref`s as arguments from host code to a Wasm function or returning multiple `externref`s to Wasm from a multi-value return function defined in the host. If Wasmtime's `VMExternRefActivationsTable` becomes filled to capacity after passing the first `externref` in, then passing in the second `externref` could trigger a garbage collection. However, the first `externref` is not rooted until control is passed to Wasm, and therefore could be reclaimed by the collector if nothing else was holding a reference to it or otherwise keeping it alive. Then, when control was passed to Wasm after the garbage collection, Wasm could use the first `externref`, which at this point has already been freed. Additionally, there is an invalid free and out-of-bounds read and write bug when running Wasm that uses `externref`s in Wasmtime. The bug can be triggered when Wasmtime is running Wasm that uses `externref`s, the host creates non-null `externrefs`, Wasmtime performs a garbage collection, and there has to be a Wasm frame on the stack that is at a GC safepoint where there are no live references at this safepoint, and there is a safepoint with live references earlier in this frame's function. The estimated impact of these bugs is relatively small because usage of `externref` is currently quite rare.