Denial of service when parsing a big JSON number as Instant/ZonedDateTime/OffsetDateTime
See original GitHub issueIt looks the same as: https://github.com/playframework/play-json/issues/180
Reproduced by the following commit: https://github.com/plokhotnyuk/jsoniter-scala/pull/153/commits/0d53faf5093b492867b550f2cec55ff0b5cc62de
The security bug is in InstantDeserializer
and DurationDeserializer
of the jackson-datatype-jsr310
artifact:
protected T _fromDecimal(DeserializationContext context, BigDecimal value)
{
long seconds = value.longValue(); // <- hangs in case of 10000000e100000000
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
return fromNanoseconds.apply(new FromDecimalArguments(
seconds, nanoseconds, getZone(context)));
}
W/A is to use custom serializers for all types that are parsed with InstantDeserializer
and DurationDeserializer
by registering them after (or instead of) registration of the JavaTimeModule
module.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:15
- Comments:27 (6 by maintainers)
Top Results From Across the Web
5 JSON Denial Attack that Every Hacker Take Advantage Of
A Denial Of Service attack is an attack to disrupt the normal service of the targeted server. Just like how a huge amount...
Read more >Denial of Service (DoS) in json | CVE-2020-10663 | Snyk
When parsing certain JSON documents, the json gem (including the one bundled with Ruby) can be coerced into creating arbitrary objects in the ......
Read more >Parsing fails in a big JSON - javascript - Stack Overflow
I can open the JSON with a program called Huge JSON Viewew, which means that the file is well structured, but when it...
Read more >An Exploration of JSON Interoperability Vulnerabilities
Denial-of-Service : Segmentation Faults. Two parsing libraries crashed on malformed JSON. Both of these instances have been reported to the ...
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
The JavaScript exceptions thrown by JSON.parse() occur when string failed to be ... JSON.parse: unterminated string SyntaxError: JSON.parse: no number after ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@abracadv8 would
longValueExact
be enough? if we want long anyway then it might be good idea to throw exception if number is too large/low, and this will do everything for you. Also @plokhotnyuk note that similar operation is inside DecimalUtils: https://github.com/FasterXML/jackson-modules-java8/blob/b45e632dbf4911c49cf33d2e8da5eb31113d1d75/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/DecimalUtils.java#L101 And this will hang too.@cowtowncoder More over, it seems that during parsing of any JSON object it is possible to DoS the Jackson parser by just adding a field with the big number.
Here is a PR which initially reproduced it for Play-JSON parser:
https://github.com/plokhotnyuk/jsoniter-scala/pull/168/files
Below are results of parametrized benchmarks where the
size
parameter specifies a number of digits in the value of that additional field:Step to reproduce are same as before, except the names of branch and benchmark:
sbt
and/or ensure that it already installed properly:jsoniter-scala
repo:play-json-DoS-using-big-number
branch: