CVE-2021-43790: Lucet runtime Use After Free Vulnerability

HIGH
Advisory Identifier: GHSA-hf79-8hjp-rrvq
CVSS 8.5
CWE-416
Published
Advisory Summary

CVE-2021-43790 is a HIGH (CVSS 8.5) use after free vulnerability (CWE-416: Use After Free) affecting Lucet runtime libraries in the crates.io ecosystem. The issue involves use after free in lucet. Remediation is available in the latest vendor maintenance releases.

CVE-2021-43790 at a Glance

CVE Identifier CVE-2021-43790
GHSA Identifier GHSA-hf79-8hjp-rrvq
Severity HIGH
CVSS v3.1 Base Score 8.5
CWE Classification CWE-416: Use After Free
Affected Product Lucet runtime
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 8.5

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

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
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-2021-43790

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

lucet-runtime fixed: Latest secure release
Upgrade lucet-runtime to Latest secure release
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 lucet-runtime

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-43790, inspect your project dependencies for Lucet runtime:

inspect dependencies for lucet-runtime

Analyze the terminal output to locate any version of Lucet runtime in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), 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-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. In Lucet runtime, 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 is a bug in the main branch of Lucet's `lucet-runtime` that allows a use-after-free in an `Instance` object that could result in memory corruption, data race, or other related issues. This bug was introduced early in the development of Lucet and is present in all releases. As a result of this bug, and dependent on the memory backing for the `Instance` objects, it is possible to trigger a use-after-free when the `Instance` is dropped. ### Patches Users should upgrade to the `main` branch of the Lucet repository. Lucet does not provide versioned releases on crates.io. ### Workarounds There is no way to remediate this vulnerability without upgrading. ### Description Lucet uses a "pool" allocator for new WebAssembly instances that are created. This pool allocator manages everything from the linear memory of the wasm instance, the runtime stack for async switching, as well as the memory behind the Instance itself. `Instances` are referred to via an `InstanceHandle` type which will, on drop, release the memory backing the Instance back to the pool. When an Instance is dropped, the fields of the `Instance` are destructed top-to-bottom, however when the `alloc: Alloc` field is destructed, the memory backing the `Instance` is released back to the pool before the destructors of the remaining fields are run. If another thread allocates the same memory from the pool while these destructors are still running, a race condition occurs that can lead to use-after-free errors. The bug was corrected by changing how the `InstanceHandle` destructor operates to ensure that the memory backing an Instance is only returned to the pool once the `Instance` has been completely destroyed. This security advisory has been assigned CVE-2021-43790. ### For more information If you have any questions or comments about this advisory: * Open an issue in [lucet repository](https://github.com/bytecodealliance/lucet) * Email [the lucet team](mailto:lucet@fastly.com) * See the [Bytecode Alliance security policy](https://bytecodealliance.org/security)

CVE-2021-43790 Affected Lucet runtime Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
lucet-runtime
crates.io
≤ 0.6.1

References

Frequently Asked Questions

What is CVE-2021-43790?
CVE-2021-43790 is a security vulnerability in Lucet runtime involving Use After Free in lucet under CWE-416: Use After Free.
Which Lucet runtime versions are affected?
Affected versions include releases prior to current release patches across affected packages: lucet-runtime.
What version fixes CVE-2021-43790?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is lucet-runtime affected?
Yes, lucet-runtime is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2021-43790?
CVE-2021-43790 has a CVSS v3.1 base score of 8.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2021-43790?
CVE-2021-43790 is classified under CWE-416: Use After Free (The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.).
How can I check crates.io dependencies for CVE-2021-43790?
Run the dependency tree command: 'inspect dependencies for lucet-runtime'. 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-hf79-8hjp-rrvq",
  "modified" : "2026-01-20T19:01:17Z",
  "published" : "2021-11-30T22:20:36Z",
  "aliases" : [ "CVE-2021-43790" ],
  "summary" : "Use After Free in lucet",
  "details" : "### Impact\nThere is a bug in the main branch of Lucet's `lucet-runtime` that allows a use-after-free in an `Instance` object that could result in memory corruption, data race, or other related issues.  This bug was introduced early in the development of Lucet and is present in all releases.  As a result of this bug, and dependent on the memory backing for the `Instance` objects, it is possible to trigger a use-after-free when the `Instance` is dropped.\n\n### Patches\nUsers should upgrade to the `main` branch of the Lucet repository. Lucet does not provide versioned releases on crates.io.\n\n### Workarounds\nThere is no way to remediate this vulnerability without upgrading.\n\n### Description\nLucet uses a \"pool\" allocator for new WebAssembly instances that are created. This pool allocator manages everything from the linear memory of the wasm instance, the runtime stack for async switching, as well as the memory behind the Instance itself. `Instances` are referred to via an `InstanceHandle` type which will, on drop, release the memory backing the Instance back to the pool.\n\nWhen an Instance is dropped, the fields of the `Instance` are destructed top-to-bottom, however when the `alloc: Alloc` field is destructed, the memory backing the `Instance` is released back to the pool before the destructors of the remaining fields are run. If another thread allocates the same memory from the pool while these destructors are still running, a race condition occurs that can lead to use-after-free errors.\n\nThe bug was corrected by changing how the `InstanceHandle` destructor operates to ensure that the memory backing an Instance is only returned to the pool once the `Instance` has been completely destroyed.\n\nThis security advisory has been assigned CVE-2021-43790.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [lucet repository](https://github.com/bytecodealliance/lucet)\n* Email [the lucet team](mailto:lucet@fastly.com)\n* See the [Bytecode Alliance security policy](https://bytecodealliance.org/security)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "lucet-runtime"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.6.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bytecodealliance/lucet/security/advisories/GHSA-hf79-8hjp-rrvq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43790"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bytecodealliance/lucet/commit/7c7757c772fb709c61b1442bcc1e1fbee97bf4a8"
  }, {
    "type" : "WEB",
    "url" : "https://crates.io/crates/lucet-runtime"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bytecodealliance/lucet"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2021-0155.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-11-30T20:56:59Z",
    "nvd_published_at" : "2021-11-30T00:15:00Z"
  }
}