Ecosyste.ms: Advisories

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

Security Advisories: GSA_kwCzR0hTQS1xODc5LTlnOTUtNTZteM0V3Q

Wrong type for `Linker`-define functions when used across two `Engine`s

Impact

As a Rust library the wasmtime crate clearly marks which functions are safe and which are unsafe, guaranteeing that if consumers never use unsafe then it should not be possible to have memory unsafety issues in their embeddings of Wasmtime. An issue was discovered in the safe API of Linker::func_* APIs. These APIs were previously not sound when one Engine was used to create the Linker and then a different Engine was used to create a Store and then the Linker was used to instantiate a module into that Store. Cross-Engine usage of functions is not supported in Wasmtime and this can result in type confusion of function pointers, resulting in being able to safely call a function with the wrong type.

Triggering this bug requires using at least two Engine values in an embedding and then additionally using two different values with a Linker (one at the creation time of the Linker and another when instantiating a module with the Linker).

It's expected that usage of more-than-one Engine in an embedding is relatively rare since an Engine is intended to be a globally shared resource, so the expectation is that the impact of this issue is relatively small.

The fix implemented is to change this behavior to panic!() in Rust instead of silently allowing it. Using different Engine instances with a Linker is a programmer bug that wasmtime catches at runtime.

Patches

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

Workarounds

If you cannot upgrade Wasmtime and are using more than one Engine in your embedding it's recommended to instead use only one Engine for the entire program if possible. An Engine is designed to be a globally shared resource that is suitable to have only one for the lifetime of an entire process. If using multiple Engines is required then code should be audited to ensure that Linker is only used with one Engine.

For more information

If you have any questions or comments about this advisory:

Permalink: https://github.com/advisories/GHSA-q879-9g95-56mx
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1xODc5LTlnOTUtNTZteM0V3Q
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: over 2 years ago
Updated: 10 months ago


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

Identifiers: GHSA-q879-9g95-56mx, CVE-2021-39219
References: Repository: https://github.com/bytecodealliance/wasmtime
Blast Radius: 21.4

Affected Packages

cargo:wasmtime
Dependent packages: 126
Dependent repositories: 2,459
Downloads: 6,801,318 total
Affected Version Ranges: < 0.30.0
Fixed in: 0.30.0
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
All unaffected versions: 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, 1.0.2, 2.0.0, 2.0.1, 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