CVE-2021-39219: Wrong type for `Linker`-define functions when used across two `Engine`s

Published Sep 17, 2021
·
Updated

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:

Reach out to us on the Bytecode Alliance Zulip chat Open an issue in the bytecodealliance/wasmtime repository

Other sources

Wasmtime is an open source runtime for WebAssembly & WASI. Wasmtime before version 0.30.0 is affected by a type confusion vulnerability. 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. This bug has been patched and users should upgrade to Wasmtime version 0.30.0. 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.

Affected Software

5 affected componentsFixes available
pip/wasmtime>=0<0.30.0
0.30.0
rust/wasmtime<0.30.0
0.30.0
bytecodealliance Wasmtime<0.30.0
Fedoraproject Fedora=34
Fedoraproject Fedora=35

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/wasmtime to a version that resolves this vulnerability.

    Fixed in 0.30.0
  2. Upgrade

    Upgrade rust/wasmtime to a version that resolves this vulnerability.

    Fixed in 0.30.0
  3. Upgrade

    Upgrade wasmtime to a version that resolves this vulnerability.

    Fixed in 0.30.0
  4. Configuration

    Ensure your embedding uses a single `Engine` for the lifetime of the process; audit code so `Linker::func_*` is only used with one `Engine` (avoid creating the `Linker` with one `Engine` and instantiating modules with a `Store` from a different `Engine`).

    Wasmtime embedding (Linker::func_* safe APIs) cross-Engine usage of Linker = use only one Engine per process (and ensure Linker is used with that same Engine for Store/module instantiation)
  5. Compensating control

    If you cannot upgrade Wasmtime and must use multiple `Engine` values in your embedding, audit and ensure that `Linker` is only used with one `Engine` (avoid using two `Engine`s such that a `Linker` created with one is used with a `Store` from another).

Event History

Sep 17, 2021
CVE Published
via MITRE·08:10 PM
Data Sourced
via MITRE·08:10 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Sep 20, 2021
Advisory Published
via GitHub·07:54 PM
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the vulnerability ID?

The vulnerability ID is CVE-2021-39219.

2

What is Wasmtime?

Wasmtime is an open source runtime for WebAssembly & WASI.

3

What version of Wasmtime is affected?

Version 0.30.0 and earlier versions of Wasmtime are affected.

4

What is the severity of CVE-2021-39219?

The severity of CVE-2021-39219 is medium, with a CVSS score of 6.3.

5

What is the impact of this vulnerability?

This vulnerability allows an attacker to exploit a type confusion vulnerability in Wasmtime.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203