GHSA-GFGM-CHR3-X6PX

Vulnerability from github – Published: 2022-12-30 17:48 – Updated: 2022-12-30 17:48
VLAI?
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).

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "crates.io",
        "name": "prettytable-rs"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.10.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [],
  "database_specific": {
    "cwe_ids": [],
    "github_reviewed": true,
    "github_reviewed_at": "2022-12-30T17:48:30Z",
    "nvd_published_at": null,
    "severity": "MODERATE"
  },
  "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, `\u0026Vec\u003cT\u003e` and `\u0026[T]` still might not have the same layout. Treating them equally may lead to undefinted behavior (UB).\n",
  "id": "GHSA-gfgm-chr3-x6px",
  "modified": "2022-12-30T17:48:30Z",
  "published": "2022-12-30T17:48:30Z",
  "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"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [],
  "summary": "prettytable-rs: Force cast a \u0026Vec\u003cT\u003e to \u0026[T] may lead to undefined behavior"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…