Skip to content

[Bug] SEGV in strtod.h FastPath due to Integer Overflow in Exponent Parsing (v1.0.0) #2406

Open

Description

@shuidaao

Vulnerability Details:

  • Product: RapidJSON
  • Version: v1.0.0
  • File: include/rapidjson/internal/strtod.h
  • Function: FastPath()
  • Line: 31
  • Type: Integer Overflow -> Out-of-bounds Read (CWE-190 + CWE-125)
  • Affected: v1.0.0

Root Cause:
During parsing of a floating-point number with an extremely large negative exponent (e.g., -3022222222223), the exponent integer overflows in ParseNumber(). The corrupted exponent is then passed to FastPath(), which calls Pow10(exp). Since the exponent exceeds the valid range, Pow10() accesses the kPow10 array out of bounds, causing a SEGV.

PoC (49 bytes):
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:

  • Crash point: strtod.h FastPath() vs reader.h ParseNumber()
  • Crash type: SEGV (OOB read) vs integer underflow
  • Affected: v1.0.0 only (fixed in v1.0.1+)
  • Trigger: extremely large negative exponent vs specific integer input

Impact:

  • Denial of Service (DoS)

Suggested Fix:
Add a range check on the exponent before calling Pow10().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions