Skip to content

← Actionable
Medium, CVSS 6.4

Wasmtime vulnerable to Use After Free with externrefs

CVE-2022-31146GHSA-5fhj-g3p3-pq9g

What to do

Vendor fix available. Upgrade each affected package to the fixed version on its release line (cranelift-codegen 0.85.2; wasmtime 0.38.2), redeploy, then verify what is actually installed.

This page has no inventory attached, so it cannot say whether you are affected. A vendor fix is not proof that your deployment is fixed.

Affected packages

  • crates.io cranelift-codegen

    Affected
    >= 0.84.0, < 0.85.2
    Fixed in
    0.85.2
  • crates.io wasmtime

    Affected
    >= 0.37.0, < 0.38.2
    Fixed in
    0.38.2

Sources

Severity and exploitation
Exploitation
No confirmed exploitation recorded. Patch Next marks exploitation only from CISA KEV.
CVSS
6.4 · CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:L
EPSS
  • CVE-2022-31146: 1.25% estimated exploitation activity in the next 30 days; percentile 69.43 (FIRST EPSS, 2026-11-03). This is a model estimate, not proof of exploitation or customer exposure.
Source description

As published by the source; long descriptions are shortened.

There is a bug in Wasmtime's code generator, Cranelift, where functions using reference types may be incorrectly missing metadata required for runtime garbage collection (GC). This means that if a GC happens at runtime then the collector will mistakenly think some Wasm stack frames do not have live references to garbage collected values and therefore reclaim and deallocate them. The function can then subsequently continue to use the values, leading later to use-after-free bugs. This bug was introduced in Cranelift's migration to the regalloc2 register allocator in the Wasmtime 0.37.0 release on 2022-05-20. This bug has been patched and users should upgrade to Wasmtime version 0.38.2. Mitigations for this issue can be achieved by doing one of: Disabling the reference types proposal by passing false to wasmtime::Config::wasmreferencetypes. Downgrading to Wasmtime 0.36.0 or prior.

Dates and revisions
Published by the source
Last modified by the source
Source last checked
  1. Revision 1 · created ·

    Published from ghsa record GHSA-5fhj-g3p3-pq9g

Agent brief

Preview the exact text before you copy it. Commands are read-only suggestions; review them before running anything.

# Patch Next advisory brief: CVE-2022-31146

Advisory: Wasmtime vulnerable to Use After Free with `externref`s
IDs: CVE-2022-31146, GHSA-5fhj-g3p3-pq9g
Record: https://patchnext.com/advisories/cve-2022-31146 (revision 1, source checked 26 Oct 2026, 15:38 UTC)
Inventory: none attached. This brief comes from a public page and does not say whether any deployment is affected.
Severity: Medium (CVSS 6.4)
Exploitation: no confirmed exploitation recorded. Patch Next confirms exploitation only from CISA KEV.
Vendor response: Vendor fix available; fixed versions by package: cranelift-codegen 0.85.2; wasmtime 0.38.2. A vendor fix does not mean a deployment is fixed.

## Affected components
- crates.io cranelift-codegen: affected >= 0.84.0, < 0.85.2; fixed in 0.85.2
- crates.io wasmtime: affected >= 0.37.0, < 0.38.2; fixed in 0.38.2

## Suggested inspection (read-only)
- crates.io cranelift-codegen: check the installed version with your package manager.
- crates.io wasmtime: check the installed version with your package manager.

## Supported action
Upgrade each affected component to a fixed version on its release line. For a transitive dependency, upgrade the parent package or add an override or constraint, then regenerate the lockfile. Redeploy every environment that ran an affected version.

## Required regression checks
- Run the test suite and a production build.
- Exercise the features that depend on cranelift-codegen, wasmtime.
- Repeat the inspection and confirm that only fixed versions remain installed.

## Rollback considerations
- Keep the previous lockfile and deployment artifact. Rolling back reinstates the vulnerable version, so apply any documented mitigation while you fix forward.

## Unresolved questions
- Which deployments run an affected version?
- Exploitation status can change. Check again before lowering the priority.
- Mark the work resolved only after the fixed version is verified in production.

## Sources
- Verified: https://github.com/advisories/GHSA-5fhj-g3p3-pq9g (GitHub-reviewed advisory GHSA-5fhj-g3p3-pq9g lists affected ranges: crates.io wasmtime >=0.37.0 =0.84.0 <0.85.2)

Commands are suggestions: review each one before running it.

Loading voting…