-
-
Notifications
You must be signed in to change notification settings - Fork 76
Closed
Labels
Description
The parser fails to throw the ParseException when the parser expects the input to be of the float number type AND the input not being a valid number. This can lead to uncaught exceptions by unexpected input, which may lead to Denial-of-Service (DoS).
json-smart-v2/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java
Lines 139 to 147 in 4402bae
protected Number extractFloat() throws ParseException { | |
if (!acceptLeadinZero) | |
checkLeadinZero(); | |
if (!useHiPrecisionFloat) | |
return Float.parseFloat(xs); | |
if (xs.length() > 18) // follow JSonIJ parsing method | |
return new BigDecimal(xs); | |
return Double.parseDouble(xs); | |
} |
Parser Input of "-." or "2e+" or "[45e-" will crash with a NumberFormatException.
== Java Exception: java.lang.NumberFormatException: For input string: "-."
at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.base/java.lang.Double.parseDouble(Double.java:549)
at net.minidev.json.parser.JSONParserBase.extractFloat(JSONParserBase.java:141)
sguillope, HoustonPagtakhan1 and mmm83