# CVE-2021-39216: Use after free passing `externref`s to Wasm in Wasmtime

- Severity: Medium 6.3 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.31%, higher than 25% of CVEs (2026-12-01)
- Published: 2021-09-17T12:00:00.000Z
- Modified: 2026-11-09T11:00:02.603Z
- Also known as: GHSA-4873-36h9-wv49, GHSA-q879-9g95-56mx, GHSA-v4cp-h94r-m7xf, PYSEC-2021-320, PYSEC-2021-321, PYSEC-2021-322, RUSTSEC-2021-0110
- Related: CVE-2021-39218, CVE-2021-39219
- Weaknesses: CWE-125, CWE-416, CWE-590, CWE-787, CWE-843
- Assigned by: GitHub_M

## Description

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`.

(As written by CVE List.)

## Affected

- bytecodealliance wasmtime: >=0.19.0, <=0.29.0; from 0.19.0 before 0.30.0
- wasmtime (crates.io): from 0.26.0 before 0.30.0; before 0.30.0; from 0.0.0-0 before 0.30.0
- wasmtime (PyPI): from 0.26.0 before 0.30.0; before 0.30.0; before 101998733b74624cbd348a2366d05760b40181f3; before 398a73f0dd862dbe703212ebae8e34036a18c11c; before b39f087414f27ae40c44449ed5d1154e03449bff
- fedoraproject fedora: 34; 35

## Every score

- GitHub_M: CVSS:3.1 6.3 Medium `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H`
- GitHub: CVSS:3.1 6.3 Medium `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H`
- GitHub: CVSS:4.0 Medium `CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N`
- GitHub: CVSS:3.1 6.3 Medium `CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H`
- GitHub: CVSS:4.0 Medium `CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:P/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N`
- GitHub: CVSS:4.0 Medium `CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N`
- RustSec Advisory Database: CVSS:3.1 6.3 Medium `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H`
- NVD: CVSS:2.0 3.3 Low `AV:L/AC:M/Au:N/C:N/I:P/A:P`

## References

- <https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-v4cp-h94r-m7xf> (advisory, third-party-advisory, web)
- <https://github.com/bytecodealliance/wasmtime/commit/101998733b74624cbd348a2366d05760b40181f3> (fix, third-party-advisory, web)
- <https://crates.io/crates/wasmtime> (package, product, web)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/Z2Z33FTXFQ6EOINVEQIP4DFBG53G5XIY/> (vendor-advisory)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/WAVBRYDDUIY2ZR3K3FO4BVYJKIMJ5TP7/> (vendor-advisory)
- <https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-4873-36h9-wv49> (advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-39218> (advisory)
- <https://github.com/bytecodealliance/wasmtime/commit/398a73f0dd862dbe703212ebae8e34036a18c11c> (fix, web)
- <https://github.com/bytecodealliance/wasmtime> (package)
- <https://github.com/bytecodealliance/wasmtime-py/compare/0.29.0...0.30.0> (web)
- <https://github.com/pypa/advisory-database/tree/main/vulns/wasmtime/PYSEC-2021-321.yaml> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WAVBRYDDUIY2ZR3K3FO4BVYJKIMJ5TP7> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/Z2Z33FTXFQ6EOINVEQIP4DFBG53G5XIY> (web)
- <https://rustsec.org/advisories/RUSTSEC-2021-0110.html> (advisory, web)
- <https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-q879-9g95-56mx> (advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-39219> (advisory)
- <https://github.com/bytecodealliance/wasmtime/commit/b39f087414f27ae40c44449ed5d1154e03449bff> (fix, web)
- <https://github.com/pypa/advisory-database/tree/main/vulns/wasmtime/PYSEC-2021-322.yaml> (web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-39216> (advisory)
- <https://github.com/pypa/advisory-database/tree/main/vulns/wasmtime/PYSEC-2021-320.yaml> (web)

## Sources

- CVE List: [CVE-2021-39216](https://www.cve.org/CVERecord?id=CVE-2021-39216), CVE Terms of Use, modified 2024-08-04
- GitHub Advisory Database: [GHSA-4873-36h9-wv49](https://github.com/advisories/GHSA-4873-36h9-wv49), CC-BY-4.0, modified 2026-07-08
- GitHub Advisory Database: [GHSA-q879-9g95-56mx](https://github.com/advisories/GHSA-q879-9g95-56mx), CC-BY-4.0, modified 2026-07-08
- GitHub Advisory Database: [GHSA-v4cp-h94r-m7xf](https://github.com/advisories/GHSA-v4cp-h94r-m7xf), CC-BY-4.0, modified 2026-07-08
- RustSec Advisory Database: [RUSTSEC-2021-0110](https://rustsec.org/advisories/RUSTSEC-2021-0110.html), CC0-1.0, modified 2026-11-09
- NVD: [CVE-2021-39216](https://nvd.nist.gov/vuln/detail/CVE-2021-39216), Public domain, modified 2026-06-17
- PyPA Advisory Database: [PYSEC-2021-320](https://osv.dev/vulnerability/PYSEC-2021-320), CC-BY-4.0, modified 2024-03-15
- PyPA Advisory Database: [PYSEC-2021-321](https://osv.dev/vulnerability/PYSEC-2021-321), CC-BY-4.0, modified 2024-03-15
- PyPA Advisory Database: [PYSEC-2021-322](https://osv.dev/vulnerability/PYSEC-2021-322), CC-BY-4.0, modified 2024-03-15

---

Page: https://cve.day/CVE-2021-39216 · Whole record: https://cve.day/CVE-2021-39216.json · Rebuilt by cve.day 2026-11-25T22:58:04.034Z
