Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS00NG1yLTh2bW0td2poZ84AAv0V

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

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:

Permalink: https://github.com/advisories/GHSA-44mr-8vmm-wjhg
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS00NG1yLTh2bW0td2poZ84AAv0V
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: about 2 years ago
Updated: over 1 year ago


CVSS Score: 5.9
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:N

Identifiers: GHSA-44mr-8vmm-wjhg, CVE-2022-39392
References: Repository: https://github.com/bytecodealliance/wasmtime
Blast Radius: 20.0

Affected Packages

cargo:wasmtime
Dependent packages: 180
Dependent repositories: 2,459
Downloads: 9,503,732 total
Affected Version Ranges: < 1.0.2, >= 2.0.0, < 2.0.2
Fixed in: 1.0.2, 2.0.2
All affected versions: 0.0.0, 0.3.0, 0.7.0, 0.8.0, 0.9.0, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.19.0, 0.20.0, 0.21.0, 0.22.0, 0.23.0, 0.24.0, 0.25.0, 0.26.0, 0.26.1, 0.27.0, 0.28.0, 0.29.0, 0.30.0, 0.31.0, 0.32.0, 0.32.1, 0.33.0, 0.33.1, 0.34.0, 0.34.1, 0.34.2, 0.35.0, 0.35.1, 0.35.2, 0.35.3, 0.36.0, 0.37.0, 0.38.0, 0.38.1, 0.38.2, 0.38.3, 0.39.0, 0.39.1, 0.40.0, 0.40.1, 1.0.0, 1.0.1, 2.0.0, 2.0.1
All unaffected versions: 1.0.2, 2.0.2, 3.0.0, 3.0.1, 4.0.0, 4.0.1, 5.0.0, 5.0.1, 6.0.0, 6.0.1, 6.0.2, 7.0.0, 7.0.1, 8.0.0, 8.0.1, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 9.0.4, 10.0.0, 10.0.1, 10.0.2, 11.0.0, 11.0.1, 11.0.2, 12.0.0, 12.0.1, 12.0.2, 13.0.0, 13.0.1, 14.0.0, 14.0.1, 14.0.2, 14.0.3, 14.0.4, 15.0.0, 15.0.1, 16.0.0, 17.0.0, 17.0.1, 17.0.2, 17.0.3, 18.0.0, 18.0.1, 18.0.2, 18.0.3, 18.0.4, 19.0.0, 19.0.1, 19.0.2, 20.0.0, 20.0.1, 20.0.2, 21.0.0, 21.0.1, 21.0.2, 22.0.0, 22.0.1, 23.0.0, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 25.0.0, 25.0.1, 25.0.2, 26.0.0