Skip to main content

CVE-2022-24791 — Use after free in wasmtime — CVE Details

HIGH

Use after free in Wasmtime

Published April 1, 2022Updated May 2, 2025Source: OSV

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.

Check my Cargo.lock

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 wasmtime to 0.34.2 or later
cargo update -p wasmtime --precise 0.34.2
Cargo
Update wasmtime to 0.35.2 or later
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).

PackageFixed In
wasmtime crates.io · Affected: All versions0.34.2
wasmtime crates.io · Affected: All versions0.35.2

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 8.1 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
High
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

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

CVSS Score
8.1

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
1.16%
EPSS percentile: 67

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

GHSA-gwc9-348x-qwv2
RUSTSEC-2022-0016
RUSTSEC-2022-0099

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Cargo.lock