RUSTSEC-2021-0050

Source
https://rustsec.org/advisories/RUSTSEC-2021-0050
Import Source
https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2021-0050.json
JSON Data
https://api.osv.dev/v1/vulns/RUSTSEC-2021-0050
Aliases
Published
2021-02-24T12:00:00Z
Modified
2023-11-08T04:05:44.188314Z
Severity
  • 7.3 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L CVSS Calculator
Summary
swap_index can write out of bounds and return uninitialized memory
Details

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.

Database specific
{
    "license": "CC0-1.0"
}
References

Affected packages

crates.io / reorder

Package

Affected ranges

Type
SEMVER
Events
Introduced
0.0.0-0
Fixed
1.1.0

Ecosystem specific

{
    "affected_functions": null,
    "affects": {
        "os": [],
        "functions": [],
        "arch": []
    }
}

Database specific

{
    "cvss": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L",
    "informational": null,
    "categories": []
}