Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUSTSEC-2022-0028: Use after free in Neon external buffers #135

Open
github-actions bot opened this issue May 24, 2022 · 0 comments
Open

RUSTSEC-2022-0028: Use after free in Neon external buffers #135

github-actions bot opened this issue May 24, 2022 · 0 comments

Comments

@github-actions
Copy link
Contributor

Use after free in Neon external buffers

Details
Package neon
Version 0.9.1
URL neon-bindings/neon#896
Date 2022-05-22
Patched versions >=0.10.1
Unaffected versions <0.8.0

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: &#39;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 &lt;0.10.1 and fails to compile afterward.

pub fn soundness_hole(mut cx: FunctionContext) -&gt; JsResult&lt;JsArrayBuffer&gt; {
    let mut data = vec![0u8, 1, 2, 3];
    
    // Creating an external from `&amp;mut [u8]` instead of `Vec&lt;u8&gt;` since there is a blanket impl
    // of `AsMut&lt;T&gt; for &amp;mut T`
    let buf = JsArrayBuffer::external(&amp;mut cx, data.as_mut_slice());

    // `buf` is still holding a reference to `data`!
    drop(data);

    Ok(buf)
}

See advisory page for additional details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants