CVE-2022-31104: CWE-682: Incorrect Calculation in bytecodealliance wasmtime
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.
AI Analysis
Technical Summary
CVE-2022-31104 is a medium-severity vulnerability affecting Wasmtime, a standalone runtime for WebAssembly developed by the Bytecode Alliance. The issue lies in the incorrect implementation of two SIMD-related WebAssembly instructions, `i8x16.swizzle` and `select`, specifically on x86_64 architectures. Wasmtime uses Cranelift as its code generator, and the bug originates in Cranelift's instruction lowering phase for these SIMD instructions. For the `swizzle` instruction, the lowering erroneously overwrites the mask input register, potentially corrupting constant values and causing subsequent uses of the same constant to yield incorrect results. For the `select` instruction, when operating on 128-bit vector types (`v128`), the implementation incorrectly moves only the lower 32 bits of the selected input when the condition is zero, leaving the upper 96 bits undefined or containing stale register data. This results in incorrect values being materialized during WebAssembly guest program execution. Although the host environment running Wasmtime is not directly impacted, guest WebAssembly programs may experience unintended branching or incorrect internal values, which could lead to further vulnerabilities such as logic errors or exploitation opportunities arising from miscompilation. The vulnerability affects Wasmtime versions prior to 0.38.1 and Cranelift-codegen versions prior to 0.85.0. The bug is limited to x86_64 hosts; ARM64 (aarch64) and s390x architectures are not affected. Mitigation includes upgrading to the fixed versions or disabling the Wasm SIMD proposal if upgrading is not feasible. No known exploits have been reported in the wild to date.
Potential Impact
For European organizations utilizing Wasmtime for WebAssembly execution on x86_64 platforms, this vulnerability could lead to subtle and hard-to-detect errors within guest WebAssembly applications. Such errors may cause incorrect program behavior, including unintended branching and data corruption, which could be exploited by malicious WebAssembly modules to bypass security controls or cause denial of service within the guest environment. While the host system's confidentiality, integrity, and availability are not directly compromised, the integrity of applications relying on Wasmtime could be undermined, potentially affecting critical services that embed WebAssembly for sandboxed execution, such as cloud platforms, edge computing, and serverless environments. Given the increasing adoption of WebAssembly in cloud-native and edge scenarios, this vulnerability could impact sectors like finance, telecommunications, and critical infrastructure where Wasmtime is integrated. The lack of known exploits reduces immediate risk, but the potential for exploitation through crafted WebAssembly modules necessitates prompt remediation to maintain application correctness and security.
Mitigation Recommendations
1. Upgrade Wasmtime to version 0.38.1 or later and Cranelift-codegen to version 0.85.0 or later to apply the corrected instruction lowerings. 2. If upgrading is not immediately possible, disable the WebAssembly SIMD proposal in Wasmtime configurations to avoid triggering the vulnerable code paths. 3. Audit and test WebAssembly guest applications running on affected Wasmtime versions for anomalous behavior or incorrect outputs that could indicate exploitation or manifestation of the bug. 4. Implement strict input validation and sandboxing controls on WebAssembly modules to limit the risk of malicious modules exploiting this vulnerability. 5. Monitor Wasmtime and Cranelift project updates and security advisories for any further patches or related vulnerabilities. 6. For organizations deploying Wasmtime in production, incorporate this vulnerability into risk assessments and incident response plans, emphasizing the importance of timely patching and configuration management.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Finland, Denmark, Ireland
CVE-2022-31104: CWE-682: Incorrect Calculation in bytecodealliance wasmtime
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.
AI-Powered Analysis
Technical Analysis
CVE-2022-31104 is a medium-severity vulnerability affecting Wasmtime, a standalone runtime for WebAssembly developed by the Bytecode Alliance. The issue lies in the incorrect implementation of two SIMD-related WebAssembly instructions, `i8x16.swizzle` and `select`, specifically on x86_64 architectures. Wasmtime uses Cranelift as its code generator, and the bug originates in Cranelift's instruction lowering phase for these SIMD instructions. For the `swizzle` instruction, the lowering erroneously overwrites the mask input register, potentially corrupting constant values and causing subsequent uses of the same constant to yield incorrect results. For the `select` instruction, when operating on 128-bit vector types (`v128`), the implementation incorrectly moves only the lower 32 bits of the selected input when the condition is zero, leaving the upper 96 bits undefined or containing stale register data. This results in incorrect values being materialized during WebAssembly guest program execution. Although the host environment running Wasmtime is not directly impacted, guest WebAssembly programs may experience unintended branching or incorrect internal values, which could lead to further vulnerabilities such as logic errors or exploitation opportunities arising from miscompilation. The vulnerability affects Wasmtime versions prior to 0.38.1 and Cranelift-codegen versions prior to 0.85.0. The bug is limited to x86_64 hosts; ARM64 (aarch64) and s390x architectures are not affected. Mitigation includes upgrading to the fixed versions or disabling the Wasm SIMD proposal if upgrading is not feasible. No known exploits have been reported in the wild to date.
Potential Impact
For European organizations utilizing Wasmtime for WebAssembly execution on x86_64 platforms, this vulnerability could lead to subtle and hard-to-detect errors within guest WebAssembly applications. Such errors may cause incorrect program behavior, including unintended branching and data corruption, which could be exploited by malicious WebAssembly modules to bypass security controls or cause denial of service within the guest environment. While the host system's confidentiality, integrity, and availability are not directly compromised, the integrity of applications relying on Wasmtime could be undermined, potentially affecting critical services that embed WebAssembly for sandboxed execution, such as cloud platforms, edge computing, and serverless environments. Given the increasing adoption of WebAssembly in cloud-native and edge scenarios, this vulnerability could impact sectors like finance, telecommunications, and critical infrastructure where Wasmtime is integrated. The lack of known exploits reduces immediate risk, but the potential for exploitation through crafted WebAssembly modules necessitates prompt remediation to maintain application correctness and security.
Mitigation Recommendations
1. Upgrade Wasmtime to version 0.38.1 or later and Cranelift-codegen to version 0.85.0 or later to apply the corrected instruction lowerings. 2. If upgrading is not immediately possible, disable the WebAssembly SIMD proposal in Wasmtime configurations to avoid triggering the vulnerable code paths. 3. Audit and test WebAssembly guest applications running on affected Wasmtime versions for anomalous behavior or incorrect outputs that could indicate exploitation or manifestation of the bug. 4. Implement strict input validation and sandboxing controls on WebAssembly modules to limit the risk of malicious modules exploiting this vulnerability. 5. Monitor Wasmtime and Cranelift project updates and security advisories for any further patches or related vulnerabilities. 6. For organizations deploying Wasmtime in production, incorporate this vulnerability into risk assessments and incident response plans, emphasizing the importance of timely patching and configuration management.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2022-05-18T00:00:00.000Z
- Cisa Enriched
- true
Threat ID: 682d9844c4522896dcbf36ad
Added to database: 5/21/2025, 9:09:24 AM
Last enriched: 6/23/2025, 3:06:25 AM
Last updated: 8/13/2025, 7:22:46 AM
Views: 16
Related Threats
CVE-2025-53948: CWE-415 Double Free in Santesoft Sante PACS Server
HighCVE-2025-52584: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-46269: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-54862: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumCVE-2025-54759: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.