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

- Severity: High (rating, scored by GitHub)
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2022-05-22T12:00:00.000Z
- Modified: 2023-11-08T04:17:25.410Z
- Also known as: RUSTSEC-2022-0028

## Description

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

(As written by GitHub Advisory Database.)

## Affected

- neon (crates.io): from 0.8.0 before 0.10.1

## References

- <https://github.com/neon-bindings/neon/issues/896> (report, web)
- <https://github.com/neon-bindings/neon> (package)
- <https://rustsec.org/advisories/RUSTSEC-2022-0028.html> (advisory, web)
- <https://crates.io/crates/neon> (package)

## Sources

- GitHub Advisory Database: [GHSA-8mj7-wxmc-f424](https://github.com/advisories/GHSA-8mj7-wxmc-f424), CC-BY-4.0, modified 2023-11-08
- RustSec Advisory Database: [RUSTSEC-2022-0028](https://rustsec.org/advisories/RUSTSEC-2022-0028.html), CC0-1.0, modified 2023-11-08

---

Page: https://cve.day/GHSA-8mj7-wxmc-f424 · Whole record: https://cve.day/GHSA-8mj7-wxmc-f424.json · Rebuilt by cve.day 2026-11-25T22:56:43.099Z
