CVE-2023-26489: Wasmtime Wasmtime Vulnerable To Guest-controlled Out-of-bounds Vulnerability

CRITICAL
Advisory Identifier: GHSA-ff4p-7xrq-q5r8
CVSS 9.9
CWE-125 CWE-787
Published
Advisory Summary

CVE-2023-26489 is a CRITICAL (CVSS 9.9) wasmtime vulnerable to guest-controlled out-of-bounds vulnerability (CWE-125: Out-of-bounds Read) affecting Wasmtime libraries in the crates.io ecosystem. The issue involves wasmtime vulnerable to guest-controlled out-of-bounds read/write on x86_64. Remediation is available by upgrading affected packages to version 6.0.1, 0.91.1, 4.0.1, 5.0.1, 0.92.1, 0.93.1.

CVE-2023-26489 at a Glance

CVE Identifier CVE-2023-26489
GHSA Identifier GHSA-ff4p-7xrq-q5r8
Severity CRITICAL
CVSS v3.1 Base Score 9.9
CWE Classification CWE-125: Out-of-bounds Read
Affected Product Wasmtime
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 9.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2023-26489

To remediate this vulnerability, upgrade all affected Wasmtime dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

wasmtime fixed: 6.0.1
Upgrade wasmtime to 6.0.1
cranelift-codegen fixed: 0.91.1
Upgrade cranelift-codegen to 0.91.1
wasmtime fixed: 4.0.1
Upgrade wasmtime to 4.0.1
wasmtime fixed: 5.0.1
Upgrade wasmtime to 5.0.1
cranelift-codegen fixed: 0.92.1
Upgrade cranelift-codegen to 0.92.1
cranelift-codegen fixed: 0.93.1
Upgrade cranelift-codegen to 0.93.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for wasmtime

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-26489, inspect your project dependencies for Wasmtime:

inspect dependencies for wasmtime

