{"id":"RUSTSEC-2026-0302","aliases":["RUSTSEC-2026-0302"],"related":[],"kind":"vulnerability","state":"published","title":"`stack-graphs` C API exports are safe `extern \"C\"` functions","summary":"`stack_graphs::c` is a public module. From 0.0.3 through the current crates.io release 0.14.1, its pointer-taking entry points are `pub extern \"C\" fn` rather than `unsafe fn`. Safe Rust can call them.\n\n`sg_stack_graph_free` frees the pointer with `Box::from_raw`. `sg_stack_graph_free(std::ptr::null_mut())` is immediate undefined behavior. The same shape is used by the other `*_free` exports and by getters and mutators that dereference the caller-supplied pointer or pass it to `from_raw_parts` (`sg_stack_graph_nodes`, `sg_stack_graph_add_edges`, and the rest of the pointer-taking functions in `src/c.rs`). Constructors that take no pointer are not part of this issue.\n\nThe upstream repository is archived, so a fix cannot be filed there and no patched release exists. The soundness fix is to make every pointer-taking export `unsafe extern \"C\" fn`, with a safety comment that the pointer is non-null and, for `free`, came from the matching constructor.","summaryFormat":"markdown","summarySource":"rustsec","descriptions":[{"lang":"en","text":"`stack_graphs::c` is a public module. From 0.0.3 through the current crates.io release 0.14.1, its pointer-taking entry points are `pub extern \"C\" fn` rather than `unsafe fn`. Safe Rust can call them.\n\n`sg_stack_graph_free` frees the pointer with `Box::from_raw`. `sg_stack_graph_free(std::ptr::null_mut())` is immediate undefined behavior. The same shape is used by the other `*_free` exports and by getters and mutators that dereference the caller-supplied pointer or pass it to `from_raw_parts` (`sg_stack_graph_nodes`, `sg_stack_graph_add_edges`, and the rest of the pointer-taking functions in `src/c.rs`). Constructors that take no pointer are not part of this issue.\n\nThe upstream repository is archived, so a fix cannot be filed there and no patched release exists. The soundness fix is to make every pointer-taking export `unsafe extern \"C\" fn`, with a safety comment that the pointer is non-null and, for `free`, came from the matching constructor.","format":"markdown","source":"rustsec"}],"published":"2026-09-22T12:00:00.000Z","modified":"2026-09-22T21:00:02.879Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"semver","introduced":"0.0.3-0","status":"affected"}],"ecosystem":"crates.io","package":"stack-graphs","purl":"pkg:cargo/stack-graphs","source":"rustsec"}],"references":[{"url":"https://crates.io/crates/stack-graphs","tags":["package"],"sources":["rustsec"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0302.html","tags":["advisory"],"sources":["rustsec"]},{"url":"https://github.com/rustsec/advisory-db/issues/3241","tags":["report"],"sources":["rustsec"]},{"url":"https://github.com/github/stack-graphs","tags":["web"],"sources":["rustsec"]}],"credits":[],"sources":[{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2026-0302","url":"https://rustsec.org/advisories/RUSTSEC-2026-0302.html","licence":"CC0-1.0","modified":"2026-09-22T21:00:02.879Z"}],"updatedAt":"2026-11-25T22:56:43.413Z"}