Skip to content
Fencer Intel
medium —

GHSA-gfgm-chr3-x6px json

prettytable-rs: Force cast a &Vec<T> to &[T] may lead to undefined behavior

published 3y ago modified 3y ago also RUSTSEC-2022-0074

cvss
—
not scored
cisa kev
Not listed
not in CISA's catalog
epss
—
no score, EPSS covers CVEs only
public exploits
0
none known

Summary

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 undefined behavior (UB). 2. 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).

Patch / fix

  • crates.io prettytable-rs 0.10.0

Is GHSA-gfgm-chr3-x6px in your dependencies? Fencer shows which of your repositories are affected as soon as an advisory lands, and opens the fix as a pull request.

Check with Fencer

Affected packages

ecosystem package affected fixed in
crates.io prettytable-rs
<0.10.0
>=0.0.0-0, <0.10.0
0.10.0

References

Sources

Fencer Intel keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.