7.5high
Improper Input Validation in fruity
- Severity
- 7.5high CVSS:3.1 by NVD
- Exploit likelihood
- 1.36% (higher than 72% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- mitre
- Also known as
- GHSA-h352-g5vw-3926RUSTSEC-2021-0123
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Unspecified product | n/a | CVE List |
| fruity (crates.io) | from 0.1.0 before 0.3.0 | GitHub Advisory Database, RustSec Advisory Database |
| fruity_project fruity | 0.1.0, 0.2.0 | NVD |
All scores
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
| NVD | 5.0medium CVSS:2.0 | AV:N/AC:L/Au:N/C:N/I:P/A:N |
Classification
What each source says
CVE List
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.
GitHub Advisory Database
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.
In 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.
Since 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.
It would be better to generate unique names for files, instead of using user-provided names, but not all applications take this approach.
RustSec Advisory Database
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.
In 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.
Impact
Since 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.
It would be better to generate unique names for files, instead of using user-provided names, but not all applications take this approach.
Example:
let string = NSString::from_str("null\0byte");
println!("{}", string);
That example only prints the string "null".
NVD (es)
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
References
| https://github.com/nvzqz/fruity/issues/14 | exploit, issue-tracking, patch, report, third-party-advisory, web | |
| https://github.com/rustsec/advisory-db/pull/1102 | exploit, patch, third-party-advisory, web | |
| https://rustsec.org/advisories/RUSTSEC-2021-0123.html | advisory, exploit, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-43620 | advisory | |
| https://github.com/nvzqz/fruity | package | |
| https://crates.io/crates/fruity | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-43620 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-h352-g5vw-3926 changed 2023-11-08 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2021-0123 changed 2023-11-08 | CC0-1.0 |
| NVD | CVE-2021-43620 changed 2026-06-17 | Public domain |