Analyze the terminal output to locate any version of Wasmtime in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.0.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-125: Out-of-bounds Read, where the product reads data past the end, or before the beginning, of the intended buffer. In Wasmtime, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact Wasmtime's code generator, Cranelift, has a bug on x86_64 targets where address-mode computation mistakenly would calculate a 35-bit effective address instead of WebAssembly's defined 33-bit effective address. This bug means that, with default codegen settings, a wasm-controlled load/store operation could read/write addresses up to 35 bits away from the base of linear memory. Wasmtime's default sandbox settings provide up to 6G of protection from the base of linear memory to guarantee that any memory access in that range will be semantically correct. Due to this bug, however, addresses up to `0xffffffff * 8 + 0x7ffffffc = 36507222004 = ~34G` bytes away from the base of linear memory are possible from guest code. This means that the virtual memory 6G away from the base of linear memory up to ~34G away can be read/written by a malicious module. This out of bounds read/write is not semantically correct and poses a threat as an arbitrary read/write within ~34G of linear memory away from the base of a wasm module's linear memory. A guest module can, without the knowledge of the embedder, read/write memory in this region. The memory may belong to other WebAssembly instances when using the pooling allocator, for example. The memory may also belong to the embedder, depending on address layout. Embedders do not have a necessarily reliable means of detecting when this happens. Wasm loads/stores are allowed to cause machine segfaults meaning that an invalid read/write would be translated to a nominal WebAssembly trap. This means that a malicious module in the worst case silently reads/writes memory outside its bounds and in the "best" case looks like a normal "something trapped here" during its execution. This makes it difficult to retroactively determine whether this bug has been exploited on hosts. Affected embedders are recommended to analyze preexisting wasm modules to see if they're affected by the incorrect codegen rules and possibly correlate that with an anomalous number of traps during historical execution to locate possibly suspicious modules. The specific bug in Cranelift's x86_64 backend is that a WebAssembly address which is left-shifted by a constant amount from 1 to 3 will get folded into x86_64's addressing modes which perform shifts. For example `(i32.load (i32.shl (local.get 0) (i32.const 3)))` loads from the WebAssembly address `$local0 << 3`. When translated to Cranelift the `$local0 << 3` computation, a 32-bit value, is zero-extended to a 64-bit value and then added to the base address of linear memory. Cranelift would generate an instruction of the form `movl (%base, %local0, 8), %dst` which calculates `%base + %local0 << 3`. The bug here, however, is that the address computation happens with 64-bit values, where the `$local0 << 3` computation was supposed to be truncated to a 32-bit value. This means that `%local0`, which can use up to 32-bits for an address, gets 3 extra bits of address space to be accessible via this `movl` instruction. The fix in Cranelift is to remove the erroneous lowering rules in the backend which handle these zero-extended expressions. The above example is then translated to `movl %local0, %temp; shl $3, %temp; movl (%base, %temp), %dst` which correctly truncates the intermediate computation of `%local0 << 3` to 32-bits inside the `%temp` register which is then added to the `%base` value. ### Patches Wasmtime version 4.0.1, 5.0.1, and 6.0.1 have been released and have all been patched to no longer contain the erroneous lowering rules. ### Workarounds While updating Wasmtime is recommended, there are a number of possible workarounds that embedders can employ to mitigate this issue if updating is not possible. Note that none of these workarounds are on-by-default and require explicit configuration: * The `Config::static_memory_maximum_size(0)` option can be used to force all accesses to linear memory to be explicitly bounds-checked. This will perform a bounds check separately from the address-mode computation which correctly calculates the effective address of a load/store. Note that this can have a large impact on the execution performance of WebAssembly modules. * The `Config::static_memory_guard_size(1 << 36)` option can be used to greatly increase the guard pages placed after linear memory. This will guarantee that memory accesses up-to-34G away are guaranteed to be semantically correct by reserving unmapped memory for the instance. Note that this reserves a very large amount of virtual memory per-instances and can greatly reduce the maximum number of concurrent instances being run. * If using a non-x86_64 host is possible, then that will also work around this bug. This bug does not affect Wasmtime's or Cranelift's AArch64 backend, for example. ### References * [`Config::static_memory_maximum_size`](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.static_memory_maximum_size) * [`Config::static_memory_guard_size`](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.static_memory_guard_size) * [Mailing list announcement](https://groups.google.com/a/bytecodealliance.org/g/sec-announce/c/Mov-ItrNJsQ) * [GitHub advisory](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-ff4p-7xrq-q5r8) * [Commit to fix this issue on Wasmtime's `main` branch](https://github.com/bytecodealliance/wasmtime/commit/63fb30e4b4415455d47b3da5a19d79c12f4f2d1f) ### For more information If you have any questions or comments about this advisory: * Reach out to us on [the Bytecode Alliance Zulip chat](https://bytecodealliance.zulipchat.com/#narrow/stream/217126-wasmtime) * Open an issue in [the bytecodealliance/wasmtime repository](https://github.com/bytecodealliance/wasmtime/)

CVE-2023-26489 Affected Wasmtime Versions

6 component(s)
Fixed Versions:
6.0.10.91.14.0.15.0.10.92.10.93.1
Product / Package Ecosystem Affected Versions Fixed Version
wasmtime
crates.io
≥ 6.0.0
< 6.0.1
6.0.1
cranelift-codegen
crates.io
≥ 0.84.0
< 0.91.1
0.91.1
wasmtime
crates.io
≥ 0.37.0
< 4.0.1
4.0.1
wasmtime
crates.io
≥ 5.0.0
< 5.0.1
5.0.1
cranelift-codegen
crates.io
≥ 0.92.0
< 0.92.1
0.92.1
cranelift-codegen
crates.io
≥ 0.93.0
< 0.93.1
0.93.1

References

Frequently Asked Questions

What is CVE-2023-26489?
CVE-2023-26489 is a security vulnerability in Wasmtime involving wasmtime vulnerable to guest-controlled out-of-bounds read/write on x86_64 under CWE-125: Out-of-bounds Read.
Which Wasmtime versions are affected?
Affected versions include releases prior to 6.0.1, 0.91.1, 4.0.1, 5.0.1, 0.92.1, 0.93.1 across affected packages: wasmtime, cranelift-codegen.
What version fixes CVE-2023-26489?
Upgrading to 6.0.1, 0.91.1, 4.0.1, 5.0.1, 0.92.1, 0.93.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is wasmtime affected?
Yes, wasmtime is affected in releases prior to 6.0.1, 4.0.1, 5.0.1. Upgrade your dependency to 6.0.1, 4.0.1, 5.0.1 or later.
Is cranelift-codegen affected?
Yes, cranelift-codegen is affected in releases prior to 0.91.1, 0.92.1, 0.93.1. Upgrade your dependency to 0.91.1, 0.92.1, 0.93.1 or later.
What is the CVSS score of CVE-2023-26489?
CVE-2023-26489 has a CVSS v3.1 base score of 9.9 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2023-26489?
CVE-2023-26489 is classified under CWE-125: Out-of-bounds Read (The product reads data past the end, or before the beginning, of the intended buffer.).
How can I check crates.io dependencies for CVE-2023-26489?
Run the dependency tree command: 'inspect dependencies for wasmtime'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-ff4p-7xrq-q5r8",
  "modified" : "2025-05-02T12:52:10Z",
  "published" : "2023-03-09T00:10:53Z",
  "aliases" : [ "CVE-2023-26489" ],
  "summary" : "wasmtime vulnerable to guest-controlled out-of-bounds read/write on x86_64",
  "details" : "### Impact\n\nWasmtime's code generator, Cranelift, has a bug on x86_64 targets where address-mode computation mistakenly would calculate a 35-bit effective address instead of WebAssembly's defined 33-bit effective address. This bug means that, with default codegen settings, a wasm-controlled load/store operation could read/write addresses up to 35 bits away from the base of linear memory. Wasmtime's default sandbox settings provide up to 6G of protection from the base of linear memory to guarantee that any memory access in that range will be semantically correct. Due to this bug, however, addresses up to `0xffffffff * 8 + 0x7ffffffc = 36507222004 = ~34G` bytes away from the base of linear memory are possible from guest code. This means that the virtual memory 6G away from the base of linear memory up to ~34G away can be read/written by a malicious module.\n\nThis out of bounds read/write is not semantically correct and poses a threat as an arbitrary read/write within ~34G of linear memory away from the base of a wasm module's linear memory. A guest module can, without the knowledge of the embedder, read/write memory in this region. The memory may belong to other WebAssembly instances when using the pooling allocator, for example. The memory may also belong to the embedder, depending on address layout.\n\nEmbedders do not have a necessarily reliable means of detecting when this happens. Wasm loads/stores are allowed to cause machine segfaults meaning that an invalid read/write would be translated to a nominal WebAssembly trap. This means that a malicious module in the worst case silently reads/writes memory outside its bounds and in the \"best\" case looks like a normal \"something trapped here\" during its execution. This makes it difficult to retroactively determine whether this bug has been exploited on hosts. Affected embedders are recommended to analyze preexisting wasm modules to see if they're affected by the incorrect codegen rules and possibly correlate that with an anomalous number of traps during historical execution to locate possibly suspicious modules.\n\nThe specific bug in Cranelift's x86_64 backend is that a WebAssembly address which is left-shifted by a constant amount from 1 to 3 will get folded into x86_64's addressing modes which perform shifts. For example `(i32.load (i32.shl (local.get 0) (i32.const 3)))` loads from the WebAssembly address `$local0 << 3`. When translated to Cranelift the `$local0 << 3` computation, a 32-bit value, is zero-extended to a 64-bit value and then added to the base address of linear memory. Cranelift would generate an instruction of the form `movl (%base, %local0, 8), %dst` which calculates `%base + %local0 << 3`. The bug here, however, is that the address computation happens with 64-bit values, where the `$local0 << 3` computation was supposed to be truncated to a 32-bit value. This means that `%local0`, which can use up to 32-bits for an address, gets 3 extra bits of address space to be accessible via this `movl` instruction.\n\nThe fix in Cranelift is to remove the erroneous lowering rules in the backend which handle these zero-extended expressions. The above example is then translated to `movl %local0, %temp; shl $3, %temp; movl (%base, %temp), %dst` which correctly truncates the intermediate computation of `%local0 << 3` to 32-bits inside the `%temp` register which is then added to the `%base` value.\n\n### Patches\n\nWasmtime version 4.0.1, 5.0.1, and 6.0.1 have been released and have all been patched to no longer contain the erroneous lowering rules.\n\n### Workarounds\n\nWhile updating Wasmtime is recommended, there are a number of possible workarounds that embedders can employ to mitigate this issue if updating is not possible. Note that none of these workarounds are on-by-default and require explicit configuration:\n\n* The `Config::static_memory_maximum_size(0)` option can be used to force all accesses to linear memory to be explicitly bounds-checked. This will perform a bounds check separately from the address-mode computation which correctly calculates the effective address of a load/store. Note that this can have a large impact on the execution performance of WebAssembly modules.\n* The `Config::static_memory_guard_size(1 << 36)` option can be used to greatly increase the guard pages placed after linear memory. This will guarantee that memory accesses up-to-34G away are guaranteed to be semantically correct by reserving unmapped memory for the instance. Note that this reserves a very large amount of virtual memory per-instances and can greatly reduce the maximum number of concurrent instances being run.\n* If using a non-x86_64 host is possible, then that will also work around this bug. This bug does not affect Wasmtime's or Cranelift's AArch64 backend, for example.\n\n### References\n\n* [`Config::static_memory_maximum_size`](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.static_memory_maximum_size)\n* [`Config::static_memory_guard_size`](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.static_memory_guard_size)\n* [Mailing list announcement](https://groups.google.com/a/bytecodealliance.org/g/sec-announce/c/Mov-ItrNJsQ)\n* [GitHub advisory](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-ff4p-7xrq-q5r8)\n* [Commit to fix this issue on Wasmtime's `main` branch](https://github.com/bytecodealliance/wasmtime/commit/63fb30e4b4415455d47b3da5a19d79c12f4f2d1f)\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Reach out to us on [the Bytecode Alliance Zulip chat](https://bytecodealliance.zulipchat.com/#narrow/stream/217126-wasmtime)\n* Open an issue in [the bytecodealliance/wasmtime repository](https://github.com/bytecodealliance/wasmtime/)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "wasmtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.37.0"
      }, {
        "fixed" : "4.0.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "wasmtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.0.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "wasmtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.0.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "cranelift-codegen"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.84.0"
      }, {
        "fixed" : "0.91.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "cranelift-codegen"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.92.0"
      }, {
        "fixed" : "0.92.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "cranelift-codegen"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.93.0"
      }, {
        "fixed" : "0.93.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-ff4p-7xrq-q5r8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-26489"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bytecodealliance/wasmtime/commit/63fb30e4b4415455d47b3da5a19d79c12f4f2d1f"
  }, {
    "type" : "WEB",
    "url" : "https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.static_memory_guard_size"
  }, {
    "type" : "WEB",
    "url" : "https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.static_memory_maximum_size"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bytecodealliance/wasmtime"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/a/bytecodealliance.org/g/sec-announce/c/Mov-ItrNJsQ"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2023-0090.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-125", "CWE-787" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-03-09T00:10:53Z",
    "nvd_published_at" : "2023-03-08T20:15:00Z"
  }
}