Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Exception in Parser #7

Closed
GanbaruTobi opened this issue Feb 22, 2021 · 2 comments
Closed

Uncaught Exception in Parser #7

GanbaruTobi opened this issue Feb 22, 2021 · 2 comments

Comments

@GanbaruTobi
Copy link

GanbaruTobi commented Feb 22, 2021

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).

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)
	at net.minidev.json.parser.JSONParserMemory.readNumber(JSONParserMemory.java:81)
	at net.minidev.json.parser.JSONParserBase.readMain(JSONParserBase.java:379)
	at net.minidev.json.parser.JSONParserBase.parse(JSONParserBase.java:156)
	at net.minidev.json.parser.JSONParserString.parse(JSONParserString.java:56)
	at net.minidev.json.parser.JSONParserString.parse(JSONParserString.java:37)
	at net.minidev.json.parser.JSONParser.parse(JSONParser.java:140)
@pronovic
Copy link

Note that this is tied to CVE-2021-27568, categorized as base score 9.1 (critical).

@UrielCh
Copy link
Contributor

UrielCh commented Apr 4, 2021

New version released 1.3.2 with CVE-2021-27568 fixed
json-smart-mini had also been patched and released.

@UrielCh UrielCh closed this as completed Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants