CVE-2021-29941
JSON

7.3high

Out of bounds write in reorder

Severity
7.3high CVSS:3.1 by NVD
Exploit likelihood
0.93% (higher than 61% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
mitre
Also known as
GHSA-3h87-v52r-p9rgGHSA-jpwg-6gf5-5vh9RUSTSEC-2021-0050

Description

An issue was discovered in the reorder crate through 2021-02-24 for Rust. swap_index has an out-of-bounds write if an iterator returns a len() that is too small.

Affected

Product or packageVersionsReported by
Unspecified productn/aCVE List
reorder (crates.io)before 1.1.0, from 0.0.0-0 before 1.1.0GitHub Advisory Database, RustSec Advisory Database
reorder_project reorderup to 2021-02-24NVD

All scores

GitHub7.3high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
RustSec Advisory Database7.3high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
NVD7.3high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
NVD7.5high CVSS:2.0AV:N/AC:L/Au:N/C:P/I:P/A:P

Classification

What each source says

CVE List

An issue was discovered in the reorder crate through 2021-02-24 for Rust. swap_index has an out-of-bounds write if an iterator returns a len() that is too small.

GitHub Advisory Database

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.

RustSec Advisory Database

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.

Patch

A new version crate was pushed that marks this function as unsafe.

reorder = "1.1.0"

Previous versions have also been yanked from crates.io.

NVD (es)

Se detectó un problema en la crate reorder hasta el 24 de febrero de 2021 para Rust. swap_index presenta una escritura fuera de límites si un iterador devuelve una función len() que es demasiado pequeña.

References

Related

Sources

SourceRecordLicence
CVE ListCVE-2021-29941 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-3h87-v52r-p9rg changed 2023-11-08CC-BY-4.0
GitHub Advisory DatabaseGHSA-jpwg-6gf5-5vh9 changed 2023-11-08CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2021-0050 changed 2023-11-08CC0-1.0
NVDCVE-2021-29941 changed 2026-06-17Public domain