GHSA-gfgm-chr3-x6px
MEDIUMprettytable-rs: Force cast a &Vec<T> to &[T] may lead to undefined behavior
In function Table::as_ref, a reference of vector is force cast to slice. There are multiple problems here:
- 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). - Even if (1) is sound,
&Vec<T>and&[T]still might not have the same layout. Treating them equally may lead to undefinted behavior (UB).
- Published
- 2 Dec 2022
- Last modified
- 8 Nov 2023
- Also known as
- RUSTSEC-2022-0074
- Sources
- OSVJSONOSV RUSTSEC-2022-0074JSON
Affected
| Source | Vendor / ecosystem | Product / package | Affected versions | Fixed in |
|---|---|---|---|---|
| OSV | crates.io | prettytable-rs | < 0.10.0 | 0.10.0 |
| OSV | crates.io | prettytable-rs | >= 0.0.0-0, < 0.10.0 | 0.10.0 |
References
- https://github.com/phsym/prettytable-rs/issues/145 · WEB, REPORT
- https://github.com/phsym/prettytable-rs · PACKAGE
- https://rustsec.org/advisories/RUSTSEC-2022-0074.html · WEB, ADVISORY
- https://crates.io/crates/prettytable-rs · PACKAGE
History
- 25 Nov 2026 20:14 UTC · OSV: first stored (published 2 Dec 2022)
- 25 Nov 2026 20:14 UTC · OSV: first stored (published 30 Dec 2022)