{"id":"CVE-2021-28031","aliases":["CVE-2021-28031","GHSA-3qm2-rfqw-fmrw","RUSTSEC-2021-0030"],"related":[],"kind":"vulnerability","state":"published","title":"move_elements can double-free objects on panic","summary":"An issue was discovered in the scratchpad crate before 1.3.1 for Rust. The move_elements function can have a double-free upon a panic in a user-provided f function.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"An issue was discovered in the scratchpad crate before 1.3.1 for Rust. The move_elements function can have a double-free upon a panic in a user-provided f function.","source":"cvelist"},{"lang":"en","text":"Affected versions of scratchpad used ptr::read to read elements while calling a user provided function f on them. Since the pointer read duplicates ownership, a panic inside the user provided f function could cause a double free when unwinding.\n\nThe flaw was fixed in commit `891561bea` by removing the unsafe block and using a plain iterator.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Affected versions of `scratchpad` used `ptr::read` to read elements while\ncalling a user provided function `f` on them.\n\nSince the pointer read duplicates ownership, a panic inside the user provided\n`f` function could cause a double free when unwinding.\n\nThe flaw was fixed in commit `891561bea` by removing the unsafe block and using\na plain iterator.","format":"markdown","source":"rustsec"},{"lang":"es","text":"Se detectó un problema en la crate scratchpad versiones anteriores a 1.3.1 para Rust.&#xa0;La función move_elements puede tener una doble liberación tras un pánico en una función f proporcionada por el usuario","source":"nvd"}],"published":"2021-02-18T12:00:00.000Z","modified":"2026-06-17T03:45:44.930Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"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-415"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.3.1"}],"ecosystem":"crates.io","package":"scratchpad","purl":"pkg:cargo/scratchpad","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"1.3.1"}],"ecosystem":"crates.io","package":"scratchpad","purl":"pkg:cargo/scratchpad","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"1.3.1"}],"vendor":"scratchpad_project","product":"scratchpad","cpe":"cpe:2.3:a:scratchpad_project:scratchpad:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0030.html","tags":["advisory","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-28031","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/okready/scratchpad/issues/1","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/okready/scratchpad/commit/891561bea","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/okready/scratchpad","tags":["package"],"sources":["ghsa"]},{"url":"https://crates.io/crates/scratchpad","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"mitre","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-28031","url":"https://www.cve.org/CVERecord?id=CVE-2021-28031","licence":"CVE Terms of Use","modified":"2024-08-03T21:33:17.105Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3qm2-rfqw-fmrw","url":"https://github.com/advisories/GHSA-3qm2-rfqw-fmrw","licence":"CC-BY-4.0","modified":"2023-11-08T04:05:27.727Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2021-0030","url":"https://rustsec.org/advisories/RUSTSEC-2021-0030.html","licence":"CC0-1.0","modified":"2023-11-08T04:05:27.727Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-28031","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-28031","licence":"Public domain","modified":"2026-06-17T03:45:44.930Z"}],"updatedAt":"2026-11-25T22:58:00.154Z","epss":{"score":0.01381,"percentile":0.72333,"date":"2026-11-30T12:00:22.000Z"}}