CVE-2022-24791: Wasmtime Use After Free Vulnerability
HIGHCVE-2022-24791 is a HIGH (CVSS 8.1) use after free vulnerability (CWE-416: Use After Free) affecting Wasmtime libraries in the crates.io ecosystem. The issue involves use after free in wasmtime. Remediation is available by upgrading affected packages to version 0.34.2, 0.35.2.
CVE-2022-24791 at a Glance
Security Impact
CVSS: 8.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-24791
To remediate this vulnerability, upgrade all affected Wasmtime dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade wasmtime to 0.34.2
Upgrade wasmtime to 0.35.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for wasmtime
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-24791, inspect your project dependencies for Wasmtime:
inspect dependencies for wasmtime
Analyze the terminal output to locate any version of Wasmtime in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.34.2), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. In Wasmtime, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-24791 Affected Wasmtime Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
wasmtime
|
crates.io |
< 0.34.2
|
0.34.2
|
|
wasmtime
|
crates.io |
≥ 0.35.0
< 0.35.2
|
0.35.2
|
References
Frequently Asked Questions
What is CVE-2022-24791?
Which Wasmtime versions are affected?
What version fixes CVE-2022-24791?
Is wasmtime affected?
What is the CVSS score of CVE-2022-24791?
What CWE is associated with CVE-2022-24791?
How can I check crates.io dependencies for CVE-2022-24791?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-gwc9-348x-qwv2",
"modified" : "2025-05-02T12:48:46Z",
"published" : "2022-04-01T13:36:12Z",
"aliases" : [ "CVE-2022-24791" ],
"summary" : "Use after free in Wasmtime",
"details" : "There is a use after free vulnerability in Wasmtime when both running Wasm that uses `externref`s and enabling [epoch interruption](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.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.\n\nThe 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.\n\nThis bug was discovered while extending our fuzz targets for `externref`s 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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "wasmtime"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.34.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "wasmtime"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.35.0"
}, {
"fixed" : "0.35.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-gwc9-348x-qwv2"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24791"
}, {
"type" : "WEB",
"url" : "https://github.com/bytecodealliance/wasmtime/commit/666c2554ea0e1728c35aa41178cf235920db888a"
}, {
"type" : "WEB",
"url" : "https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.epoch_interruption"
}, {
"type" : "WEB",
"url" : "https://github.com/WebAssembly/reference-types"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/bytecodealliance/wasmtime"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2022-0016.html"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2022-0099.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-416" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-04-01T13:36:12Z",
"nvd_published_at" : "2022-03-31T23:15:00Z"
}
}