{"id":"GHSA-gfgm-chr3-x6px","aliases":["RUSTSEC-2022-0074"],"status":"published","title":"prettytable-rs: Force cast a \u0026Vec\u003cT\u003e to \u0026[T] may lead to undefined behavior","description":"In function `Table::as_ref`, a reference of vector is force cast to slice. There are multiple problems here:\n1. To guarantee the size is correct, we have to first do `Vec::shrink_to_fit`. The function requires a mutable reference, so we have to force cast from immutable to mutable, which is undefined behavior (UB).\n2. Even if (1) is sound, `\u0026Vec\u003cT\u003e` and `\u0026[T]` still might not have the same layout. Treating them equally may lead to undefinted behavior (UB).","facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"published":"2022-12-02T12:00:00Z","modified":"2023-11-08T04:19:29Z","fixes":[{"ecosystem":"crates.io","package":"prettytable-rs","fixed_in":["0.10.0"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"crates.io","package":"prettytable-rs","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.10.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"prettytable-rs","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.10.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"prettytable-rs","ranges":[{"type":"SEMVER","events":[{"introduced":"0.0.0-0"},{"fixed":"0.10.0"}]}]}],"references":[{"url":"https://github.com/phsym/prettytable-rs/issues/145","tags":["web","report"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2022-0074.html","tags":["web","advisory"]},{"url":"https://github.com/advisories/GHSA-gfgm-chr3-x6px"},{"url":"https://github.com/phsym/prettytable-rs","tags":["package"]},{"url":"https://crates.io/crates/prettytable-rs","tags":["package"]}],"sources":{"ghsa":[{"id":"GHSA-gfgm-chr3-x6px","title":"prettytable-rs: Force cast a \u0026Vec\u003cT\u003e to \u0026[T] may lead to undefined behavior","description":"In function `Table::as_ref`, a reference of vector is force cast to slice. There are multiple problems here:\n1. To guarantee the size is correct, we have to first do `Vec::shrink_to_fit`. The function requires a mutable reference, so we have to force cast from immutable to mutable, which is undefined behavior (UB).\n2. Even if (1) is sound, `\u0026Vec\u003cT\u003e` and `\u0026[T]` still might not have the same layout. Treating them equally may lead to undefinted behavior (UB).\n","status":"published","published":"2022-12-30T17:48:30Z","modified":"2023-01-07T05:05:44Z","updated_at":"2026-11-02T14:36:01.39976Z"}],"osv":[{"id":"GHSA-gfgm-chr3-x6px","title":"prettytable-rs: Force cast a \u0026Vec\u003cT\u003e to \u0026[T] may lead to undefined behavior","description":"In function `Table::as_ref`, a reference of vector is force cast to slice. There are multiple problems here:\n1. To guarantee the size is correct, we have to first do `Vec::shrink_to_fit`. The function requires a mutable reference, so we have to force cast from immutable to mutable, which is undefined behavior (UB).\n2. Even if (1) is sound, `\u0026Vec\u003cT\u003e` and `\u0026[T]` still might not have the same layout. Treating them equally may lead to undefinted behavior (UB).\n","status":"published","published":"2022-12-30T17:48:30Z","modified":"2023-11-08T04:19:29.041635Z","updated_at":"2026-11-02T15:46:47.822182Z"},{"id":"RUSTSEC-2022-0074","title":"Force cast a \u0026Vec\u003cT\u003e to \u0026[T]","description":"In function `Table::as_ref`, a reference of vector is force cast to slice. There are multiple problems here:\n1. To guarantee the size is correct, we have to first do `Vec::shrink_to_fit`. The function requires a mutable reference, so we have to force cast from immutable to mutable, which is UB.\n2. Even if (1) is sound, `\u0026Vec\u003cT\u003e` and `\u0026[T]` still might not have the same layout. Treating them equally may lead to UB.","status":"published","published":"2022-12-02T12:00:00Z","modified":"2023-11-08T04:19:29.041635Z","updated_at":"2026-11-02T15:53:39.971022Z"}]}}
