{ "schema_version": "1.4.0", "id": "GHSA-gfgm-chr3-x6px", "modified": "2022-12-30T17:48:30Z", "published": "2022-12-30T17:48:30Z", "aliases": [], "summary": "prettytable-rs: Force cast a &Vec to &[T] may lead to undefined behavior", "details": "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, `&Vec` and `&[T]` still might not have the same layout. Treating them equally may lead to undefinted behavior (UB).\n", "severity": [], "affected": [ { "package": { "ecosystem": "crates.io", "name": "prettytable-rs" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.10.0" } ] } ] } ], "references": [ { "type": "WEB", "url": "https://github.com/phsym/prettytable-rs/issues/145" }, { "type": "PACKAGE", "url": "https://github.com/phsym/prettytable-rs" }, { "type": "WEB", "url": "https://rustsec.org/advisories/RUSTSEC-2022-0074.html" } ], "database_specific": { "cwe_ids": [], "severity": "MODERATE", "github_reviewed": true, "github_reviewed_at": "2022-12-30T17:48:30Z", "nvd_published_at": null } }