CVE-2024-39697 (Rust, published 2024-07-09T15:15Z)
Description: value: phonenumber is a library for parsing, formatting and validating international phone numbers. Since 0.3.4, the phonenumber parsing code may panic due to a panic-guarded out-of-bounds access on the phonenumber string. In a typical deployment of rust-phonenumber, this may get triggered by feeding a maliciously crafted phonenumber, e.g. over the network, specifically strings of the form `+dwPAA;phone-context=AA`, where the "number" part potentially parses as a number larger than 2^56. This vulnerability is fixed in 0.3.6.
Severity: nan (CVSS v3 base score: )
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/whisperfish/rust-phonenumber
Files changed:
src/national_number.rs
src/parser/mod.rs
Commit message: Fit NationalNumber in 64 bits


Vulnerable code:
    pub(crate) zeros: u8,
}

impl NationalNumber {
    /// The number without any leading zeroes.
    pub fn value(&self) -> u64 {
        self.value
    }

    /// The number of leading zeroes.
        self.zeros
        for _ in 0..self.zeros {
        write!(f, "{}", self.value)
        national: NationalNumber {
            value: number.national.parse()?,
            zeros: number.national.chars().take_while(|&c| c == '0').count() as u8,
        },
            national: NationalNumber {
                value: 33316005,
                zeros: 0,
            },
            national: NationalNumber {
                value: 64123456,
                zeros: 0,
            },
                national: NationalNumber {
                    value: 30123456,
                    zeros: 0,
                },
                national: NationalNumber {
                    value: 2345,
                    zeros: 0,
                },
                national: NationalNumber {
                    value: 12,
                    zeros: 0,
                },
                national: NationalNumber {
                    value: 3121286979,
                    zeros: 0,
                },

Fixed code:
}

impl NationalNumber {
    pub fn new(value: u64, zeros: u8) -> Self {
        // E.164 specifies a maximum of 15 decimals, which corresponds to slightly over 48.9 bits.
        // 56 bits ought to cut it here.
        assert!(value < (1 << 56), "number too long");
        Self {
            value: ((zeros as u64) << 56) | value,
        }
    }
    /// The number without any leading zeroes.
    pub fn value(&self) -> u64 {
        self.value & 0x00ffffffffffffff
    }

    /// The number of leading zeroes.
    ///
        (self.value >> 56) as u8
        for _ in 0..self.zeros() {
        write!(f, "{}", self.value())
        national: NationalNumber::new(
            number.national.parse()?,
            number.national.chars().take_while(|&c| c == '0').count() as u8,
        ),
            national: NationalNumber::new(33316005, 0),
            national: NationalNumber::new(64123456, 0),
                national: NationalNumber::new(30123456, 0),
                national: NationalNumber::new(2345, 0,),
                national: NationalNumber::new(12, 0,),
                national: NationalNumber::new(3121286979, 0),