Advisory Database
  • Advisories
  • Dependency Scanning
  1. cargo
  2. ›
  3. reorder
  4. ›
  5. CVE-2021-29941

CVE-2021-29941: Out of bounds write in reorder

August 25, 2021 (updated June 13, 2023)

swap_index takes an iterator and swaps the items with their corresponding indexes. It reserves capacity and sets the length of the vector based on the .len() method of the iterator.

If the len() returned by the iterator is larger than the actual number of elements yielded, then swap_index creates a vector containing uninitialized members. If the len() returned by the iterator is smaller than the actual number of members yielded, then swap_index can write out of bounds past its allocated vector.

As noted by the Rust documentation, len() and size_hint() are primarily meant for optimization and incorrect values from their implementations should not lead to memory safety violations.

References

  • github.com/advisories/GHSA-3h87-v52r-p9rg
  • github.com/tiby312/reorder
  • github.com/tiby312/reorder/issues/1
  • nvd.nist.gov/vuln/detail/CVE-2021-29941
  • rustsec.org/advisories/RUSTSEC-2021-0050.html

Code Behaviors & Features

Detect and mitigate CVE-2021-29941 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 1.1.0

Fixed versions

  • 1.1.0

Solution

Upgrade to version 1.1.0 or above.

Impact 7.3 HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L

Learn more about CVSS

Weakness

  • CWE-787: Out-of-bounds Write

Source file

cargo/reorder/CVE-2021-29941.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:29 +0000.