Medium

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

  • Disclosed: 17.09.2021
  • Updated: 11.10.2026 13:19

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:

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) wasmtime < 0.30.0 0.30.0

References

CVSS score 6.3/10
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

  1. 2021: 2
  2. 2022: 0
  3. 2023: 0
  4. 2024: 2
  5. 2025: 0
  6. 2026: 1
  1. Low · 2.9 CVE-2024-47813 <= 19.0.0, <= 19.0.1, <= 19.0.2, <= 20.0.0, <= 20.0.1, <= 20.0.2, <= 21.0.0, <= 21.0.1, <= 22.0.0, <= 23.0.0, <= 23.0.1, <= 23.0.2, <= 24.0.0, <= 25.0.0, <= 25.0.1 no fix
  2. Wrong type for `Linker`-define functions when used across two `Engine`s this entry
    Medium · 6.3 CVE-2021-39216 < 0.30.0 0.30.0
  3. High · 7.2 CVE-2021-32629 < 0.27.0 0.27.0

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.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.