{"id":"CVE-2021-43620","aliases":["EUVD-2021-2353","GHSA-h352-g5vw-3926","RUSTSEC-2021-0123"],"status":"published","title":"Improper Input Validation in fruity","description":"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.","severity":{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high","assessor":"primary","from":"nvd"},"epss":{"day":"2026-11-11","score":0.01358,"percentile":0.72036,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-20"],"published":"2021-11-14T12:00:00Z","modified":"2026-10-20T10:55:02Z","fixes":[{"ecosystem":"crates.io","package":"fruity","fixed_in":["0.3.0"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"crates.io","package":"fruity","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0.1.0"},{"fixed":"0.3.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"fruity","ranges":[{"type":"SEMVER","events":[{"introduced":"0.1.0"},{"fixed":"0.3.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"fruity","ranges":[{"type":"SEMVER","events":[{"introduced":"0.1.0"},{"fixed":"0.3.0"}]}]}],"products":[{"vendor":"fruity_project","product":"fruity"}],"references":[{"url":"https://github.com/nvzqz/fruity/issues/14","tags":["x_refsource_MISC","x_transferred","Exploit","Issue Tracking","Patch","Third Party Advisory","fix","web","report"]},{"url":"https://github.com/rustsec/advisory-db/pull/1102","tags":["x_refsource_MISC","x_transferred","Exploit","Patch","Third Party Advisory","fix","web"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0123.html","tags":["x_refsource_MISC","x_transferred","Exploit","Third Party Advisory","evidence","web","advisory"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-43620","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-h352-g5vw-3926"},{"url":"https://github.com/nvzqz/fruity","tags":["package"]},{"url":"https://crates.io/crates/fruity","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2021-43620","description":"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.","status":"published","published":"2021-11-15T04:16:20Z","modified":"2024-08-04T04:03:08.34Z","updated_at":"2026-11-02T14:32:56.689433Z"}],"euvd":[{"id":"EUVD-2021-2353","description":"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.","status":"published","published":"2021-11-15T04:16:20Z","modified":"2024-08-04T04:03:08Z","updated_at":"2026-11-03T03:24:13.772922Z"}],"ghsa":[{"id":"GHSA-h352-g5vw-3926","title":"Improper Input Validation in fruity","description":"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.","status":"published","published":"2021-11-16T17:26:47Z","modified":"2023-06-13T17:27:03Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"}],"cwes":["CWE-20"],"updated_at":"2026-11-02T14:36:53.654352Z"}],"nvd":[{"id":"CVE-2021-43620","description":"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.","status":"published","published":"2021-11-15T05:15:07.913Z","modified":"2026-06-17T04:11:12.523Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high","assessor":"primary"},{"version":"2.0","score":5,"vector":"AV:N/AC:L/Au:N/C:N/I:P/A:N","level":"medium","assessor":"primary"}],"updated_at":"2026-11-02T14:07:00.984108Z"}],"osv":[{"id":"CVE-2021-43620","description":"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.","status":"published","published":"2021-11-15T05:15:07.913Z","modified":"2026-10-20T10:55:02.91108977Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"}],"updated_at":"2026-11-02T15:44:21.877444Z"},{"id":"GHSA-h352-g5vw-3926","title":"Improper Input Validation in fruity","description":"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.","status":"published","published":"2021-11-16T17:26:47Z","modified":"2023-11-08T04:07:11.140379Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"}],"cwes":["CWE-20"],"updated_at":"2026-11-02T15:46:48.546324Z"},{"id":"RUSTSEC-2021-0123","title":"Converting `NSString` to a String Truncates at Null Bytes","description":"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","status":"published","published":"2021-11-14T12:00:00Z","modified":"2023-11-08T04:07:11.140379Z","updated_at":"2026-11-02T15:53:39.492624Z"}]}}
