GHSA-8mj7-wxmc-f424: Neon Use After Free Vulnerability

HIGH
Published
Advisory Summary

GHSA-8mj7-wxmc-f424 is a HIGH use after free vulnerability (General Security Weakness) affecting Neon libraries in the crates.io ecosystem. The issue involves use after free in neon external buffers. Remediation is available by upgrading affected packages to version 0.10.1.

GHSA-8mj7-wxmc-f424 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-8mj7-wxmc-f424
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Neon
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-8mj7-wxmc-f424

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

neon fixed: 0.10.1
Upgrade neon to 0.10.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 neon

How to Check if You Are Affected

To determine whether your application is affected by GHSA-8mj7-wxmc-f424, inspect your project dependencies for Neon:

inspect dependencies for neon

Analyze the terminal output to locate any version of Neon in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.10.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 General Security Weakness. In Neon, 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

Neon provides functionality for creating JavaScript `ArrayBuffer` (and the `Buffer` subtype) instances backed by bytes allocated outside of V8/Node. The [`JsArrayBuffer::external`](https://docs.rs/neon/0.10.0/neon/types/struct.JsArrayBuffer.html#method.external) and [`JsBuffer::external`](https://docs.rs/neon/0.10.0/neon/types/struct.JsBuffer.html#method.external) did not require `T: 'static` prior to Neon `0.10.1`. This allowed creating an externally backed buffer from types that may be freed while they are still referenced by a JavaScript `ArrayBuffer`. The following example demonstrates use after free. It compiles on versions `<0.10.1` and fails to compile afterward. ```rust pub fn soundness_hole(mut cx: FunctionContext) -> JsResult<JsArrayBuffer> { let mut data = vec![0u8, 1, 2, 3]; // Creating an external from `&mut [u8]` instead of `Vec<u8>` since there is a blanket impl // of `AsMut<T> for &mut T` let buf = JsArrayBuffer::external(&mut cx, data.as_mut_slice()); // `buf` is still holding a reference to `data`! drop(data); Ok(buf) } ```

GHSA-8mj7-wxmc-f424 Affected Neon Versions

1 component(s)
Fixed Versions:
0.10.1
Product / Package Ecosystem Affected Versions Fixed Version
neon
crates.io
≥ 0.8.0
< 0.10.1
0.10.1

References

Frequently Asked Questions

What is GHSA-8mj7-wxmc-f424?
GHSA-8mj7-wxmc-f424 is a security vulnerability in Neon involving Use after free in Neon external buffers under General Security Weakness.
Which Neon versions are affected?
Affected versions include releases prior to 0.10.1 across affected packages: neon.
What version fixes GHSA-8mj7-wxmc-f424?
Upgrading to 0.10.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is neon affected?
Yes, neon is affected in releases prior to 0.10.1. Upgrade your dependency to 0.10.1 or later.
What CWE is associated with GHSA-8mj7-wxmc-f424?
GHSA-8mj7-wxmc-f424 is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-8mj7-wxmc-f424?
Run the dependency tree command: 'inspect dependencies for neon'. 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-8mj7-wxmc-f424",
  "modified" : "2022-06-17T00:13:40Z",
  "published" : "2022-06-17T00:13:40Z",
  "aliases" : [ ],
  "summary" : "Use after free in Neon external buffers",
  "details" : "Neon provides functionality for creating JavaScript `ArrayBuffer` (and the `Buffer` subtype) instances backed by bytes allocated outside of V8/Node. The [`JsArrayBuffer::external`](https://docs.rs/neon/0.10.0/neon/types/struct.JsArrayBuffer.html#method.external) and [`JsBuffer::external`](https://docs.rs/neon/0.10.0/neon/types/struct.JsBuffer.html#method.external) did not require `T: 'static` prior to Neon `0.10.1`. This allowed creating an externally backed buffer from types that may be freed while they are still referenced by a JavaScript `ArrayBuffer`.\n\nThe following example demonstrates use after free. It compiles on versions `<0.10.1` and fails to compile afterward.\n\n```rust\npub fn soundness_hole(mut cx: FunctionContext) -> JsResult<JsArrayBuffer> {\n    let mut data = vec![0u8, 1, 2, 3];\n    \n    // Creating an external from `&mut [u8]` instead of `Vec<u8>` since there is a blanket impl\n    // of `AsMut<T> for &mut T`\n    let buf = JsArrayBuffer::external(&mut cx, data.as_mut_slice());\n\n    // `buf` is still holding a reference to `data`!\n    drop(data);\n\n    Ok(buf)\n}\n```\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "neon"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.8.0"
      }, {
        "fixed" : "0.10.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/neon-bindings/neon/issues/896"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/neon-bindings/neon"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2022-0028.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-17T00:13:40Z",
    "nvd_published_at" : null
  }
}