Skip to content
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

A OOM security issue was found in JSON-java #834

Open
Alex111998 opened this issue Nov 27, 2023 · 2 comments
Open

A OOM security issue was found in JSON-java #834

Alex111998 opened this issue Nov 27, 2023 · 2 comments

Comments

@Alex111998
Copy link

When I test the latest version(20231013) of JSON-java by CIFuzz,a OOM security issue was found, it caused when put a big number in JSONArray, may cause denial of service issues in applications via the follow code:

new org.json.JSONArray().put(1829517625, 1.0719845412539998E291);

image

@johnjaylward
Copy link
Contributor

This is expected behavior. Don't do that.

@Madjosz
Copy link
Contributor

Madjosz commented Feb 6, 2024

JSON does not support the concept of "sparse arrays" as you would need an index => value mapping which effectively is a JSONObject then. You have to think about how your created object would be stringified: It would be
[,,,(1829517624 commas in total),,, 1.0719845412539998E291]
and you could already avoid parsing this. On the other hand your example can only be created directly from code so the 'security issue' can only be injected by the programmer deliberately and can be migitated by checks for the index to be in a sane range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants