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

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 6.4
- **CVSS:** 6.4 (v3.1, CNA) `CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:L`
- **CVSS metrics:** Attack vector: Network; Attack complexity: High; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: Low; Availability impact: Low
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, login needed
- **EPSS:** 1.15% (percentile 67, 2026-11-26)
- **CWE:** CWE-416
- **Aliases:** GHSA-5fhj-g3p3-pq9g, RUSTSEC-2022-0100
- **Published:** 2022-07-12T12:00:00.000Z
- **Modified:** 2026-10-12T18:00:06.108Z

## Who should check

- Projects that depend on crates.io package wasmtime (\>= 0.37.0, \< 0.38.2)
- Projects that depend on crates.io package cranelift-codegen (\>= 0.84.0, \< 0.85.2)
- Anyone running bytecodealliance wasmtime \>= 0.37.0, \< 0.38.2; \>= 0.84.0, \< 0.85.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.

## Affected and fixed versions

- crates.io `wasmtime`: affected \>= 0.37.0, \< 0.38.2; fixed 0.38.2 (osv)
- crates.io `cranelift-codegen`: affected \>= 0.84.0, \< 0.85.2; fixed 0.85.2 (osv)
- bytecodealliance wasmtime: \>= 0.37.0, \< 0.38.2; \>= 0.84.0, \< 0.85.2 (cvelist)

## Mitigation

- Upgrade wasmtime to 0.38.2 or later.
- Upgrade cranelift-codegen to 0.85.2 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2022-31146. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2022-31146.md
Affected: wasmtime >= 0.37.0, < 0.38.2; cranelift-codegen >= 0.84.0, < 0.85.2
Fixed in: 0.38.2, 0.85.2

Steps:
1. Search this machine and project for wasmtime (crates.io), cranelift-codegen (crates.io), bytecodealliance wasmtime: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2022-31146 being exploited?

There is no confirmed exploitation: CVE-2022-31146 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 1.15% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2022-31146?

Medium: CVSS 6.4 (v3.1, scored by CNA). Remote, login needed. The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2022-31146?

wasmtime \>= 0.37.0, \< 0.38.2; cranelift-codegen \>= 0.84.0, \< 0.85.2.

### Is there a fix for CVE-2022-31146?

Yes. Fixed in 0.38.2, 0.85.2. Upgrade wasmtime to 0.38.2 or later. Upgrade cranelift-codegen to 0.85.2 or later.

### How do I check if I'm affected by CVE-2022-31146?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-5fhj-g3p3-pq9g>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2022-31146>
- vendor: <https://rustsec.org/advisories/RUSTSEC-2022-0100.html>
- patch: <https://github.com/bytecodealliance/wasmtime/commit/2ba4bce5cc719e5a74e571a534424614e62ecc41>
- other: <https://github.com/WebAssembly/reference-types>
- other: <https://github.com/bytecodealliance/wasmtime/>
- other: <https://github.com/bytecodealliance/wasmtime>
- other: <https://crates.io/crates/wasmtime>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2022-31146>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-5fhj-g3p3-pq9g> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/RUSTSEC-2022-0100> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2022-31146> · JSON: <https://flawdb.com/api/v1/entries/CVE-2022-31146>
