{"id":"GHSA-8mj7-wxmc-f424","aliases":["RUSTSEC-2022-0028"],"status":"published","title":"Use after free in Neon external buffers","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`.\n\nThe following example demonstrates use after free. It compiles on versions `\u003c0.10.1` and fails to compile afterward.\n\n```rust\npub fn soundness_hole(mut cx: FunctionContext) -\u003e JsResult\u003cJsArrayBuffer\u003e {\n    let mut data = vec![0u8, 1, 2, 3];\n    \n    // Creating an external from `\u0026mut [u8]` instead of `Vec\u003cu8\u003e` since there is a blanket impl\n    // of `AsMut\u003cT\u003e for \u0026mut T`\n    let buf = JsArrayBuffer::external(\u0026mut cx, data.as_mut_slice());\n\n    // `buf` is still holding a reference to `data`!\n    drop(data);\n\n    Ok(buf)\n}\n```","facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"published":"2022-05-22T12:00:00Z","modified":"2023-11-08T04:17:25Z","fixes":[{"ecosystem":"crates.io","package":"neon","fixed_in":["0.10.1"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"crates.io","package":"neon","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0.8.0"},{"fixed":"0.10.1"}]}]},{"source":"osv","ecosystem":"crates.io","package":"neon","ranges":[{"type":"SEMVER","events":[{"introduced":"0.8.0"},{"fixed":"0.10.1"}]}]},{"source":"osv","ecosystem":"crates.io","package":"neon","ranges":[{"type":"SEMVER","events":[{"introduced":"0.8.0"},{"fixed":"0.10.1"}]}]}],"references":[{"url":"https://github.com/neon-bindings/neon/issues/896","tags":["web","report"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2022-0028.html","tags":["web","advisory"]},{"url":"https://github.com/advisories/GHSA-8mj7-wxmc-f424"},{"url":"https://github.com/neon-bindings/neon","tags":["package"]},{"url":"https://crates.io/crates/neon","tags":["package"]}],"sources":{"ghsa":[{"id":"GHSA-8mj7-wxmc-f424","title":"Use after free in Neon external buffers","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`.\n\nThe following example demonstrates use after free. It compiles on versions `\u003c0.10.1` and fails to compile afterward.\n\n```rust\npub fn soundness_hole(mut cx: FunctionContext) -\u003e JsResult\u003cJsArrayBuffer\u003e {\n    let mut data = vec![0u8, 1, 2, 3];\n    \n    // Creating an external from `\u0026mut [u8]` instead of `Vec\u003cu8\u003e` since there is a blanket impl\n    // of `AsMut\u003cT\u003e for \u0026mut T`\n    let buf = JsArrayBuffer::external(\u0026mut 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","status":"published","published":"2022-06-17T00:13:40Z","modified":"2023-06-13T18:37:13Z","updated_at":"2026-11-02T14:36:53.654352Z"}],"osv":[{"id":"GHSA-8mj7-wxmc-f424","title":"Use after free in Neon external buffers","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`.\n\nThe following example demonstrates use after free. It compiles on versions `\u003c0.10.1` and fails to compile afterward.\n\n```rust\npub fn soundness_hole(mut cx: FunctionContext) -\u003e JsResult\u003cJsArrayBuffer\u003e {\n    let mut data = vec![0u8, 1, 2, 3];\n    \n    // Creating an external from `\u0026mut [u8]` instead of `Vec\u003cu8\u003e` since there is a blanket impl\n    // of `AsMut\u003cT\u003e for \u0026mut T`\n    let buf = JsArrayBuffer::external(\u0026mut 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","status":"published","published":"2022-06-17T00:13:40Z","modified":"2023-11-08T04:17:25.410603Z","updated_at":"2026-11-02T15:46:42.437513Z"},{"id":"RUSTSEC-2022-0028","title":"Use after free in Neon external buffers","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`.\n\nThe following example demonstrates use after free. It compiles on versions `\u003c0.10.1` and fails to compile afterward.\n\n```rust\npub fn soundness_hole(mut cx: FunctionContext) -\u003e JsResult\u003cJsArrayBuffer\u003e {\n    let mut data = vec![0u8, 1, 2, 3];\n    \n    // Creating an external from `\u0026mut [u8]` instead of `Vec\u003cu8\u003e` since there is a blanket impl\n    // of `AsMut\u003cT\u003e for \u0026mut T`\n    let buf = JsArrayBuffer::external(\u0026mut cx, data.as_mut_slice());\n\n    // `buf` is still holding a reference to `data`!\n    drop(data);\n\n    Ok(buf)\n}\n```","status":"published","published":"2022-05-22T12:00:00Z","modified":"2023-11-08T04:17:25.410603Z","updated_at":"2026-11-02T15:53:39.971022Z"}]}}
