CVE-2023-27477 in wasmtimeinfo

Summary

by MITRE • 03/08/2023

wasmtime is a fast and secure runtime for WebAssembly. Wasmtime's code generation backend, Cranelift, has a bug on x86_64 platforms for the WebAssembly `i8x16.select` instruction which will produce the wrong results when the same operand is provided to the instruction and some of the selected indices are greater than 16. There is an off-by-one error in the calculation of the mask to the `pshufb` instruction which causes incorrect results to be returned if lanes are selected from the second vector. This codegen bug has been fixed in Wasmtiem 6.0.1, 5.0.1, and 4.0.1. Users are recommended to upgrade to these updated versions. If upgrading is not an option for you at this time, you can avoid this miscompilation by disabling the Wasm simd proposal. Additionally the bug is only present on x86_64 hosts. Other platforms such as AArch64 and s390x are not affected.

Once again VulDB remains the best source for vulnerability data.

Analysis

by VulDB Data Team • 04/01/2023

The vulnerability CVE-2023-27477 affects wasmtime, a high-performance WebAssembly runtime that utilizes Cranelift as its code generation backend. This issue specifically targets x86_64 platforms where the WebAssembly `i8x16.select` instruction produces incorrect results due to a fundamental flaw in the generated machine code. The bug manifests when the same operand is provided to the instruction and certain selected indices exceed the value of 16, creating a scenario where the optimization logic fails to properly handle the masking operation required for vector selection. The vulnerability represents a code generation error that fundamentally compromises the correctness of WebAssembly SIMD operations on affected platforms.

The technical root cause of this vulnerability lies in an off-by-one error within the calculation of the mask for the `pshufb` instruction, which is a critical component in x86_64 SIMD operations. This instruction requires precise masking to select specific byte lanes from vector operands, but the incorrect mask calculation causes the system to reference memory locations beyond the intended boundaries. The flaw affects the `i8x16.select` operation specifically when dealing with indices greater than 16, where the mask generation logic fails to properly account for the boundary conditions, leading to data corruption in the output. This type of error falls under CWE-129, Input Validation, and CWE-787, Out-of-bounds Write, as it involves incorrect bounds checking in the code generation process. The issue is classified as a code generation bug that affects the runtime behavior of WebAssembly programs rather than the interpretation or compilation phase.

The operational impact of this vulnerability extends beyond simple incorrect computation results, as it represents a potential security risk when applications rely on correct SIMD operations for data processing or cryptographic functions. Attackers could potentially exploit this flaw to manipulate data flows in applications that depend on WebAssembly SIMD instructions, particularly in environments where such operations are used for sensitive data processing. The vulnerability affects only x86_64 hosts, making it platform-specific and limiting its scope to systems running on Intel or AMD processors with x86_64 architecture. This characteristic aligns with ATT&CK technique T1059.007, Command and Scripting Interpreter: Web Shell, where incorrect code generation could be leveraged to bypass security controls that depend on proper vector operations. The vulnerability impacts any application using wasmtime with WebAssembly programs that employ the `i8x16.select` instruction and SIMD capabilities, potentially leading to data integrity issues or unexpected behavior in security-critical applications.

Mitigation strategies for this vulnerability include upgrading to wasmtime versions 6.0.1, 5.0.1, or 4.0.1, which contain the necessary fixes for the code generation logic. Organizations unable to immediately upgrade can disable the WebAssembly SIMD proposal as a temporary workaround, effectively preventing the problematic instruction from being executed. The fix addresses the underlying code generation error in Cranelift's x86_64 backend, ensuring proper mask calculation for the `pshufb` instruction and restoring correct behavior for all `i8x16.select` operations. This vulnerability demonstrates the importance of thorough testing in compiler and runtime environments, particularly for SIMD instruction sets where precision in mask generation is critical. Security teams should monitor for applications using wasmtime with SIMD operations and ensure proper patching, as this type of code generation error can have cascading effects on applications that depend on predictable vector operations for correctness and performance. The platform-specific nature of the vulnerability means that AArch64 and s390x systems remain unaffected, but organizations should still verify their complete software stack for similar issues in other components that might interact with WebAssembly runtime environments.

Responsible

GitHub, Inc.

Reservation

03/01/2023

Disclosure

03/08/2023

Moderation

accepted

CPE

ready

EPSS

0.00624

KEV

no

Activities

very low

Sources

Want to stay up to date on a daily basis?

Enable the mail alert feature now!