GHSA-8mj7-wxmc-f424 Use after free in Neon external buffers

Not scored Published

A use-after-free vulnerability in the Neon Rust library allows attackers to execute arbitrary code or cause crashes via improperly managed external buffers.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Not stated
Victim action needed
Not needed
Fix
Available

What is GHSA-8mj7-wxmc-f424?

GHSA-8mj7-wxmc-f424 is an use after free vulnerability in neon, published on 22 May 2022.

Official description

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)
}

Which versions are affected by GHSA-8mj7-wxmc-f424?

3 open source packages ship an affected version, including neon.

PackageAffectedFixed in
neon crates.ioFrom 0.8.00.10.1
neon crates.ioFrom 0.8.00.10.1
neon crates.ioFrom 0.8.00.10.1

How do I fix GHSA-8mj7-wxmc-f424?

Upgrade neon to 0.10.1 or later.

Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.

Is GHSA-8mj7-wxmc-f424 being exploited?

There is no known exploitation of GHSA-8mj7-wxmc-f424 in the wild and no public exploit code.

Sources

Also known as RUSTSEC-2022-0028.

Is GHSA-8mj7-wxmc-f424 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free