Skip to content

2.4.9 breaks JSON parser #132

Closed
Closed
@ColdFireIce

Description

@ColdFireIce

The depth CVE fix broke the whole JSON parser...

in the protected <T> T readObject(JsonReaderI<T> mapper) you count up every time. But you only count down at case '}':
but there is another

read(); /* unstack */
return mapper.convert(current);

later, without counting down. This makes it, so you can only read 400 objects. Not a depth of 400.

This of course breaks parsing every JSON with more than 400 objects..

Easy test to prove Problem:

JsonPath jsonPath = JsonPath.compile("$");
jsonPath.read("["+ "{\"foo\":\"bar\"},".repeat(400) + "{\"foo\":\"bar\"}]");

Throws:

net.minidev.json.parser.ParseException: Malicious payload, having non natural depths, parsing stoped on { at position 5587.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions