Use after free passing `externref`s to Wasm in Wasmtime
Key facts
- Attack vector
- Local
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- High
- Impact type
- —
- Confidentiality · integrity · availability
- None · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub.
Summary
Wasmtime is an open source runtime for WebAssembly & WASI. In Wasmtime from version 0.19.0 and before version 0.30.0 there was a use-after-free bug when passing `externref`s from the host to guest Wasm content. To trigger the bug, you have to explicitly pass multiple `externref`s from the host to a Wasm instance at the same time, either by passing multiple `externref`s as arguments from host code to a Wasm function, or returning multiple `externref`s to Wasm from a multi-value return function defined in the host. If you do not have host code that matches one of these shapes, then you are not impacted. If Wasmtime's `VMExternRefActivationsTable` became filled to capacity after passing the first `externref` in, then passing in the second `externref` could trigger a garbage collection. However the first `externref` is not rooted until we pass control to Wasm, and therefore could be reclaimed by the collector if nothing else was holding a reference to it or otherwise keeping it alive. Then, when control was passed to Wasm after the garbage collection, Wasm could use the first `externref`, which at this point has already been freed. We have reason to believe that the effective impact of this bug is relatively small because usage of `externref` is currently quite rare. The bug has been fixed, and users should upgrade to Wasmtime 0.30.0. If you cannot upgrade Wasmtime yet, you can avoid the bug by disabling reference types support in Wasmtime by passing `false` to `wasmtime::Config::wasm_reference_types`.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| bytecodealliance | wasmtime | 0.19.0 – 0.29.0 | — | No fix listed | CNA |
| — | wasmtime (crates.io) | before 0.30.0 | 0.30.0 | Patch available | GHSA-v4cp-h94r-m7xf |
| — | wasmtime (PyPI) | before 0.30.0 | 0.30.0 | Patch available | GHSA-v4cp-h94r-m7xf |
- wasmtime Vendorbytecodealliance Affected 0.19.0 – 0.29.0 Fixed in — No fix listed CNA
- wasmtime (crates.io) Vendor— Affected before 0.30.0 Fixed in 0.30.0 Patch available GHSA-v4cp-h94r-m7xf
- wasmtime (PyPI) Vendor— Affected before 0.30.0 Fixed in 0.30.0 Patch available GHSA-v4cp-h94r-m7xf
CPE configurations NVD · 3
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:bytecodealliance:wasmtime:*:*:*:*:*:*:*:* | 0.19.0 to before 0.30.0 | Vulnerable | bytecodealliance |
| cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:* | 34 | Vulnerable | Fedoraproject |
| cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* | 35 | Vulnerable | Fedoraproject |
- cpe:2.3:a:bytecodealliance:wasmtime:*:*:*:*:*:*:*:* Versions 0.19.0 to before 0.30.0 Vulnerable ·bytecodealliance
- cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:* Versions 34 Vulnerable ·Fedoraproject
- cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* Versions 35 Vulnerable ·Fedoraproject
Remediation
- Fix · GHSA-v4cp-h94r-m7xf wasmtime (crates.io) Fixed in 0.30.0 Advisory →
- Fix · GHSA-v4cp-h94r-m7xf wasmtime (PyPI) Fixed in 0.30.0 Advisory →
Fixed in the same release
Records fixed by the same vendor advisory or release, as the CNA lists them.
- Advisory ·
bytecodealliance wasmtime — FEDORA-2021-1805eacb48
3 records Highest priority Priority LOW 3 LOW
Other records, highest priority first
- TI-2021-16604 Wrong type for `Linker`-define functions when used across two `Engine`sPriority LOW 28
- TI-2021-16603 Out-of-bounds read/write and invalid free with `externref`s and GC safepoints in WasmtimePriority LOW 28
- Advisory ·
bytecodealliance wasmtime — FEDORA-2021-68713440cb
3 records Highest priority Priority LOW 3 LOW
Other records, highest priority first
- TI-2021-16604 Wrong type for `Linker`-define functions when used across two `Engine`sPriority LOW 28
- TI-2021-16603 Out-of-bounds read/write and invalid free with `externref`s and GC safepoints in WasmtimePriority LOW 28
Vendor assessments
Timeline
- 2026-10-02 Threatist record created from CVE-2021-39216
- 2026-10-03 Alias added: GHSA-v4cp-h94r-m7xf
References
Advisory 5
Other 7
- https://crates.io/crates/wasmtime
- 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-320.yaml
- https://lists.fedoraproject.org/archives/list/[email protected]/message/WAVBRYDDUIY2ZR3K3FO4BVYJKIMJ5TP7
- https://lists.fedoraproject.org/archives/list/[email protected]/message/Z2Z33FTXFQ6EOINVEQIP4DFBG53G5XIY
- https://rustsec.org/advisories/RUSTSEC-2021-0110.html
More bytecodealliance Wasmtime vulnerabilities
- TI-2026-21632 Wasmtime is vulnerable to panic when dropping a `[Typed]Func::call_async` future CVSS 4.0MEDIUM 6.9
- TI-2023-11636 Guest-controlled out-of-bounds read/write on x86_64 in wasmtime CVSS 3.1CRITICAL 10.0
- TI-2022-18765 Wasmtime vulnerable to data leakage between instances in the pooling allocator CVSS 3.1HIGH 8.6
- TI-2022-08604 Use after free in Wasmtime CVSS 3.1CRITICAL 9.8
- TI-2022-18766 wasmtime_trap_code C API function has out of bounds write vulnerability CVSS 3.1CRITICAL 9.8
- TI-2026-27209 Wasmtime with Winch compiler backend on aarch64 may allow a sandbox-escaping memory access CVSS 4.0CRITICAL 9.0
Sources
- CVE-2021-39216 · CVE Program
- CVE-2021-39216 · NVD
- FIRST EPSS
- GHSA-v4cp-h94r-m7xf · GitHub Advisory Database · CC BY 4.0
- CVE-2021-39216 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences