Skip to main content

CVE-2022-39393 — Vulnerability in wasmtime — CVE Details

HIGH

Wasmtime may have data leakage between instances in the pooling allocator

Published November 10, 2022Updated May 2, 2025Source: OSV

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (0.96%). Schedule for your next planned update.

Does your project use an affected wasmtime version?

Paste your Cargo.lock to check it for CVE-2022-39393 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

Impact

There is a bug in Wasmtime's implementation of it's pooling instance allocator where when a linear memory is reused for another instance the initial heap snapshot of the prior instance can be visible, erroneously to the next instance. The pooling instance allocator in Wasmtime works by preallocating virtual memory for a fixed number of instances to reside in and then new instantiations pick a slot to use. Most conventional modules additionally have an initial copy-on-write "heap image" which is mapped in Wasmtime into the linear memory slot. When a heap slot is deallocated Wasmtime resets all of its contents back to the initial state but it does not unmap the image in case the next instance is an instantiation of the same module.

The bug in Wasmtime occurs when a slot in the pooling allocator previously was used for a module with a heap image, meaning that its current state of memory contains the initial heap contents of that module. If the next instantiation within that slot does not itself contain a heap image then Wasmtime would leave the old heap image in place erroneously and continue with instantiation. This means that instantiations of modules without a heap image can see the initial heap image of the prior instantiation within that slot.

Heap images in Wasmtime are created by precomputing WebAssembly data segments into one large mapping to be placed into linear memory at a particular offset. Most modules produced by toolchains today will have a heap image and an initialization snapshot. Creating a module without a heap image would require a hand-crafted *.wat file or a specially crafted source program. This consequence means that this bug is highly unlikely to be accidentally triggered and would otherwise require an intentional trigger with a hand-crafted module.

One important part of this vulnerability is Wasmtime is highly likely to segfault when the slot is reused again with a module that itself has an initialization image. For example if module A has a heap initialization image and module B does not have a heap initialization image, then the following sequence of events could happen if they all are instantiated into the same instance slot:

  • Module A is instantiated, and then deallocated. This leaves A's heap image in place, reset to its initial contents.
  • Module B is instantiated and erroneously can see the initial heap contents of A. Module B is then deallocated and the entire heap is unmapped and reset back to zero.
  • Module A is instantiated again, but the state tracking the slot did not account for module B so it thinks the module image is still mapped and proceeds with instantiation. Any action on A's part to access linear memory will then trap and if the host accesses A's memory it will segfault because the data that's supposed to be mapped is all unmapped.

Adding this all together this means that in practice modules must be deliberately crafted to not have an initial heap image to view the contents of a prior image. If this module is instantiated though then when the slot is reused the next, likely image-using, module will believe its memory is mapped when it isn't, causing the host to segfault on unmapped memory it believed was mapped.

Patches

This bug has been patched and users should upgrade to Wasmtime 2.0.2.

Workarounds

Trigging this bug requires the pooling allocator to be configured and for copy-on-write heap images to also be enabled. Pooling allocation is not enabled by default but copy-on-write heap images are. Mitigations for this bug include:

  • Disabling the pooling allocator - note that pooling allocation is not enabled by default in Wasmtime
  • Disabling the memory-init-cow feature or with Config::memory_init_cow

References

For more information

If you have any questions or comments about this advisory:

Advisory Timeline

  • First published November 10, 2022 (1477 days ago).
  • Last revised May 2, 2025 — 904 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Cargo
Update wasmtime to 1.0.2 or later
cargo update -p wasmtime --precise 1.0.2
Cargo
Update wasmtime to 2.0.2 or later
cargo update -p wasmtime --precise 2.0.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 versions1.0.2
wasmtime crates.io · Affected: All versions2.0.2

Vulnerability Classification

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

CVSS Score Breakdown

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

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

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

Frequently Asked Questions

What is CVE-2022-39393?
Wasmtime may have data leakage between instances in the pooling allocator. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.6/10).
How do I check if my project is affected by CVE-2022-39393?
CVE-2022-39393 affects wasmtime. It has a 1.0% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2022-39393 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
8.6

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
0.96%
EPSS percentile: 60.3

This is an above-median EPSS score — 60.3% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.

Also Known As

GHSA-wh6w-3828-g9qf
RUSTSEC-2022-0075
RUSTSEC-2022-0098

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Cargo.lock