CVE-2021-39219
Wrong type for `Linker`-define functions when used across two `Engine`s
Check your servers for CVE-2021-39219
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2021-39219 affects wasmtime, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
Description
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 `Engine`s is required then code should be audited to ensure that `Linker` is only used with one `Engine`.
Severity (CVSS)
CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- high: an attack depends on conditions outside the control of the attacker, such as a race
- Privileges required
- none: the attacker does not need an account
- User interaction
- required: a user has to do something, such as open a link or a file
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality none, integrity high, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 0.36%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 31.9% of all scored CVEs. Scores of 1 Dec 2026.
Weakness
- CWE-843 Access of Resource Using Incompatible Type
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| wasmtime |
affected <= 0.29.0
|
Is my server affected?
Find the installed version of wasmtime and compare it with the fixed version of your distribution. Distributions often fix a CVE in a package version of their own, so the version number of the upstream project can mislead.
Debian, Ubuntu
dpkg -l | grep -i wasmtime
# packages whose changelog names the CVE (fixed in the installed version)
zgrep -l CVE-2021-39219 /usr/share/doc/*/changelog.Debian.gz
# Ubuntu
pro fix CVE-2021-39219RHEL, Rocky, Alma, Fedora
rpm -q wasmtime
# lists the advisory while the fix is not installed
dnf updateinfo list --cve CVE-2021-39219Alpine
apk list --installed | grep -i wasmtimeWith Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2021-39219
trivy image --scanners vuln IMAGE | grep CVE-2021-39219
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Advisories
- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-q879-9g95-56mx github.com
- FEDORA-2021-68713440cb lists.fedoraproject.org · vendor advisory
- FEDORA-2021-1805eacb48 lists.fedoraproject.org · vendor advisory
Other references
- https://crates.io/crates/wasmtime crates.io
- https://github.com/bytecodealliance/wasmtime/commit/b39f087414f27ae40c44449ed5d1154e03449bff github.com
Source: the record CVE-2021-39219 of the CVE List (CVE Program), CVE Terms of Use; EPSS of FIRST; the CWE catalog of MITRE, CWE Terms of Use. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse