{"id":"CVE-2022-31146","published":"2022-07-20T22:30:16Z","modified":"2025-04-23T17:57:59Z","title":"Use After Free in Wasmtime","vendor":"bytecodealliance","product":"wasmtime","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":6.4,"severity":"MEDIUM","version":"3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:L","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.01281,"percentile":0.70745,"provenance":"source"},"cwes":[{"id":"CWE-416","name":"Use After Free"}],"references":[{"url":"https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-5fhj-g3p3-pq9g","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/WebAssembly/reference-types","tags":["x_refsource_MISC"]},{"url":"https://github.com/bytecodealliance/wasmtime/","tags":["x_refsource_MISC"]}],"priority":{"score":18.6,"factors":[{"name":"EPSS percentile","points":14.15},{"name":"CVSS severity","points":4.48}]},"vendorSlug":"bytecodealliance","affectedVersions":[{"vendor":"bytecodealliance","product":"wasmtime","versions":[">= 0.37.0, < 0.38.2",">= 0.84.0, < 0.85.2"]}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"partial","timestamp":"2025-04-23T14:03:18.900742Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"crates.io","package":"wasmtime","vulnerableRanges":[">=0.37.0, <0.38.2",">=0.0.0-0, <0.38.2"],"patched":["0.38.2"],"from":["GHSA-5fhj-g3p3-pq9g","RUSTSEC-2022-0100"],"provenance":"source"},{"ecosystem":"crates.io","package":"cranelift-codegen","vulnerableRanges":[">=0.84.0, <0.85.2"],"patched":["0.85.2"],"from":["GHSA-5fhj-g3p3-pq9g"],"provenance":"source"}],"summary":{"text":"Wasmtime's Cranelift code generator fails to emit the metadata that tells the runtime garbage collector about live references in functions that use reference types, so a GC pass can wrongly reclaim values still in use and lead to a use-after-free. An attacker who can get a guest WebAssembly module to run in the affected runtime, and who can trigger a garbage collection at runtime, can exploit this, with the reference types proposal enabled being a precondition for the flaw to apply.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T20:35:22Z"},"euvd":{"id":"EUVD-2022-6243","exploited":false,"provenance":"source"},"lineage":{"packageHistory":[{"cve":"CVE-2021-32629","published":"2021-05-24","fixed":"0.73.1","kev":false},{"cve":"CVE-2022-31104","published":"2022-06-27","fixed":"0.85.1","kev":false,"link":{"from":"CVE-2022-31104","to":"CVE-2022-31146","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"crates.io:cranelift-codegen","fromFixed":"0.85.1","toFixed":"0.85.2","daysApart":23}]}},{"cve":"CVE-2022-31146","published":"2022-07-20","fixed":"0.85.2","kev":false},{"cve":"CVE-2022-31169","published":"2022-07-21","fixed":"0.85.2","kev":false},{"cve":"CVE-2023-26489","published":"2023-03-08","fixed":"0.93.1","kev":false},{"cve":"CVE-2023-27477","published":"2023-03-08","fixed":"0.93.1","kev":false}],"package":"crates.io:cranelift-codegen"}}