8.6high
Wasmtime vulnerable to data leakage between instances in the pooling allocator
- Severity
- 8.6high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.96% (higher than 62% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-wh6w-3828-g9qfRUSTSEC-2022-0075RUSTSEC-2022-0098
Description
Wasmtime is a standalone runtime for WebAssembly. Prior to versions 2.0.2 and 1.0.2, there is a bug in Wasmtime's implementation of its 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. This bug has been patched and users should upgrade to Wasmtime 2.0.2 and 1.0.2. Other mitigations include disabling the pooling allocator and disabling the `memory-init-cow`.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| bytecodealliance wasmtime | >= 2.0.0, < 2.0.2, < 1.0.2, before 1.0.2, from 2.0.0 before 2.0.2 | CVE List, NVD |
| wasmtime (crates.io) | from 2.0.0 before 2.0.2, before 1.0.2, from 0.0.0-0 before 1.0.2 | GitHub Advisory Database, RustSec Advisory Database |
All scores
| GitHub_M | 8.6high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N |
| GitHub | 8.6high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N |
| RustSec Advisory Database | 8.6high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N |
| NVD | 8.6high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N |
Classification
What each source says
CVE List
Wasmtime is a standalone runtime for WebAssembly. Prior to versions 2.0.2 and 1.0.2, there is a bug in Wasmtime's implementation of its 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. This bug has been patched and users should upgrade to Wasmtime 2.0.2 and 1.0.2. Other mitigations include disabling the pooling allocator and disabling the `memory-init-cow`.
GitHub Advisory Database
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-cowfeature or withConfig::memory_init_cow
References
Config::allocation_strategy- configuration required to enable the pooling allocator.Config::memory_init_cow- configuration required to enable or disable copy-on-write (this is enabled by default).- Mailing list announcement
- Patch for
release-2.0.0branch - Patch for
main
For more information
If you have any questions or comments about this advisory:
- Reach out to us on the Bytecode Alliance Zulip chat
- Open an issue in the bytecodealliance/wasmtime repository
RustSec Advisory Database
bug in Wasmtime's implementation of its 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.
Mitigations are described here.
RustSec Advisory Database
This is an entry in the RustSec database for the Wasmtime security advisory located at https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-wh6w-3828-g9qf. For more information see the GitHub-hosted security advisory.
NVD (es)
Wasmtime es una ejecución independiente de WebAssembly. Antes de la versión 2.0.2, había un error en la implementación de Wasmtime de su asignador de instancias de pooling donde, cuando se reutiliza una memoria lineal para otra instancia, la instantánea de la pila inicial de la instancia anterior puede ser visible, erróneamente, para la siguiente instancia. Este error ha sido corregido y los usuarios deben actualizar a Wasmtime 2.0.2. Otras mitigaciones incluyen deshabilitar el asignador de instancias de pooling y deshabilitar la "memory-init-cow".
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2022-39393 changed 2025-05-02 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-wh6w-3828-g9qf changed 2025-05-02 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2022-0075 changed 2026-10-12 | CC0-1.0 |
| RustSec Advisory Database | RUSTSEC-2022-0098 changed 2026-10-12 | CC0-1.0 |
| NVD | CVE-2022-39393 changed 2026-06-17 | Public domain |