CVE-2022-24791

CVE-2022-24791 is a high-severity use after free vulnerability in wasmtime (rust), affecting versions < 0.34.2. It is fixed in 0.34.2, 0.35.2.

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.

Impact

Memory is accessed after it has been freed, leading to undefined behavior in native code. Typical impact: memory corruption, crash, or potential code execution.

CVE-2022-24791 has a CVSS score of 8.1 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.34.2, 0.35.2); upgrading removes the vulnerable code path.

Affected versions

wasmtime (< 0.34.2) wasmtime (>= 0.35.0, < 0.35.2)

Security releases

wasmtime → 0.34.2 (rust) wasmtime → 0.35.2 (rust)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

Upgrade the following packages to resolve this vulnerability:

wasmtime to 0.34.2 or later; wasmtime to 0.35.2 or later

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2022-24791? CVE-2022-24791 is a high-severity use after free vulnerability in wasmtime (rust), affecting versions < 0.34.2. It is fixed in 0.34.2, 0.35.2. Memory is accessed after it has been freed, leading to undefined behavior in native code.
  2. How severe is CVE-2022-24791? CVE-2022-24791 has a CVSS score of 8.1 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of wasmtime are affected by CVE-2022-24791? wasmtime (rust) versions < 0.34.2 is affected.
  4. Is there a fix for CVE-2022-24791? Yes. CVE-2022-24791 is fixed in 0.34.2, 0.35.2. Upgrade to this version or later.
  5. Is CVE-2022-24791 exploitable, and should I be worried? Whether CVE-2022-24791 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2022-24791 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2022-24791?
    • Upgrade wasmtime to 0.34.2 or later
    • Upgrade wasmtime to 0.35.2 or later

Other vulnerabilities in wasmtime

CVE-2026-44216CVE-2026-35186CVE-2026-34987CVE-2026-35195CVE-2026-34988

Stop the waste.
Protect your environment with Kodem.