Advisory

RUSTSEC-2021-0050

Also known as: CVE-2021-29941, CVE-2021-29942, GHSA-3h87-v52r-p9rg, GHSA-jpwg-6gf5-5vh9

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.

Severity

High Basis: CVSS v3 score 7.3, vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L

Dates

Published
2021-02-24 12:00 UTC
Modified
2023-11-08 04:05 UTC

Affected packages and fixes

reorder

crates.io · All systems

Affected

  • introduced 0.0.0-0, fixed 1.1.0 (semver)

Fixed versions

1.1.0

Fix

  • Fixed version 1.1.0
    cargo update -p reorder --precise 1.1.0

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: RustSec Advisory Database · CC0-1.0

Sources & licences