CVE-2022-23636: Wasmtime Invalid Drop Of Partially-initialized Instances Vulnerability

MODERATE
Advisory Identifier: GHSA-88xq-w8cq-xfg7
CVSS 5.1
CWE-824
Published
Advisory Summary

CVE-2022-23636 is a MODERATE (CVSS 5.1) invalid drop of partially-initialized instances vulnerability (CWE-824: Access of Uninitialized Pointer) affecting Wasmtime libraries in the crates.io ecosystem. The issue involves invalid drop of partially-initialized instances in the pooling instance allocator for modules with defined `externref` globals. Remediation is available by upgrading affected packages to version 0.34.1, 0.33.1.

CVE-2022-23636 at a Glance

CVE Identifier CVE-2022-23636
GHSA Identifier GHSA-88xq-w8cq-xfg7
Severity MODERATE
CVSS v3.1 Base Score 5.1
CWE Classification CWE-824: Access of Uninitialized Pointer
Affected Product Wasmtime
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 5.1

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

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

How to Fix CVE-2022-23636

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: 0.34.1
Upgrade wasmtime to 0.34.1
wasmtime fixed: 0.33.1
Upgrade wasmtime to 0.33.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-2022-23636, 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 0.34.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-824: Access of Uninitialized Pointer, where the product accesses or uses a pointer that has not been initialized. 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 There exists a bug in the pooling instance allocator in Wasmtime's runtime where a failure to instantiate an instance for a module that defines an `externref` global will result in an invalid drop of a `VMExternRef` via an uninitialized pointer. As instance slots may be reused between consecutive instantiations, the value of the uninitialized pointer may be from a previous instantiation and therefore under the control of an attacker via a module's initial values for its globals. If the attacker can somehow determine an address under their control inside the mapped memory representing the instance pool, it is possible to trick the runtime to call `drop_in_place` on a trait object under the attacker's control and therefore cause remote code execution. Exploiting the bug to cause remote code execution would be very difficult as attackers cannot determine the addresses of globals from code executing within the WebAssembly VM and the memory space for the instance pool cannot be statically determined. Operating system mitigations, such as [address space layout randomization](https://en.wikipedia.org/wiki/Address_space_layout_randomization), would additionally increase the difficulty for attackers to determine useful executable code to target with an exploit. It is also very unlikely that attackers will be able to directly influence the conditions that trigger the bug as described below. When the conditions to trigger the bug are met, however, it is much easier to exploit this bug to cause a denial of service by crashing the host with an invalid memory read. The following engine configuration (via [Config](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Config.html)) is required to be impacted by this bug: * support for the reference types proposal must be enabled (this is the default for `Config`). * a pooling allocation strategy must be configured via [Config::allocation_strategy](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Config.html#method.allocation_strategy), which is **not the default allocation strategy**. A module must be instantiated with **all the following characteristics**: * The module defines at least one table or memory. * The module defines at least one `externref` global. During instantiation, **one of the following** must occur to cause the instantiation to fail: * a call to `mprotect` or `VirtualAlloc` fails (e.g. out-of-memory conditions). * a resource limiter was configured in the associated `Store` (via [Store::limiter](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Store.html#method.limiter) or [Store::limiter_async](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Store.html#method.limiter_async)) and the limiter returns `false` from the initial call to `memory_growing` or `table_growing`. **Stores do not have a resource limiter set by default**. This results in a partially-initialized instance being dropped and that attempts to drop the uninitialized `VMExternRef` representing the defined `externref` global. We have reason to believe that the effective impact of this bug is relatively small because the usage of `externref` is still uncommon and without a resource limiter configured on the `Store`, which is not the default configuration, it is only possible to trigger the bug from an error returned by `mprotect` or `VirtualAlloc`. Note that on Linux with the `uffd` feature enabled, it is only possible to trigger the bug from a resource limiter as the call to `mprotect` is skipped; if no resource limiter is used, then this configuration is not vulnerable. ### Patches The bug has been fixed in 0.34.1 and 0.33.1; users are encouraged to upgrade as soon as possible. ### Workarounds If it is not possible to upgrade to 0.34.1 or 0.33.1 of the `wasmtime` crate, it is recommend that support for the reference types proposal be disabled by passing `false` to [Config::wasm_reference_types](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.wasm_reference_types). Doing so will prevent modules that use `externref` from being loaded entirely. ### 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-2022-23636 Affected Wasmtime Versions

2 component(s)
Fixed Versions:
0.34.10.33.1
Product / Package Ecosystem Affected Versions Fixed Version
wasmtime
crates.io
≥ 0.34.0
< 0.34.1
All 1 versions
0.34.0
0.34.1
wasmtime
crates.io
< 0.33.1
0.33.1

References

Frequently Asked Questions

