Rust advisories / prettytable-rs
Unsound MediumRUSTSEC-2022-0074 · prettytable-rs
RUSTSEC-2022-0074: Force cast a &Vec<T> to &[T]
Short answerprettytable-rs has an API that can cause undefined behaviour from safe code: Force cast a &Vec<T> to &[T]. Fixed in 0.10.0.
| Crate | prettytable-rs |
|---|---|
| Type | Unsound |
| Affected versions | Before 0.10.0. |
| Fixed in | 0.10.0 |
| Severity | Medium (GitHub rating) |
| Published | 2022-12-02 |
| Last changed | 2023-11-08 |
| Also known as | GHSA-gfgm-chr3-x6px |
What to do
- See which version you have:
cargo tree -i prettytable-rs(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p prettytable-rs. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for exampleprettytable-rs = "0.10.0") or update the dependency that pulls it in. - Check again with
cargo audit, or paste your Cargo.lock into our Cargo.toml checker.
Details from the advisory
In function Table::as_ref, a reference of vector is force cast to slice. There are multiple problems here: 1. 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. 2. Even if (1) is sound, &Vec<T> and &[T] still might not have the same layout. Treating them equally may lead to UB.
References
- Package: crates.io/crates/prettytable-rs
- Advisory: rustsec.org/advisories/RUSTSEC-2022-0074.html
- Report: github.com/phsym/prettytable-rs/issues/145
From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.
Up next
Are you affected?Check your whole dependency treePaste Cargo.lock: every advisory, for your exact versions.Read it next →Also worth your time
Did this answer your question?