{"answers":{"affected":"5 open source packages ship an affected version, including wasmtime and cranelift-codegen. It affects 2 products.","exploited":"There is no known exploitation of CVE-2022-31104 in the wild and no public exploit code.","fix":"Upgrade wasmtime to 0.38.1 or later.","what":"CVE-2022-31104 is a medium-severity vulnerability in bytecodealliance wasmtime, published on 27 Jun 2022. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for CVE-2022-31104 and fix it if it is affected.\n\nWhat it is: CVE-2022-31104 is a medium-severity vulnerability in bytecodealliance wasmtime, published on 27 Jun 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: There is no known exploitation of CVE-2022-31104 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- wasmtime (crates.io): affected all versions; fixed in 0.38.1\n- wasmtime (crates.io): affected all versions; fixed in 0.38.1\n- wasmtime (crates.io): affected from 0.0.0-0; fixed in 0.38.1\n- cranelift-codegen (crates.io): affected all versions; fixed in 0.85.1\n- cranelift-codegen (crates.io): affected all versions; fixed in 0.85.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-2022-31104/ (Markdown: https://insights.sbomify.com/CVE-2022-31104/index.md)","id":"CVE-2022-31104","markdown":"https://insights.sbomify.com/CVE-2022-31104/index.md","name":"CVE-2022-31104","record":{"aliases":["GHSA-jqwc-c49r-4w2x","RUSTSEC-2022-0095"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["other"],"network_reachable":"yes","non_default_config":false,"product_category":"WebAssembly runtime","requires_auth":"none","summary":"Miscompilation in Wasmtime's SIMD implementation on x86_64 can cause incorrect values or unintended branches in guest programs, potentially leading to secondary vulnerabilities.","user_interaction":"not_required","vuln_class":"other"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"GitHub_M","cpe":[{"product":"cranelift-codegen","vendor":"bytecodealliance"},{"product":"wasmtime","vendor":"bytecodealliance"}],"cvss":{"score":4.8,"severity":"medium","source":"cna","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L","version":"3.1"},"cwes":[{"id":"CWE-682","name":"Incorrect Calculation"}],"description":"Wasmtime is a standalone runtime for WebAssembly. In affected versions wasmtime's implementation of the SIMD proposal for WebAssembly on x86_64 contained two distinct bugs in the instruction lowerings implemented in Cranelift. The aarch64 implementation of the simd proposal is not affected. The bugs were presented in the `i8x16.swizzle` and `select` WebAssembly instructions. The `select` instruction is only affected when the inputs are of `v128` type. The correspondingly affected Cranelift instructions were `swizzle` and `select`. The `swizzle` instruction lowering in Cranelift erroneously overwrote the mask input register which could corrupt a constant value, for example. This means that future uses of the same constant may see a different value than the constant itself. The `select` instruction lowering in Cranelift wasn't correctly implemented for vector types that are 128-bits wide. When the condition was 0 the wrong instruction was used to move the correct input to the output of the instruction meaning that only the low 32 bits were moved and the upper 96 bits of the result were left as whatever the register previously contained (instead of the input being moved from). The `select` instruction worked correctly if the condition was nonzero, however. This bug in Wasmtime's implementation of these instructions on x86_64 represents an incorrect implementation of the specified semantics of these instructions according to the WebAssembly specification. The impact of this is benign for hosts running WebAssembly but represents possible vulnerabilities within the execution of a guest program. For example a WebAssembly program could take unintended branches or materialize incorrect values internally which runs the risk of exposing the program itself to other related vulnerabilities which can occur from miscompilations. We have released Wasmtime 0.38.1 and cranelift-codegen (and other associated cranelift crates) 0.85.1 which contain the corrected implementations of these two instructions in Cranelift. If upgrading is not an option for you at this time, you can avoid the vulnerability by disabling the Wasm simd proposal. Additionally the bug is only present on x86_64 hosts. Other aarch64 hosts are not affected. Note that s390x hosts don't yet implement the simd proposal and are not affected.","ecosystems":["crates.io"],"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":"Miscompilation of `i8x16.swizzle` and `select` with v128 inputs in Wasmtime","id":"CVE-2022-31104","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"crates.io","product":null,"products":[],"type":"other","year":"2022"},"n_packages":5,"n_references":6,"next":{"headline":"Argo CD's certificate verification is skipped for connections to OIDC providers","id":"CVE-2022-31105"},"packages":[{"ecosystem":"crates.io","fixed":["0.85.1"],"introduced":["0"],"last_affected":[],"package":"cranelift-codegen","purl":null,"source":"GHSA-jqwc-c49r-4w2x"},{"ecosystem":"crates.io","fixed":["0.85.1"],"introduced":["0"],"last_affected":[],"package":"cranelift-codegen","purl":"pkg:cargo/cranelift-codegen","source":"GHSA-jqwc-c49r-4w2x"},{"ecosystem":"crates.io","fixed":["0.38.1"],"introduced":["0"],"last_affected":[],"package":"wasmtime","purl":null,"source":"GHSA-jqwc-c49r-4w2x"},{"ecosystem":"crates.io","fixed":["0.38.1"],"introduced":["0"],"last_affected":[],"package":"wasmtime","purl":"pkg:cargo/wasmtime","source":"GHSA-jqwc-c49r-4w2x"},{"ecosystem":"crates.io","fixed":["0.38.1"],"introduced":["0.0.0-0"],"last_affected":[],"package":"wasmtime","purl":"pkg:cargo/wasmtime","source":"RUSTSEC-2022-0095"}],"prev":{"headline":"Improper handling of CSS at-rules in lettersanitizer","id":"CVE-2022-31103"},"products":["wasmtime"],"published":"2022-06-27","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":7.2,"headline":"Memory access due to code generation flaw in Cranelift module","id":"CVE-2021-32629","kev_date_added":null,"published":"2021-05-24"},{"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":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":"open","licence":"CC0 1.0","name":"RustSec","prefix":"RUSTSEC"},{"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":"no","exploitation":"none","technical_impact":"partial"},"state":"PUBLISHED","updated":"2025-04-23","vendors":["bytecodealliance"]},"summary":"Miscompilation in Wasmtime's SIMD implementation on x86_64 can cause incorrect values or unintended branches in guest programs, potentially leading to secondary vulnerabilities.","url":"https://insights.sbomify.com/CVE-2022-31104/"}