CVE-2022-24791 Use after free in Wasmtime
Attackers can trigger a use-after-free in Wasmtime by exploiting missing stack maps during garbage collection, potentially leading to code execution or crashes.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2022-24791?
CVE-2022-24791 is a high-severity use after free vulnerability in bytecodealliance wasmtime, published on 31 Mar 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
Wasmtime is a standalone JIT-style runtime for WebAssembly, using Cranelift. There is a use after free vulnerability in Wasmtime when both running Wasm that uses externrefs and enabling epoch interruption in Wasmtime. If you are not explicitly enabling epoch interruption (it is disabled by default) then you are not affected. If you are explicitly disabling the Wasm reference types proposal (it is enabled by default) then you are also not affected. The use after free is caused by Cranelift failing to emit stack maps when there are safepoints inside cold blocks. Cold blocks occur when epoch interruption is enabled. Cold blocks are emitted at the end of compiled functions, and change the order blocks are emitted versus defined. This reordering accidentally caused Cranelift to skip emitting some stack maps because it expected to emit the stack maps in block definition order, rather than block emission order. When Wasmtime would eventually collect garbage, it would fail to find live references on the stack because of the missing stack maps, think that they were unreferenced garbage, and therefore reclaim them. Then after the collection ended, the Wasm code could use the reclaimed-too-early references, which is a use after free. Patches have been released in versions 0.34.2 and 0.35.2, which fix the vulnerability. All Wasmtime users are recommended to upgrade to these patched versions. If upgrading is not an option for you at this time, you can avoid the vulnerability by either: disabling the Wasm reference types proposal, config.wasm_reference_types(false); or by disabling epoch interruption if you were previously enabling it. config.epoch_interruption(false).
Weakness: CWE-416
Which versions are affected by CVE-2022-24791?
6 open source packages ship an affected version, including wasmtime. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
wasmtime crates.io | All versions | 0.34.2 |
wasmtime crates.io | All versions | 0.34.2 |
wasmtime crates.io | From 0.0.0-0 | 0.34.2, 0.35.2 |
wasmtime crates.io | From 0.34.0 | 0.34.2, 0.35.2 |
wasmtime crates.io | From 0.35.0 | 0.35.2 |
wasmtime crates.io | From 0.35.0 | 0.35.2 |
Linux distribution packages (1)
cargo-audit-advisory-db openSUSE:Tumbleweed | All versions | 20220420-1.1 |
Products include Bytecodealliance Wasmtime.
How do I fix CVE-2022-24791?
Upgrade wasmtime to a fixed version for your release line: 0.34.2 or 0.35.2.
Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.
Is CVE-2022-24791 being exploited?
There is no known exploitation of CVE-2022-24791 in the wild and no public exploit code.
Other vulnerabilities in bytecodealliance wasmtime
- CVE-2026-34971 Wasmtime miscompiled guest heap access enables sandbox escape on aarch64 Cranelift
- CVE-2026-34987 Wasmtime with Winch compiler backend on aarch64 may allow a sandbox-escaping memory access
- CVE-2022-39393 Wasmtime vulnerable to data leakage between instances in the pooling allocator
- CVE-2026-47261 Wasmtime: WASI path_open(TRUNCATE) bypasses `FilePerms::WRITE` host restriction
- CVE-2026-34941 Wasmtime has a Heap OOB read in component model UTF-16 to latin1+utf16 string transcoding
Sources
Also known as GHSA-gwc9-348x-qwv2, RUSTSEC-2022-0016, RUSTSEC-2022-0099, UBUNTU-CVE-2022-24791, openSUSE-SU-2024:12009-1.