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 package | Versions | Reported by |
|---|---|---|
| Unspecified product | n/a | CVE List |
| reorder (crates.io) | before 1.1.0, from 0.0.0-0 before 1.1.0 | GitHub Advisory Database, RustSec Advisory Database |
| reorder_project reorder | up to 2021-02-24 | NVD |
All scores
| GitHub | 7.3high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L |
| RustSec Advisory Database | 7.3high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L |
| NVD | 7.3high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L |
| NVD | 7.5high CVSS:2.0 | AV: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
| https://rustsec.org/advisories/RUSTSEC-2021-0050.html | advisory, exploit, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-29941 | advisory | |
| https://github.com/tiby312/reorder/issues/1 | report, web | |
| https://github.com/tiby312/reorder | package | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-29942 | advisory | |
| https://crates.io/crates/reorder | package | |
Related
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-29941 changed 2024-08-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-3h87-v52r-p9rg changed 2023-11-08 | CC-BY-4.0 |
| GitHub Advisory Database | GHSA-jpwg-6gf5-5vh9 changed 2023-11-08 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2021-0050 changed 2023-11-08 | CC0-1.0 |
| NVD | CVE-2021-29941 changed 2026-06-17 | Public domain |