{"id":"CVE-2021-29941","aliases":["CVE-2021-29941","GHSA-3h87-v52r-p9rg","GHSA-jpwg-6gf5-5vh9","RUSTSEC-2021-0050"],"related":["CVE-2021-29942"],"kind":"vulnerability","state":"published","title":"Out of bounds write in reorder","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"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.\n\nIf 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.\n\nAs 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.","format":"markdown","source":"ghsa"},{"lang":"en","text":"`swap_index` takes an iterator and swaps the items with their corresponding\nindexes. It reserves capacity and sets the length of the vector based on the\n`.len()` method of the iterator.\n\nIf the `len()` returned by the iterator is larger than the actual number of\nelements yielded, then `swap_index` creates a vector containing uninitialized\nmembers. If the `len()` returned by the iterator is smaller than the actual\nnumber of members yielded, then `swap_index` can write out of bounds past\nits allocated vector.\n\nAs noted by the Rust documentation, [`len()`](https://doc.rust-lang.org/std/iter/trait.ExactSizeIterator.html#method.len)\nand `size_hint()` are primarily meant for optimization and incorrect values\nfrom their implementations should not lead to memory safety violations.\n\n\n# Patch\n\nA new version crate was pushed that marks this function as unsafe.\n\nreorder = \"1.1.0\"\n\nPrevious versions have also been yanked from crates.io.","format":"markdown","source":"rustsec"},{"lang":"es","text":"Se detectó un problema en la crate reorder hasta el 24 de febrero de 2021 para Rust.&#xa0;swap_index presenta una escritura fuera de límites si un iterador devuelve una función len() que es demasiado pequeña.","source":"nvd"}],"published":"2021-02-24T12:00:00.000Z","modified":"2026-06-17T03:48:28.890Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},"severities":[{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","score":7.5,"rating":"HIGH"}],"cwes":["CWE-787"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.1.0"}],"ecosystem":"crates.io","package":"reorder","purl":"pkg:cargo/reorder","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.1.0"}],"ecosystem":"crates.io","package":"reorder","purl":"pkg:cargo/reorder","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"1.1.0"}],"ecosystem":"crates.io","package":"reorder","purl":"pkg:cargo/reorder","source":"rustsec"},{"ranges":[{"status":"affected","lastAffected":"2021-02-24"}],"vendor":"reorder_project","product":"reorder","cpe":"cpe:2.3:a:reorder_project:reorder:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0050.html","tags":["advisory","exploit","vendor-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29941","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/tiby312/reorder/issues/1","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/tiby312/reorder","tags":["package"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29942","tags":["advisory"],"sources":["ghsa"]},{"url":"https://crates.io/crates/reorder","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"mitre","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-29941","url":"https://www.cve.org/CVERecord?id=CVE-2021-29941","licence":"CVE Terms of Use","modified":"2024-08-03T22:18:03.411Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3h87-v52r-p9rg","url":"https://github.com/advisories/GHSA-3h87-v52r-p9rg","licence":"CC-BY-4.0","modified":"2023-11-08T04:05:44.188Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jpwg-6gf5-5vh9","url":"https://github.com/advisories/GHSA-jpwg-6gf5-5vh9","licence":"CC-BY-4.0","modified":"2023-11-08T04:05:44.188Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2021-0050","url":"https://rustsec.org/advisories/RUSTSEC-2021-0050.html","licence":"CC0-1.0","modified":"2023-11-08T04:05:44.188Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-29941","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29941","licence":"Public domain","modified":"2026-06-17T03:48:28.890Z"}],"updatedAt":"2026-11-25T22:58:00.541Z","epss":{"score":0.00932,"percentile":0.61723,"date":"2026-12-01T12:00:22.000Z"}}