LiveActive security incident?Get immediate response
CVE Record

CVE-2021-39218: Out-of-bounds read/write and invalid free with `externref`s and GC safepoints in Wasmtime

Wasmtime is an open source runtime for WebAssembly & WASI. In Wasmtime from version 0.26.0 and before version 0.30.0 is affected by a memory unsoundness vulnerability. There was an invalid free and out-of-bounds read and write bug when running Wasm that uses `externref`s in Wasmtime. To trigger this bug, Wasmtime needs to be running Wasm that uses `externref`s, the host creates non-null `externrefs`, Wasmtime performs a garbage collection (GC), and there has to be a Wasm frame on the stack that is at a GC safepoint where there are no live references at this safepoint, and there is a safepoint with live references earlier in this frame's function. Under this scenario, Wasmtime would incorrectly use the GC stack map for the safepoint from earlier in the function instead of the empty safepoint. This would result in Wasmtime treating arbitrary stack slots as `externref`s that needed to be rooted for GC. At the *next* GC, it would be determined that nothing was referencing these bogus `externref`s (because nothing could ever reference them, because they are not really `externref`s) and then Wasmtime would deallocate them and run `<ExternRef as Drop>::drop` on them. This results in a free of memory that is not necessarily on the heap (and shouldn't be freed at this moment even if it was), as well as potential out-of-bounds reads and writes. Even though support for `externref`s (via the reference types proposal) is enabled by default, unless you are creating non-null `externref`s in your host code or explicitly triggering GCs, you cannot be affected by this bug. We have reason to believe that the effective impact of this bug is relatively small because usage of `externref` is currently quite rare. This bug has been patched and users should upgrade to Wasmtime version 0.30.0. If you cannot upgrade Wasmtime at this time, you can avoid this bug by disabling the reference types proposal by passing `false` to `wasmtime::Config::wasm_reference_types`.

MediumCVSS 6.3Not KEV-listedUpdated
Glexia's TakeAutomated analysismoderate

Security readout for executives and security teams

Plain-English summary

Wasmtime could mishandle WebAssembly externref values during garbage collection under narrow conditions, causing invalid frees and out-of-bounds memory access. Business risk is mainly for services embedding affected Wasmtime versions and running untrusted or tenant-supplied Wasm with host-created externrefs.

Executive priority

Treat as a targeted remediation item, not a broad emergency. Prioritize exposed Wasmtime hosts processing untrusted Wasm and using externrefs. Patch during the next controlled maintenance window unless inventory shows high-risk multi-tenant execution paths.

Technical view

In Wasmtime 0.26.0 through 0.29.0, GC safepoint stack maps could be selected incorrectly for frames with earlier live externrefs and a later empty safepoint. Bogus stack slots were rooted as externrefs, then dropped at a later GC, causing invalid free and possible out-of-bounds read/write.

Likely exposure

Exposure is limited to applications embedding Wasmtime 0.26.0-0.29.0 where Wasm uses externref, host code creates non-null externrefs, and GC occurs. Hosts not creating non-null externrefs or avoiding the reference-types path are unlikely affected based on the advisory.

Exploitation context

No active exploitation is indicated in the provided sources, and the CVE is not listed as KEV. The CVSS vector indicates local access, low privileges, high attack complexity, and no user interaction, with integrity and availability impact.

Researcher notes

The vulnerability depends on a specific GC safepoint mismatch involving externrefs. Sources describe invalid free plus possible out-of-bounds read/write, but do not provide public exploitation evidence. Validate exposure through version, reference-types configuration, externref host behavior, and GC usage.

Mitigation direction

  • Upgrade Wasmtime to version 0.30.0 or later.
  • If upgrade is delayed, disable reference types with wasm_reference_types set to false.
  • Inventory applications that embed Wasmtime directly or through Rust dependencies.
  • Prioritize services that execute untrusted Wasm or tenant-provided modules.
  • Review Fedora package advisories where Wasmtime is consumed through Fedora packages.

Validation and detection

  • Confirm deployed Wasmtime versions are not 0.26.0 through 0.29.0.
  • Review host code for non-null externref creation.
  • Check whether host code explicitly triggers Wasmtime garbage collection.
  • Verify reference types are disabled where patching is delayed.
  • Confirm SBOMs or dependency manifests reflect the patched Wasmtime version.
Prepared
Confidence
high
Sources
7

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · low confidence lookup

CWE-125: Exact CWE lookup

Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cwe · low confidence lookup

CWE-590: Exact CWE lookup

Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cwe · low confidence lookup

CWE-787: Exact CWE lookup

Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2021-39218 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
Medium
CVSS
6.3 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
0Timeline events
0ADP providers
6Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
6.3CVSS 3.1MediumCVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H15.2Primary CVE score

Vulnerability scoring details

Base CVSS 3.1 score

6.3Medium
CVSS 3.1 vector shape for CVE-2021-39218Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone

Source materials

Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
bytecodealliancewasmtime>= 0.26.0, <= 0.29.0Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.