Miggo Logo

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

7.2

CVSS Score

Basic Information

EPSS Score
-
Published
8/25/2021
Updated
11/19/2024
KEV Status
No
Technology
TechnologyRust

Technical Details

CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
cranelift-codegenrust< 0.73.10.73.1
wasmtimepip>= 0, < 0.27.00.27.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stemmed from how spilled 32-bit values were reloaded in the x64 backend. The gen_load_stack function in abi.rs previously used sign-extension (ExtKind::SignExtend) for i32 and smaller types when reloading from stack slots. This interacted dangerously with Cranelift's optimization that elides explicit zero-extends after 'special' instructions (add/sub/mul/and/or) that implicitly zero upper bits. When combined with register pressure causing spills, this created scenarios where high i32 values would be sign-extended instead of zero-extended during reload, leading to invalid memory accesses. The commit 95559c0 fixed this by always loading spilled integer values as 64-bit (with zero extension) and removing the conditional sign-extension logic.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

T**r* is * *u* in *.**.* o* t** *r*n*li*t x** ***k*n* t**t **n *r**t* * s**n*rio t**t *oul* r*sult in * pot*nti*l s*n**ox *s**p* in * W***ss*m*ly mo*ul*. Us*rs o* v*rsions *.**.* o* *r*n*li*t s*oul* up*r*** to *it**r *.**.* or *.** to r*m**i*t* t*is

Reasoning

T** vuln*r**ility st*mm** *rom *ow spill** **-*it v*lu*s w*r* r*lo**** in t** x** ***k*n*. T** **n_lo**_st**k *un*tion in **i.rs pr*viously us** si*n-*xt*nsion (*xtKin*::Si*n*xt*n*) *or i** *n* sm*ll*r typ*s w**n r*lo**in* *rom st**k slots. T*is int*