Skip to content

Wasmtime out of bounds read/write with zero-memory-pages configuration

Moderate severity GitHub Reviewed Published Nov 10, 2022 in bytecodealliance/wasmtime • Updated Mar 16, 2023

Package

cargo wasmtime (Rust)

Affected versions

>= 2.0.0, < 2.0.2
< 1.0.2

Patched versions

2.0.2
1.0.2

Description

Impact

There is a bug in Wasmtime's implementation of its pooling instance allocator when the allocator is configured to give WebAssembly instances a maximum of zero pages of memory. In this configuration the virtual memory mapping for WebAssembly memories did not meet the compiler-required configuration requirements for safely executing WebAssembly modules. Wasmtime's default settings require virtual memory page faults to indicate that wasm reads/writes are out-of-bounds, but the pooling allocator's configuration would not create an appropriate virtual memory mapping for this meaning out of bounds reads/writes can successfully read/write memory unrelated to the wasm sandbox within range of the base address of the memory mapping created by the pooling allocator.

This bug can only be triggered by setting InstanceLimits::memory_pages to zero. This is expected to be a very rare configuration since this means that wasm modules cannot allocate any pages of linear memory. All wasm modules produced by all current toolchains are highly likely to use linear memory, so it's expected to be unlikely that this configuration is set to zero by any production embedding of Wasmtime, hence the low severity of this bug despite the critical consequences.

Patches

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

Workarounds

One way to mitigate this issue is to disable usage of the pooling allocator. Note that the pooling allocator is not enabled by default.

This bug can also only be worked around by increasing the memory_pages allotment when configuring the pooling allocator to a value greater than zero. If an embedding wishes to still prevent memory from actually being used then the Store::limiter method can be used to dynamically disallow growth of memory beyond 0 bytes large. Note that the default memory_pages value is greater than zero.

This bug is not applicable with the default settings of the wasmtime crate.

References

For more information

If you have any questions or comments about this advisory:

References

@alexcrichton alexcrichton published to bytecodealliance/wasmtime Nov 10, 2022
Published by the National Vulnerability Database Nov 10, 2022
Published to the GitHub Advisory Database Nov 10, 2022
Reviewed Nov 10, 2022
Last updated Mar 16, 2023

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
High
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:N

EPSS score

0.125%
(47th percentile)

CVE ID

CVE-2022-39392

GHSA ID

GHSA-44mr-8vmm-wjhg

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.