# GHSA-5x36-7567-3cw6: partial_sort contains Out-of-bounds Read in release mode

- Severity: Medium (rating, scored by GitHub)
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2023-02-20T12:00:00.000Z
- Modified: 2023-11-08T04:15:57.343Z
- Also known as: RUSTSEC-2023-0016
- Weaknesses: CWE-125

## Description

Affected versions of this crate were using a debug assertion to validate the `last` parameter of `partial_sort()`. This would allow invalid inputs to cause an out-of-bounds read instead of immediately panicking, when compiled without debug assertions.

All writes are bounds-checked, so the out-of-bounds memory access is read-only. This also means that the first attempted out-of-bounds write will panic, limiting the possible reads.

The accessible region is further limited by an initial bounds-checked read at `(last / 2) - 1`, i.e., it is proportional to the size of the vector.

This bug has been fixed in v0.2.0.

(As written by GitHub Advisory Database.)

## Affected

- partial_sort (crates.io): before 0.2.0; from 0.0.0-0 before 0.2.0

## References

- <https://github.com/sundy-li/partial_sort/issues/7> (report, web)
- <https://github.com/sundy-li/partial_sort> (package)
- <https://rustsec.org/advisories/RUSTSEC-2023-0016.html> (advisory, web)
- <https://crates.io/crates/partial_sort> (package)

## Sources

- GitHub Advisory Database: [GHSA-5x36-7567-3cw6](https://github.com/advisories/GHSA-5x36-7567-3cw6), CC-BY-4.0, modified 2023-11-08
- RustSec Advisory Database: [RUSTSEC-2023-0016](https://rustsec.org/advisories/RUSTSEC-2023-0016.html), CC0-1.0, modified 2023-11-08

---

Page: https://cve.day/GHSA-5x36-7567-3cw6 · Whole record: https://cve.day/GHSA-5x36-7567-3cw6.json · Rebuilt by cve.day 2026-11-25T22:56:43.141Z
