Skip to content

2.4.9 breaks JSON parser #132

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

Closed
ColdFireIce opened this issue Mar 16, 2023 · 3 comments
Closed

2.4.9 breaks JSON parser #132

ColdFireIce opened this issue Mar 16, 2023 · 3 comments

Comments

@ColdFireIce
Copy link

ColdFireIce commented Mar 16, 2023

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.
@hezhangjian
Copy link
Collaborator

thanks for your report. I'll dive it this weekend

@ewoelfel
Copy link
Contributor

i added #133 to fix this issue

@hezhangjian
Copy link
Collaborator

I think #133 can close this issue. Feel free to reopen it.

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