Denial of Service (DoS) Affecting org.codehaus.jettison:jettison package, versions [,1.5.4)


0.0
high

Snyk CVSS

    Attack Complexity Low
    Availability High

    Threat Intelligence

    Exploit Maturity Proof of concept
    EPSS 0.08% (32nd percentile)
Expand this section
NVD
7.5 high
Expand this section
Red Hat
7.5 high

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JAVA-ORGCODEHAUSJETTISON-3367610
  • published 22 Mar 2023
  • disclosed 22 Mar 2023
  • credit JFrog Research Team

How to fix?

Upgrade org.codehaus.jettison:jettison to version 1.5.4 or higher.

Overview

Affected versions of this package are vulnerable to Denial of Service (DoS) due to infinite recursion, when constructing a JSONArray from a Collection that contains a self-reference in one of its elements. Exploiting this vulnerability results in a StackOverflowError exception being thrown.

Mitigation

Wrap Jettison's JSONArray constructor with exception handling:

try {
    JSONArray jsonArray = new JSONArray(list);
}
catch(StackOverflowError e) {
    System.err.println("ERROR: Stack limit reached");
}

PoC

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