CVE-2021-43620
JSON

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 packageVersionsReported by
Unspecified productn/aCVE List
fruity (crates.io)from 0.1.0 before 0.3.0GitHub Advisory Database, RustSec Advisory Database
fruity_project fruity0.1.0, 0.2.0NVD

All scores

GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
NVD5.0medium CVSS:2.0AV: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/14exploit, issue-tracking, patch, report, third-party-advisory, web
https://github.com/rustsec/advisory-db/pull/1102exploit, patch, third-party-advisory, web
https://rustsec.org/advisories/RUSTSEC-2021-0123.htmladvisory, exploit, third-party-advisory, web
https://nvd.nist.gov/vuln/detail/CVE-2021-43620advisory
https://github.com/nvzqz/fruitypackage
https://crates.io/crates/fruitypackage

Sources

SourceRecordLicence
CVE ListCVE-2021-43620 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-h352-g5vw-3926 changed 2023-11-08CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2021-0123 changed 2023-11-08CC0-1.0
NVDCVE-2021-43620 changed 2026-06-17Public domain