CVE-2022-24791 — Use after free in wasmtime — CVE Details
Use after free in Wasmtime
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.16%). Schedule for your next planned update.
Does your project use an affected wasmtime version?
Paste your Cargo.lock to check it for CVE-2022-24791 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
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.
This bug was discovered while extending our fuzz targets for externrefs and GC in Wasmtime. The updated fuzz target thoroughly exercises these code paths and feature combinations now. We have also added a regression test for this bug. Released versions 0.34.2 and 0.35.2, which fix the vulnerability. We recommend all Wasmtime users 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 or by disabling epoch interruption if you were previously enabling it.
Advisory Timeline
- First published April 1, 2022 (1700 days ago).
- Last revised May 2, 2025 — 1127 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
cargo update -p wasmtime --precise 0.34.2
cargo update -p wasmtime --precise 0.35.2
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (2)
Affects 1 ecosystem: crates.io (1).
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-416Use After FreeMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 8.1 score means for each attack dimension.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
References
- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-gwc9-348x-qwv2WEB
- https://nvd.nist.gov/vuln/detail/CVE-2022-24791ADVISORY
- https://github.com/bytecodealliance/wasmtime/commit/666c2554ea0e1728c35aa41178cf235920db888aWEB
- https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.epoch_interruptionWEB
- https://github.com/WebAssembly/reference-typesWEB
- https://github.com/bytecodealliance/wasmtimePACKAGE
- https://rustsec.org/advisories/RUSTSEC-2022-0016.htmlWEB
- https://rustsec.org/advisories/RUSTSEC-2022-0099.htmlWEB
Frequently Asked Questions
- What is CVE-2022-24791?
- Use after free in Wasmtime. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.1/10).
- How do I check if my project is affected by CVE-2022-24791?
- CVE-2022-24791 affects wasmtime. It has a 1.2% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2022-24791 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is an above-median EPSS score — 67% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
Also Known As
Related CVEs
- CVE-2026-34987CRITICAL
Wasmtime with Winch compiler backend on aarch64 may allow a sandbox-escaping memory access
- CVE-2022-39392HIGH
Bug in Wasmtime implementation of pooling instance allocator
- CVE-2022-39393HIGH
Data leakage between instances in the pooling allocator
- CVE-2022-39393HIGH
Wasmtime may have data leakage between instances in the pooling allocator
- CVE-2026-34946MEDIUM
Wasmtime has host panic when Winch compiler executes `table.fill`
- CVE-2024-47763MEDIUM
wasmtime has a runtime crash when combining tail calls with trapping imports
- CVE-2026-34944MEDIUM
Wasmtime segfault or unused out-of-sandbox load with `f64x2.splat` operator on x86-64
- CVE-2026-27195MEDIUM
Wasmtime is vulnerable to panic when dropping a `[Typed]Func::call_async` future