CVE-2022-31146
JSON

6.4medium

Use After Free in Wasmtime

Severity
6.4medium CVSS:3.1 by GitHub_M
Exploit likelihood
1.28% (higher than 70% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-5fhj-g3p3-pq9gRUSTSEC-2022-0100

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

Product or packageVersionsReported by
bytecodealliance wasmtime>= 0.37.0, < 0.38.2, >= 0.84.0, < 0.85.2, from 0.37.0 before 0.38.2CVE List, NVD
wasmtime (crates.io)from 0.37.0 before 0.38.2, from 0.0.0-0 before 0.38.2GitHub Advisory Database, RustSec Advisory Database
cranelift-codegen (crates.io)from 0.84.0 before 0.85.2GitHub Advisory Database
bytecodealliance cranelift-codegenfrom 0.84.0 before 0.85.2NVD

All scores

GitHub_M6.4medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:L
GitHub6.4medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:L
NVD8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-416

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database

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:

RustSec Advisory Database

This is an entry in the RustSec database for the Wasmtime security advisory located at https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-5fhj-g3p3-pq9g. For more information see the GitHub-hosted security advisory.

NVD (es)

Se presenta un error en el generador de código de Wasmtime, Cranelift, en el que las funciones que usan tipos de referencia pueden carecer incorrectamente de los metadatos necesarios para la recolección de basura en tiempo de ejecución. Esto significa que si es producida una GC en tiempo de ejecución, el pase de GC pensará erróneamente que estas funciones no presentan referencias vivas a los valores de la GC, reclamándolos y reasignándolos. La función continuará entonces usando los valores asumiendo que no han sido GC'd, conllevando más tarde a un uso de memoria previamente liberada. Este bug fue introducido en la migración al asignador de registros "regalloc2" que ocurrió en Wasmtime versión 0.37.0 del 20-05-2022. Este bug ha sido parcheado y los usuarios deberían actualizar a Wasmtime versión 0.38.2. La mitigación de este problema puede lograrse al hacer una de las siguientes cosas: * Deshabilitar la propuesta de tipos de referencia pasando "false" a ["wasmtime::Config::wasm_reference_types"](https://docs.rs/wasmtime/0.38.0/wasmtime/struct.Config.html#method.wasm_reference_types). * Desactualizar a Wasmtime versión 0.36.0 o anterior

References

Sources

SourceRecordLicence
CVE ListCVE-2022-31146 changed 2025-04-23CVE Terms of Use
GitHub Advisory DatabaseGHSA-5fhj-g3p3-pq9g changed 2025-05-02CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2022-0100 changed 2026-10-12CC0-1.0
NVDCVE-2022-31146 changed 2026-06-17Public domain