Use After Free in Wasmtime
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · NVD. Fix status from CNA and GitHub. Impact type from CWE-416 and the CVSS impact.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| bytecodealliance | wasmtime | 0.37.0 to before 0.38.2; 0.84.0 to before 0.85.2 | 0.38.2, 0.85.2 | Patch available | CNA |
| — | wasmtime (crates.io) | 0.37.0 to before 0.38.2 | 0.38.2 | Patch available | GHSA-5fhj-g3p3-pq9g |
| — | cranelift-codegen (crates.io) | 0.84.0 to before 0.85.2 | 0.85.2 | Patch available | GHSA-5fhj-g3p3-pq9g |
- wasmtime Vendorbytecodealliance Affected 0.37.0 to before 0.38.2; 0.84.0 to before 0.85.2 Fixed in 0.38.2, 0.85.2 Patch available CNA
- wasmtime (crates.io) Vendor— Affected 0.37.0 to before 0.38.2 Fixed in 0.38.2 Patch available GHSA-5fhj-g3p3-pq9g
- cranelift-codegen (crates.io) Vendor— Affected 0.84.0 to before 0.85.2 Fixed in 0.85.2 Patch available GHSA-5fhj-g3p3-pq9g
CPE configurations NVD · 2
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:bytecodealliance:cranelift-codegen:*:*:*:*:*:rust:*:* | 0.84.0 to before 0.85.2 | Vulnerable | bytecodealliance |
| cpe:2.3:a:bytecodealliance:wasmtime:*:*:*:*:*:rust:*:* | 0.37.0 to before 0.38.2 | Vulnerable | bytecodealliance |
- cpe:2.3:a:bytecodealliance:cranelift-codegen:*:*:*:*:*:rust:*:* Versions 0.84.0 to before 0.85.2 Vulnerable ·bytecodealliance
- cpe:2.3:a:bytecodealliance:wasmtime:*:*:*:*:*:rust:*:* Versions 0.37.0 to before 0.38.2 Vulnerable ·bytecodealliance
Remediation
- Fix · CNA wasmtime (bytecodealliance) Fixed in 0.38.2, 0.85.2
- Fix · GHSA-5fhj-g3p3-pq9g wasmtime (crates.io) Fixed in 0.38.2 Advisory →
- Fix · GHSA-5fhj-g3p3-pq9g cranelift-codegen (crates.io) Fixed in 0.85.2 Advisory →
Timeline
- 2026-10-02 Threatist record created from CVE-2022-31146
- 2026-10-03 Alias added: GHSA-5fhj-g3p3-pq9g
References
Advisory 4
More bytecodealliance Cranelift-codegen vulnerabilities
- TI-2023-11636 Guest-controlled out-of-bounds read/write on x86_64 in wasmtime CVSS 3.1CRITICAL 10.0
- TI-2021-12298 Memory access due to code generation flaw in Cranelift module CVSS 3.1HIGH 8.8
- TI-2022-13211 Cranelift vulnerable to miscompilation of constant values in division on AArch64 CVSS 3.1HIGH 7.5
- TI-2022-13148 Miscompilation of `i8x16.swizzle` and `select` with v128 inputs in Wasmtime CVSS 3.1MEDIUM 5.6
- TI-2023-12205 wasmtime is a fast and secure runtime for WebAssembly. CVSS 3.1MEDIUM 4.3
Sources
- CVE-2022-31146 · CVE Program
- CVE-2022-31146 · NVD
- FIRST EPSS
- GHSA-5fhj-g3p3-pq9g · GitHub Advisory Database · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences