Repository navigation
Description
Summary
A SEGV (out-of-bounds read) vulnerability exists in RapidJSON v1.0.0 when parsing floating-point numbers with extremely large negative exponents. The exponent integer overflows during parsing, causing an array index out of bounds in strtod.h.
Affected Versions
- RapidJSON v1.0.0 (latest tested)
- Likely earlier versions as well
Vulnerability Location
- File:
include/rapidjson/internal/strtod.h - Function:
FastPath() - Line: 31
Root Cause
During the parsing of a number like 1e-3022222222223, the exponent is accumulated into an int variable in ParseNumber(). Because -3022222222223 exceeds the range of int, it overflows. The corrupted exponent value is then passed to FastPath(), which calls internal::Pow10(exp).
In Pow10(), the exponent is used as an index to access the kPow10 array. If the overflowed exponent is out of the valid range (e.g., becomes a huge positive number), it causes an out-of-bounds array access, resulting in a SEGV.
PoC (49 bytes)
Input data: 12222222228222222221e-3022222222223
// Minimal reproduction
Document doc;
doc.Parse("12222222228222222221e-3022222222223");
ASan Report
ERROR: AddressSanitizer: SEGV on unknown address 0x63a13691e668
READ of size 1
#0 FastPath() at strtod.h:31
#1 StrtodNormalPrecision() at strtod.h:43
#2 ParseNumber<0u>() at reader.h:951
#3 Parse<0u>() at reader.h:408
GDB Backtrace
#0 FastPath() at strtod.h:31
#1 FastPath() at strtod.h:27
#2 StrtodNormalPrecision() at strtod.h:43
#3 ParseNumber<0u>() at reader.h:951
Independence Statement
This vulnerability is independent from CVE-2024-38517:
Different crash point: This crashes in strtod.h FastPath(), while CVE-2024-38517 crashes in reader.h ParseNumber().
Different trigger: This requires a specific extreme negative exponent (integer overflow), whereas CVE-2024-38517 is triggered by specific integer inputs.
Different affected versions: This affects v1.0.0 (and potentially others), while CVE-2024-38517 specifically targeted v1.0.0.
Different crash type: This results in a direct SEGV (array index out of bounds), not a heap-buffer-overflow.
Suggested Fix
Add a range check for the exponent before calling Pow10():
// In FastPath()
if (exp < -308 || exp > 308) {
return 0.0; // Or handle appropriately
}
CVE Request
I would like to request a CVE ID for this vulnerability.
Activity