Advisory

GHSA-gfgm-chr3-x6px

Also known as: RUSTSEC-2022-0074

Summary

prettytable-rs: Force cast a &Vec<T> 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:

  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).

Severity

Medium Basis: The source's own band: MODERATE

Dates

Published
2022-12-30 17:48 UTC
Modified
2023-11-08 04:19 UTC

Affected packages and fixes

prettytable-rs

crates.io · All systems

Affected

  • introduced 0, fixed 0.10.0 (semver)

Fixed versions

0.10.0

Fix

  • Fixed version 0.10.0
    cargo update -p prettytable-rs --precise 0.10.0

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences