-
Notifications
You must be signed in to change notification settings - Fork 20
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
Possible DoS when parsing a JSON number to BigInt or BigDecimal #88
Comments
Also, Moreover, for Scala versions before 2.12.7 the math context for some operations is ignored that can lead for the same problem: scala/bug#10882 |
So, are you suggesting we should implement our own parsing of
|
Yeh, I'm already thinking about it...
You are right that problems should be fixed in Java and Scala sources but I'm not sure that it can happen in the near future.
The provided math context isn't taken in account during parsing of the mantissa:
|
BTW, the latest version of |
Finally, I managed to get much more efficient implementation for parsing of strings to For small numbers it gives more than 2x speed up, while big numbers with 1M digits can be parsed in ~50x times faster than with standard constructors from JDK 8/11. But it still does not close possibility for DoS contemporary servers at 100Mbit/1Gbit rate of input. |
It happened that parsing of
BigInt
andBigDecimal
in latest versions of JVM hasO(n^2)
complexity wheren
is the number of significant digits. It means that a JSON body with a length ~1Mb can do 100% load one CPU core for several seconds:The text was updated successfully, but these errors were encountered: