{"answers":{"affected":"6 open source packages ship an affected version, including wasmtime and cranelift-codegen. It affects 1 product.","exploited":"There is no known exploitation of CVE-2021-32629 in the wild and no public exploit code.","fix":"Upgrade wasmtime to 0.27.0 or later.","what":"CVE-2021-32629 is a high-severity memory corruption vulnerability in bytecodealliance wasmtime, published on 24 May 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link."},"fix_prompt":"Check this codebase for CVE-2021-32629 and fix it if it is affected.\n\nWhat it is: CVE-2021-32629 is a high-severity memory corruption vulnerability in bytecodealliance wasmtime, published on 24 May 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.\nExploitation: There is no known exploitation of CVE-2021-32629 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- wasmtime (PyPI): affected all versions; fixed in 0.27.0\n- wasmtime (PyPI): affected all versions; fixed in 0.27.0\n- wasmtime (PyPI): affected all versions; fixed in 0.27.0\n- cranelift-codegen (crates.io): affected all versions; fixed in 0.73.1\n- cranelift-codegen (crates.io): affected all versions; fixed in 0.73.1\n- cranelift-codegen (crates.io): affected from 0.0.0-0; fixed in 0.73.1\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/CVE-2021-32629/ (Markdown: https://insights.sbomify.com/CVE-2021-32629/index.md)","id":"CVE-2021-32629","markdown":"https://insights.sbomify.com/CVE-2021-32629/index.md","name":"CVE-2021-32629","record":{"aliases":["GHSA-hpqh-2wqx-7qp5","PYSEC-2021-87","RUSTSEC-2021-0067","openSUSE-SU-2024:10673-1"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["data_read","security_bypass"],"network_reachable":"adjacent_or_local","non_default_config":false,"product_category":"Wasm code generator","requires_auth":"low_privilege","summary":"A flaw in the Cranelift x64 backend allows Wasm programs to read memory outside their heap, potentially enabling sandbox escapes.","user_interaction":"required","vuln_class":"memory_corruption"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"GitHub_M","cpe":[{"product":"cranelift-codegen","vendor":"bytecodealliance"}],"cvss":{"score":7.2,"severity":"high","source":"cna","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N","version":"3.1"},"cwes":[{"id":"CWE-681","name":"Incorrect Conversion between Numeric Types"},{"id":"CWE-125","name":"Out-of-bounds Read"},{"id":"CWE-788","name":"Access of Memory Location After End of Buffer"}],"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.","ecosystems":["PyPI","crates.io","openSUSE:Tumbleweed"],"exploits":{"exploitdb":0,"first_seen":null,"github_poc":0,"max_poc_stars":null,"metasploit":0,"nuclei":0,"refs":[],"tier":"none_known"},"has_fix":true,"headline":"Memory access due to code generation flaw in Cranelift module","id":"CVE-2021-32629","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"PyPI","product":null,"products":[],"type":"memory_corruption","year":"2021"},"n_packages":7,"n_references":4,"next":{"headline":"Various","id":"CVE-2021-32630"},"packages":[{"ecosystem":"PyPI","fixed":["0.27.0"],"introduced":["0"],"last_affected":[],"package":"wasmtime","purl":null,"source":"GHSA-hpqh-2wqx-7qp5"},{"ecosystem":"PyPI","fixed":["0.27.0"],"introduced":["0"],"last_affected":[],"package":"wasmtime","purl":"pkg:pypi/wasmtime","source":"GHSA-hpqh-2wqx-7qp5"},{"ecosystem":"PyPI","fixed":["0.27.0"],"introduced":["0"],"last_affected":[],"package":"wasmtime","purl":"pkg:pypi/wasmtime","source":"PYSEC-2021-87"},{"ecosystem":"crates.io","fixed":["0.73.1"],"introduced":["0"],"last_affected":[],"package":"cranelift-codegen","purl":null,"source":"GHSA-hpqh-2wqx-7qp5"},{"ecosystem":"crates.io","fixed":["0.73.1"],"introduced":["0"],"last_affected":[],"package":"cranelift-codegen","purl":"pkg:cargo/cranelift-codegen","source":"GHSA-hpqh-2wqx-7qp5"},{"ecosystem":"crates.io","fixed":["0.73.1"],"introduced":["0.0.0-0"],"last_affected":[],"package":"cranelift-codegen","purl":"pkg:cargo/cranelift-codegen","source":"RUSTSEC-2021-0067"},{"ecosystem":"openSUSE:Tumbleweed","fixed":["20210802-1.2"],"introduced":["0"],"last_affected":[],"package":"cargo-audit-advisory-db","purl":"pkg:rpm/opensuse/cargo-audit-advisory-db\u0026distro=openSUSE%20Tumbleweed","source":"openSUSE-SU-2024:10673-1"}],"prev":{"headline":"Vulnerability in handling large ziplists","id":"CVE-2021-32628"},"products":["wasmtime"],"published":"2021-05-24","related":[{"cvss_score":10,"headline":"Guest-controlled out-of-bounds read/write on x86_64 in wasmtime","id":"CVE-2023-26489","kev_date_added":null,"published":"2023-03-08"},{"cvss_score":6.4,"headline":"Use After Free in Wasmtime","id":"CVE-2022-31146","kev_date_added":null,"published":"2022-07-20"},{"cvss_score":5.9,"headline":"Cranelift vulnerable to miscompilation of constant values in division on AArch64","id":"CVE-2022-31169","kev_date_added":null,"published":"2022-07-21"},{"cvss_score":4.8,"headline":"Miscompilation of `i8x16.swizzle` and `select` with v128 inputs in Wasmtime","id":"CVE-2022-31104","kev_date_added":null,"published":"2022-06-27"},{"cvss_score":3.1,"headline":"wasmtime vulnerable to miscompilation of `i8x16.select` with the same inputs on x86_64","id":"CVE-2023-27477","kev_date_added":null,"published":"2023-03-08"}],"sources":[{"class":"attribution","licence":"CVE Terms of Use (MITRE)","name":"CVE List","prefix":"CVE"},{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"attribution","licence":"CC BY 4.0","name":"PyPA Advisory Database","prefix":"PYSEC"},{"class":"open","licence":"CC0 1.0","name":"RustSec","prefix":"RUSTSEC"},{"class":"attribution","licence":"CC BY 4.0","name":"SUSE","prefix":"openSUSE"},{"class":"attribution","licence":"US public information, NVD API terms","name":"NVD"},{"class":"attribution","licence":"CWE Terms of Use","name":"CWE (MITRE)"},{"class":"attribution","licence":"FIRST CVSS licence","name":"CVSS (FIRST)"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":"PUBLISHED","updated":"2024-08-03","vendors":["bytecodealliance"]},"summary":"A flaw in the Cranelift x64 backend allows Wasm programs to read memory outside their heap, potentially enabling sandbox escapes.","url":"https://insights.sbomify.com/CVE-2021-32629/"}