{"id":"CVE-2021-43620","aliases":["CVE-2021-43620","GHSA-h352-g5vw-3926","RUSTSEC-2021-0123"],"related":[],"kind":"vulnerability","state":"published","title":"Improper Input Validation in fruity","summary":"An issue was discovered in the fruity crate through 0.2.0 for Rust. Security-relevant validation of filename extensions is plausibly affected. Methods of NSString for conversion to a string may return a partial result. Because they call CStr::from_ptr on a pointer to the string buffer, the string is terminated at the first '\\0' byte, which might not be the end of the string.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"An issue was discovered in the fruity crate through 0.2.0 for Rust. Security-relevant validation of filename extensions is plausibly affected. Methods of NSString for conversion to a string may return a partial result. Because they call CStr::from_ptr on a pointer to the string buffer, the string is terminated at the first '\\0' byte, which might not be the end of the string.","source":"cvelist"},{"lang":"en","text":"Methods of NSString for conversion to a string may return a partial result. Since they call CStr::from_ptr on a pointer to the string buffer, the string is terminated at the first null byte, which might not be the end of the string.\n\nIn addition to the vulnerable functions listed for this issue, the implementations of Display, PartialEq, PartialOrd, and ToString for NSString are also affected, since they call those functions.\n\nSince NSString is commonly used as the type for paths by the Foundation framework, null byte truncation might allow for easily bypassing file extension checks. For example, if a file name is provided by a user and validated to have one of a specific set of extensions, with validation taking place before truncation, an attacker can add an accepted extension after a null byte (e.g., file.exe\\0.txt). After truncation, the file name used by the application would be file.exe.\n\nIt would be better to generate unique names for files, instead of using user-provided names, but not all applications take this approach.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Methods of [`NSString`] for conversion to a string may return a partial result.\nSince they call [`CStr::from_ptr`] on a pointer to the string buffer, the\nstring is terminated at the first null byte, which might not be the end of the\nstring.\n\nIn addition to the vulnerable functions listed for this issue, the\nimplementations of [`Display`], [`PartialEq`], [`PartialOrd`], and [`ToString`]\nfor [`NSString`] are also affected, since they call those functions.\n\n## Impact\n\nSince [`NSString`] is commonly used as the type for paths by the [Foundation]\nframework, null byte truncation might allow for easily bypassing file extension\nchecks. For example, if a file name is provided by a user and validated to have\none of a specific set of extensions, with validation taking place before\ntruncation, an attacker can add an accepted extension after a null byte (e.g.,\n`file.exe\\0.txt`). After truncation, the file name used by the application\nwould be `file.exe`.\n\nIt would be better to generate unique names for files, instead of using\nuser-provided names, but not all applications take this approach.\n\n## Example:\n\n```rust\nlet string = NSString::from_str(\"null\\0byte\");\nprintln!(\"{}\", string);\n```\n\nThat example only prints the string \"null\".\n\n[`CStr::from_ptr`]: https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_ptr\n[`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html\n[Foundation]: https://developer.apple.com/documentation/foundation\n[`NSString`]: https://docs.rs/fruity/0.2.0/fruity/foundation/struct.NSString.html\n[`PartialEq`]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html\n[`PartialOrd`]: https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html\n[`ToString`]: https://doc.rust-lang.org/std/string/trait.ToString.html","format":"markdown","source":"rustsec"},{"lang":"es","text":"Se ha detectado un problema en el crate fruity versiones hasta 0.2.0, para Rust. Una comprobación relevante para la seguridad de las extensiones de los nombres de archivos está plausiblemente afectada. Los métodos de NSString para la conversión a una cadena pueden devolver un resultado parcial. Debido a que llaman a CStr::from_ptr en un puntero al buffer de la cadena, la cadena se termina en el primer byte \"\\0\", que podría no ser el final de la cadena","source":"nvd"}],"published":"2021-11-14T12:00:00.000Z","modified":"2026-06-17T04:11:12.523Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:P/A:N","score":5,"rating":"MEDIUM"}],"cwes":["CWE-20"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.1.0","status":"affected","fixed":"0.3.0"}],"ecosystem":"crates.io","package":"fruity","purl":"pkg:cargo/fruity","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.1.0","status":"affected","fixed":"0.3.0"}],"ecosystem":"crates.io","package":"fruity","purl":"pkg:cargo/fruity","source":"rustsec"},{"ranges":[{"status":"affected","version":"0.1.0"},{"status":"affected","version":"0.2.0"}],"vendor":"fruity_project","product":"fruity","cpe":"cpe:2.3:a:fruity_project:fruity:0.1.0:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://github.com/nvzqz/fruity/issues/14","tags":["exploit","issue-tracking","patch","report","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://github.com/rustsec/advisory-db/pull/1102","tags":["exploit","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0123.html","tags":["advisory","exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-43620","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/nvzqz/fruity","tags":["package"],"sources":["ghsa"]},{"url":"https://crates.io/crates/fruity","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"mitre","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-43620","url":"https://www.cve.org/CVERecord?id=CVE-2021-43620","licence":"CVE Terms of Use","modified":"2024-08-04T04:03:08.340Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-h352-g5vw-3926","url":"https://github.com/advisories/GHSA-h352-g5vw-3926","licence":"CC-BY-4.0","modified":"2023-11-08T04:07:11.140Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2021-0123","url":"https://rustsec.org/advisories/RUSTSEC-2021-0123.html","licence":"CC0-1.0","modified":"2023-11-08T04:07:11.140Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-43620","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-43620","licence":"Public domain","modified":"2026-06-17T04:11:12.523Z"}],"updatedAt":"2026-11-25T22:24:36.010Z","epss":{"score":0.01358,"percentile":0.7247,"date":"2026-12-01T12:00:22.000Z"}}