{"id":"RUSTSEC-2026-0156","aliases":["RUSTSEC-2026-0156"],"related":[],"kind":"vulnerability","state":"published","title":"Bad-free in `MetaCallException::new`","summary":"`exception_struct` is a local stack variable, but the code passes its address to the C language as `&mut exception_struct as *mut _ as *mut c_void`. Then, the returned `MetaCallException` value is stored here:\n```rust\nOk(Self {\n    exception_struct: Arc::new(exception_struct),\n    value: exception_ptr,\n    leak: false,\n})\n```\nBecause leak is false, the destructor will run later. But the original exception pointer points to Rust stack memory.\n\n## Trigger\n\n```rust\n#[test]\nfn exception_bad_free_safe_api() {\n    let original = metacall::MetaCallException::new(\n        \"test\",\n        \"test\",\n        \"test\",\n        1,\n    );\n\n    drop(original); // AddressSanitizer: bad-free\n}\n```\n\n## Impact\n\nEvery time the `MetaCallException` is created, when it is dropped, it leads to a bad-free. This can be triggered through the safe public API `MetaCallException::new()`, with no `unsafe` required from the caller.","summaryFormat":"markdown","summarySource":"rustsec","descriptions":[{"lang":"en","text":"`exception_struct` is a local stack variable, but the code passes its address to the C language as `&mut exception_struct as *mut _ as *mut c_void`. Then, the returned `MetaCallException` value is stored here:\n```rust\nOk(Self {\n    exception_struct: Arc::new(exception_struct),\n    value: exception_ptr,\n    leak: false,\n})\n```\nBecause leak is false, the destructor will run later. But the original exception pointer points to Rust stack memory.\n\n## Trigger\n\n```rust\n#[test]\nfn exception_bad_free_safe_api() {\n    let original = metacall::MetaCallException::new(\n        \"test\",\n        \"test\",\n        \"test\",\n        1,\n    );\n\n    drop(original); // AddressSanitizer: bad-free\n}\n```\n\n## Impact\n\nEvery time the `MetaCallException` is created, when it is dropped, it leads to a bad-free. This can be triggered through the safe public API `MetaCallException::new()`, with no `unsafe` required from the caller.","format":"markdown","source":"rustsec"}],"published":"2026-06-01T12:00:00.000Z","modified":"2026-06-03T10:45:04.175Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected"}],"ecosystem":"crates.io","package":"metacall","purl":"pkg:cargo/metacall","source":"rustsec"}],"references":[{"url":"https://crates.io/crates/metacall","tags":["package"],"sources":["rustsec"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0156.html","tags":["advisory"],"sources":["rustsec"]},{"url":"https://github.com/metacall/core/issues/809","tags":["report"],"sources":["rustsec"]}],"credits":[],"sources":[{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2026-0156","url":"https://rustsec.org/advisories/RUSTSEC-2026-0156.html","licence":"CC0-1.0","modified":"2026-06-03T10:45:04.175Z"}],"updatedAt":"2026-11-25T22:56:43.364Z"}