CVE-2022-24791
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: Use After Free
CISA SSVC decision points
| Exploitation | none |
|---|---|
| Automatable | no |
| Technical impact | total |
| Scored | 2025-04-23 |
Timeline
- 2022-03-31Published by the CNA23:00 UTC
- 2022-04-01GitHub advisory published (GHSA-gwc9-348x-qwv2)1 day after publication
- 2025-04-23CISA SSVC decision recorded1119 days after publication
Exploit and advisory records
GitHub advisory GHSA-gwc9-348x-qwv2, affected packages:
| Package | Vulnerable versions | Fixed in |
|---|---|---|
| crates.io wasmtime | before 0.34.2 | 0.34.2 |
| crates.io wasmtime | from 0.35.0 before 0.35.2 | 0.35.2 |
Affected products
Products listed as vulnerable. Upgrade to the version under "Fixed in", or a later one.
| Product | Vulnerable versions | Fixed in |
|---|---|---|
| bytecodealliance wasmtime | from 0.34.0 before 0.34.2fixed in 0.34.2from 0.35.0 before 0.35.2fixed in 0.35.2 | 0.34.20.35.2 |
References
- https://github.com/bytecodealliance/wasmtime/commit/666c2554ea0e1728c35aa41178cf235920db888a
- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-gwc9-348x-qwv2
Get more CVE data from the API.
curl 'https://api.contrastcyber.com/cve_lookup/CVE-2022-24791'curl 'https://api.contrastcyber.com/cve_risk_score/CVE-2022-24791'curl 'https://api.contrastcyber.com/cve_exploit/CVE-2022-24791'curl 'https://api.contrastcyber.com/cve_products/CVE-2022-24791'
Sources
- Vulnerability data from the National Vulnerability Database (NIST) and the CVE Program. CVE records: Copyright © 1999-2026, The MITRE Corporation, used under the CVE Program Terms of Use. CVE® is a registered trademark of The MITRE Corporation.
- CWE definitions: Copyright © 2006-2026, The MITRE Corporation, used under the CWE Terms of Use. CWE is a trademark of The MITRE Corporation.
- OWASP Top 10 categories by the OWASP Foundation (CC BY 3.0).
- EPSS scores by FIRST.org EPSS, used with attribution.
- KEV catalog and SSVC decisions by CISA.
- Advisory data from the GitHub Advisory Database through OSV.dev (CC BY 4.0).
- Exploit metadata from the Exploit Database (GPL-2.0-only, metadata only).
- Nuclei template names from nuclei-templates (MIT).