# CVE-2021-32629: Memory access due to code generation flaw in Cranelift module

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

- **Severity:** HIGH 7.2
- **CVSS:** 7.2 (v3.1, CNA) `CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N`
- **CVSS metrics:** Attack vector: Local; Attack complexity: High; Privileges required: Low; User interaction: Required; Scope: Changed (impact reaches other components); Confidentiality impact: High; Integrity impact: High; Availability impact: None
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.46% (percentile 31, 2026-11-26)
- **CWE:** CWE-788
- **Aliases:** GHSA-hpqh-2wqx-7qp5, PYSEC-2021-87, RUSTSEC-2021-0067
- **Published:** 2021-05-21T12:00:00.000Z
- **Modified:** 2026-10-12T18:00:06.113Z

## Who should check

- Projects that depend on PyPI package wasmtime (\< 0.27.0)
- Projects that depend on crates.io package cranelift-codegen (\< 0.73.1)
- Anyone running bytecodealliance wasmtime \<= 0.73.0

## Description

Cranelift is an open-source code generator maintained by Bytecode Alliance. It translates a target-independent intermediate representation into executable machine code. There is a bug in 0.73 of the Cranelift x64 backend that can create a scenario that could result in a potential sandbox escape in a Wasm program. This bug was introduced in the new backend on 2020-09-08 and first included in a release on 2020-09-30, but the new backend was not the default prior to 0.73. The recently-released version 0.73 with default settings, and prior versions with an explicit build flag to select the new backend, are vulnerable. The bug in question performs a sign-extend instead of a zero-extend on a value loaded from the stack, under a specific set of circumstances. If those circumstances occur, the bug could allow access to memory addresses upto 2GiB before the start of the Wasm program heap. If the heap bound is larger than 2GiB, then it would be possible to read memory from a computable range dependent on the size of the heaps bound. The impact of this bug is highly dependent on heap implementation, specifically: \* if the heap has bounds checks, and \* does not rely exclusively on guard pages, and \* the heap bound is 2GiB or smaller \* then this bug cannot be used to reach memory from another Wasm program heap. The impact of the vulnerability is mitigated if there is no memory mapped in the range accessible using this bug, for example, if there is a 2 GiB guard region before the Wasm program heap. The bug in question performs a sign-extend instead of a zero-extend on a value loaded from the stack, when the register allocator reloads a spilled integer value narrower than 64 bits. This interacts poorly with another optimization: the instruction selector elides a 32-to-64-bit zero-extend operator when we know that an instruction producing a 32-bit value actually zeros the upper 32 bits of its destination register. Hence, we rely on these zeroed bits, but the type of the value is still i32, and the spill/reload reconstitutes those bits as the sign extension of the i32’s MSB. The issue would thus occur when: \* An i32 value in a Wasm program is greater than or equal to 0x8000\_0000; \* The value is spilled and reloaded by the register allocator due to high register pressure in the program between the value’s definition and its use; \* The value is produced by an instruction that we know to be “special” in that it zeroes the upper 32 bits of its destination: add, sub, mul, and, or; \* The value is then zero-extended to 64 bits in the Wasm program; \* The resulting 64-bit value is used. Under these circumstances there is a potential sandbox escape when the i32 value is a pointer. The usual code emitted for heap accesses zero-extends the Wasm heap address, adds it to a 64-bit heap base, and accesses the resulting address. If the zero-extend becomes a sign-extend, the program could reach backward and access memory up to 2GiB before the start of its heap. In addition to assessing the nature of the code generation bug in Cranelift, we have also determined that under specific circumstances, both Lucet and Wasmtime using this version of Cranelift may be exploitable. See referenced GitHub Advisory for more details.

## Affected and fixed versions

- PyPI `wasmtime`: affected \< 0.27.0; fixed 0.27.0 (osv)
- crates.io `cranelift-codegen`: affected \< 0.73.1; fixed 0.73.1 (osv)
- bytecodealliance wasmtime: \<= 0.73.0 (cvelist)

## Mitigation

- Upgrade wasmtime to 0.27.0 or later.
- Upgrade cranelift-codegen to 0.73.1 or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2021-32629.md
Affected: wasmtime < 0.27.0; cranelift-codegen < 0.73.1
Fixed in: 0.27.0, 0.73.1

Steps:
1. Search this machine and project for wasmtime (PyPI), 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-2021-32629 being exploited?

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

### How serious is CVE-2021-32629?

High: CVSS 7.2 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed). A user has to take an action, such as opening a link, for the attack to work. The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2021-32629?

wasmtime \< 0.27.0; cranelift-codegen \< 0.73.1.

### Is there a fix for CVE-2021-32629?

Yes. Fixed in 0.27.0, 0.73.1. Upgrade wasmtime to 0.27.0 or later. Upgrade cranelift-codegen to 0.73.1 or later.

### How do I check if I'm affected by CVE-2021-32629?

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-hpqh-2wqx-7qp5>
- vendor: <https://www.fastly.com/security-advisories/memory-access-due-to-code-generation-flaw-in-cranelift-module>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2021-32629>
- vendor: <https://rustsec.org/advisories/RUSTSEC-2021-0067.html>
- patch: <https://github.com/bytecodealliance/wasmtime/commit/95559c01aaa7c061088a433040f31e8291fb09d0>
- other: <https://crates.io/crates/cranelift-codegen>
- other: <https://github.com/RustSec/advisory-db/blob/main/crates/cranelift-codegen/RUSTSEC-2021-0067.md>
- other: <https://github.com/bytecodealliance/wasmtime/tree/main/cranelift>
- other: <https://github.com/pypa/advisory-database/tree/main/vulns/wasmtime/PYSEC-2021-87.yaml>

## 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-2021-32629>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/PYSEC-2021-87> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-hpqh-2wqx-7qp5> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/RUSTSEC-2021-0067> (license: <https://creativecommons.org/licenses/by/4.0/>)

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