Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS04bWo3LXd4bWMtZjQyNM4AArsu

Use after free in Neon external buffers

Neon provides functionality for creating JavaScript ArrayBuffer (and the Buffer subtype) instances backed by bytes allocated outside of V8/Node. The JsArrayBuffer::external and JsBuffer::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.

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)
}
Permalink: https://github.com/advisories/GHSA-8mj7-wxmc-f424
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS04bWo3LXd4bWMtZjQyNM4AArsu
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: almost 2 years ago
Updated: 10 months ago


Identifiers: GHSA-8mj7-wxmc-f424
References: Repository: https://github.com/neon-bindings/neon
Blast Radius: 0.0

Affected Packages

cargo:neon
Dependent packages: 47
Dependent repositories: 454
Downloads: 5,523,620 total
Affected Version Ranges: >= 0.8.0, < 0.10.1
Fixed in: 0.10.1
All affected versions: 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.9.0, 0.9.1, 0.10.0
All unaffected versions: 0.0.10, 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.1.10, 0.1.11, 0.1.12, 0.1.13, 0.1.14, 0.1.15, 0.1.16, 0.1.17, 0.1.18, 0.1.19, 0.1.20, 0.1.21, 0.1.22, 0.1.23, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.4.1, 0.4.2, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.6.0, 0.7.0, 0.7.1, 0.10.1, 1.0.0