GHSA-xm67-587q-r2vw CVE-2023-27477 RUSTSEC-2023-0093
wasmtime vulnerable to miscompilation of `i8x16.select` with the same inputs on x86_64
- Severity
- 3.1 / 10
- Medium · CVSS 3.1
- Exploit chance (EPSS)
- 0.62%
- Chance of exploitation in the next 30 days. Higher than 49.93% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-193 Off-by-one Error
- Fix
- Available
- 2 packages have a fixed version
Description
Impact
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.
The impact of this miscompilation is that the WebAssembly instruction can produce incorrect results for the i8x16.select instruction. This should have no effect on embedders and does not represent a sandbox escape, for example. Guest programs, however, may behave unexpectedly due to the incorrect result of this instruction. In extreme cases if a guest program is handling untrusted input then the guest program may deviate from its intended execution, for example calling an imported host function with different arguments than intended. This still does not impact embedders, however, because there is no form of privilege escalation with the guest.
At this time it's expected that this codegen pattern doesn't show up in the wild that often. LLVM-generated modules, for example, do not appear to conventionally or idiomatically generate code which would hit this bug. It is possible, however, to still write code which triggers this, so it's recommended for embedders to analyze existing modules to see if any are affected.
Patches
This codegen bug has been fixed in Wasmtime 6.0.1, 5.0.1, and 4.0.1. Users are recommended to upgrade to these updated versions.
Workarounds
If upgrading is not an option for you at this time, you can avoid this miscompilation by disabling the Wasm simd proposal
config.wasm_simd(false);
Additionally the bug is only present on x86_64 hosts. Other platforms such as AArch64 and s390x are not affected.
References
- The WebAssembly simd proposal
- Mailing list announcement
- GitHub advisory
- Commit to fix this issue on Wasmtime's
mainbranch
For more information
If you have any questions or comments about this advisory:
- Reach out to us on the Bytecode Alliance Zulip chat
- Open an issue in the bytecodealliance/wasmtime repository
Affected versions
crates.io
| Package | Vulnerable | Fixed in |
|---|---|---|
| cranelift-codegen | >= 0.88.0, < 0.91.1 |
0.91.1 |
| cranelift-codegen | >= 0.92.0, < 0.92.1 |
0.92.1 |
| cranelift-codegen | >= 0.93.0, < 0.93.1 |
0.93.1 |
| wasmtime | >= 1.0.0, < 4.0.1 |
4.0.1 |
| wasmtime | >= 5.0.0, < 5.0.1 |
5.0.1 |
| wasmtime | >= 6.0.0, < 6.0.1 |
6.0.1 |
| wasmtime | >= 0.0.0-0, < 4.0.1>= 5.0.0, < 5.0.1>= 6.0.0, < 6.0.1 |
4.0.15.0.16.0.1 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
cranelift-codegen crates.io → 0.91.1
- cargo
cargo update -p cranelift-codegen --precise 0.91.1
wasmtime crates.io → 4.0.1
- cargo
cargo update -p wasmtime --precise 4.0.1
Severity breakdown
CVSS 3.1 3.1
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N
- Attack vector
- Network
- Attack complexity
- High
- Privileges required
- Low
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- Low
- Availability
- None
Weakness
CWE-193: Off-by-one Error
A product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value.
How to prevent it
- Implementation: When copying character arrays or using character manipulation methods, the correct size parameter must be used to account for the null terminator that needs to be added at the end of the array. Some examples of functions susceptible to this weakness in C include strcpy(), strncpy(), strcat(), strncat(), printf(), sprintf(), scanf() and sscanf().
References
Advisories
Packages
Other links
- github.com/bytecodealliance/wasmtime/security/advisories/GHSA-xm67-587q-r2vw
- github.com/bytecodealliance/wasmtime/commit/5dc2bbccbb363e474d2c9a1b8e38a89a43b…
- docs.rs/wasmtime/latest/wasmtime/struct.Config.html
- github.com/webassembly/simd
- groups.google.com/a/bytecodealliance.org/g/sec-announce/c/Mov-ItrNJsQ
- rustsec.org/advisories/RUSTSEC-2023-0093.html
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| RUSTSEC-2026-0424 Unchecked memory usage in transferring borrowed resources between components | Not rated yet | Also affects wasmtime |
| RUSTSEC-2026-0423 Cross-engine type confusion with host-created struct-types-with-supertypes | Not rated yet | Also affects wasmtime |
| RUSTSEC-2026-0422 Typed functions with `i31` or `nullref` arguments may panic due to insufficient type-check | Low | Also affects wasmtime |
| RUSTSEC-2026-0379 Wasmtime: Cranelift backend on aarch64 can jump to incorrect target on large Wasm `br_table` instruction | Critical | Also affects wasmtime |
| GHSA-9pvw-hwfg-92h5 Wasmtime: Panic lowering a host-created component model stream into a guest that expects a different payload type | Medium | Also affects wasmtime |
| GHSA-897f-g5gm-fmxm Wasmtime: Bit-packing in Cranelift compiler causes silent overflow and miscompilation | Critical | Also affects wasmtime |
| RUSTSEC-2026-0364 Exception tags can cause host data structures to be unaligned | Not rated yet | Also affects wasmtime |
| RUSTSEC-2026-0363 Component-model handle tables are capped only per instance and charged to no limit | Medium | Also affects wasmtime |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor