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:
- Reach out to us on the Bytecode Alliance Zulip chat
- Open an issue in the
bytecodealliance/wasmtimerepository
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| Python (PyPI) | wasmtime | < 0.30.0 | 0.30.0 |
References
- https://crates.io/crates/wasmtime
- https://github.com/bytecodealliance/wasmtime/commit/101998733b74624cbd348a2366d05760b40181f3
- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-v4cp-h94r-m7xf
- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-4873-36h9-wv49
- https://github.com/bytecodealliance/wasmtime/commit/398a73f0dd862dbe703212ebae8e34036a18c11c
- https://github.com/bytecodealliance/wasmtime/commit/b39f087414f27ae40c44449ed5d1154e03449bff
- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-q879-9g95-56mx
- https://nvd.nist.gov/vuln/detail/CVE-2021-39218
- https://github.com/bytecodealliance/wasmtime
- https://github.com/bytecodealliance/wasmtime-py/compare/0.29.0...0.30.0
- https://github.com/pypa/advisory-database/tree/main/vulns/wasmtime/PYSEC-2021-321.yaml
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WAVBRYDDUIY2ZR3K3FO4BVYJKIMJ5TP7
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/Z2Z33FTXFQ6EOINVEQIP4DFBG53G5XIY
- https://rustsec.org/advisories/RUSTSEC-2021-0110.html
- https://nvd.nist.gov/vuln/detail/CVE-2021-39216
- https://github.com/pypa/advisory-database/tree/main/vulns/wasmtime/PYSEC-2021-320.yaml
- https://nvd.nist.gov/vuln/detail/CVE-2021-39219
- https://github.com/pypa/advisory-database/tree/main/vulns/wasmtime/PYSEC-2021-322.yaml
- CVSS vector
CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H- Weakness (CWE)
CWE-125, CWE-590, CWE-787, CWE-416, CWE-843- Platform
- Python (PyPI)
- Package
wasmtime- Disclosed
- 17.09.2021
- Updated
- 11.10.2026 13:19
Sources and licenses
OSV / GitHub Advisory Database - PYSEC-2021-320 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - PYSEC-2021-321 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - PYSEC-2021-322 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-4873-36h9-wv49 - CC BY 4.0
OSV / GitHub Advisory Database - GHSA-v4cp-h94r-m7xf - CC BY 4.0
OSV / GitHub Advisory Database - GHSA-q879-9g95-56mx - CC BY 4.0
Vulnerability history: wasmtime
All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 5
- First → latest
- 05.2021 04.2026
- Without a fix
- 3
- Exploited in attacks
- 0
Severity breakdown
- High 1
- Medium 3
- Low 1
Disclosures per year
- 2021: 2
- 2022: 0
- 2023: 0
- 2024: 2
- 2025: 0
- 2026: 1
-
Wrong type for `Linker`-define functions when used across two `Engine`s this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.