What is CVE-2022-23636?
CVE-2022-23636 is a security vulnerability in Wasmtime involving Invalid drop of partially-initialized instances in the pooling instance allocator for modules with defined `externref` globals under CWE-824: Access of Uninitialized Pointer.
Which Wasmtime versions are affected?
Affected versions include releases prior to 0.34.1, 0.33.1 across affected packages: wasmtime.
What version fixes CVE-2022-23636?
Upgrading to 0.34.1, 0.33.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is wasmtime affected?
Yes, wasmtime is affected in releases prior to 0.34.1, 0.33.1. Upgrade your dependency to 0.34.1, 0.33.1 or later.
What is the CVSS score of CVE-2022-23636?
CVE-2022-23636 has a CVSS v3.1 base score of 5.1 (MODERATE) with vector string CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-23636?
CVE-2022-23636 is classified under CWE-824: Access of Uninitialized Pointer (The product accesses or uses a pointer that has not been initialized.).
How can I check crates.io dependencies for CVE-2022-23636?
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-88xq-w8cq-xfg7",
  "modified" : "2025-05-02T12:48:30Z",
  "published" : "2022-02-16T22:35:03Z",
  "aliases" : [ "CVE-2022-23636" ],
  "summary" : "Invalid drop of partially-initialized instances in the pooling instance allocator for modules with defined `externref` globals ",
  "details" : "### Impact\n\nThere exists a bug in the pooling instance allocator in Wasmtime's runtime where a failure to instantiate an instance for a module that defines an `externref` global will result in an invalid drop of a `VMExternRef` via an uninitialized pointer.\n\nAs instance slots may be reused between consecutive instantiations, the value of the uninitialized pointer may be from a previous instantiation and therefore under the control of an attacker via a module's initial values for its globals. If the attacker can somehow determine an address under their control inside the mapped memory representing the instance pool, it is possible to trick the runtime to call `drop_in_place` on a trait object under the attacker's control and therefore cause remote code execution.\n\nExploiting the bug to cause remote code execution would be very difficult as attackers cannot determine the addresses of globals from code executing within the WebAssembly VM and the memory space for the instance pool cannot be statically determined. Operating system mitigations, such as [address space layout randomization](https://en.wikipedia.org/wiki/Address_space_layout_randomization), would additionally increase the difficulty for attackers to determine useful executable code to target with an exploit. It is also very unlikely that attackers will be able to directly influence the conditions that trigger the bug as described below.\n\nWhen the conditions to trigger the bug are met, however, it is much easier to exploit this bug to cause a denial of service by crashing the host with an invalid memory read.\n\nThe following engine configuration (via [Config](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Config.html)) is required to be impacted by this bug:\n\n* support for the reference types proposal must be enabled (this is the default for `Config`).\n* a pooling allocation strategy must be configured via [Config::allocation_strategy](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Config.html#method.allocation_strategy), which is **not the default allocation strategy**.\n\nA module must be instantiated with **all the following characteristics**:\n\n* The module defines at least one table or memory.\n* The module defines at least one `externref` global.\n\nDuring instantiation, **one of the following** must occur to cause the instantiation to fail:\n\n* a call to `mprotect` or `VirtualAlloc` fails (e.g. out-of-memory conditions).\n* a resource limiter was configured in the associated `Store` (via [Store::limiter](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Store.html#method.limiter) or [Store::limiter_async](https://docs.rs/wasmtime/0.34.0/wasmtime/struct.Store.html#method.limiter_async)) and the limiter returns `false` from the initial call to `memory_growing` or `table_growing`. **Stores do not have a resource limiter set by default**.\n\nThis results in a partially-initialized instance being dropped and that attempts to drop the uninitialized `VMExternRef` representing the defined `externref` global.\n\nWe have reason to believe that the effective impact of this bug is relatively small because the usage of `externref` is still uncommon and without a resource limiter configured on the `Store`, which is not the default configuration, it is only possible to trigger the bug from an error returned by `mprotect` or `VirtualAlloc`.\n\nNote that on Linux with the `uffd` feature enabled, it is only possible to trigger the bug from a resource limiter as the call to `mprotect` is skipped; if no resource limiter is used, then this configuration is not vulnerable.\n\n### Patches\n\nThe bug has been fixed in 0.34.1 and 0.33.1; users are encouraged to upgrade as soon as possible.\n\n### Workarounds\n\nIf it is not possible to upgrade to 0.34.1 or 0.33.1 of the `wasmtime` crate, it is recommend that support for the reference types proposal be disabled by passing `false` to [Config::wasm_reference_types](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.wasm_reference_types).\n\nDoing so will prevent modules that use `externref` from being loaded entirely.\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:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "wasmtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.34.0"
      }, {
        "fixed" : "0.34.1"
      } ]
    } ],
    "versions" : [ "0.34.0" ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "wasmtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.33.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-88xq-w8cq-xfg7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23636"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bytecodealliance/wasmtime/commit/886ecc562040bef61faf19438c22285c2d62403a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bytecodealliance/wasmtime"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2022-0096.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-824" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-02-16T22:35:03Z",
    "nvd_published_at" : "2022-02-16T22:15:00Z"
  }
}