CVE-2021-43859: Xstream Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-rmr5-cpv2-vgjf
CVSS 7.5
CWE-502 CWE-400
Published
Advisory Summary

CVE-2021-43859 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Xstream libraries in the Maven ecosystem. The issue involves denial of service by injecting highly recursive collections or maps in xstream. Remediation is available by upgrading affected packages to version 1.4.19.

CVE-2021-43859 at a Glance

CVE Identifier CVE-2021-43859
GHSA Identifier GHSA-rmr5-cpv2-vgjf
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Xstream
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2021-43859

To remediate this vulnerability, upgrade all affected Xstream dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

com.thoughtworks.xstream:xstream fixed: 1.4.19
<dependency>
    <groupId>com.thoughtworks.xstream</groupId>
    <artifactId>xstream</artifactId>
    <version>1.4.19</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=com.thoughtworks.xstream

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2021-43859, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=com.thoughtworks.xstream

Analyze the terminal output to locate any version of Xstream in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.19), your application is affected.

Note: The mvn dependency:tree -Dincludes=com.thoughtworks.xstream command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Xstream, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact The vulnerability may allow a remote attacker to allocate 100% CPU time on the target system depending on CPU type or parallel execution of such a payload resulting in a denial of service only by manipulating the processed input stream. ### Patches XStream 1.4.19 monitors and accumulates the time it takes to add elements to collections and throws an exception if a set threshold is exceeded. ### Workarounds The attack uses the hash code implementation for collections and maps to force an exponential calculation time due to highly recursive structures with in the collection or map. Following types of the Java runtime are affected in Java versions available in December 2021: - java.util.HashMap - java.util.HashSet - java.util.Hashtable - java.util.LinkedHashMap - java.util.LinkedHashSet - java.util.Stack (older Java revisions only) - java.util.Vector (older Java revisions only) - Other third party collection implementations that use their element's hash code may also be affected If your object graph does not use referenced elements at all, you may simply set the NO_REFERENCE mode: ```Java XStream xstream = new XStream(); xstream.setMode(XStream.NO_REFERENCES); ``` If your object graph contains neither a Hashtable, HashMap nor a HashSet (or one of the linked variants of it) then you can use the security framework to deny the usage of these types: ```Java XStream xstream = new XStream(); xstream.denyTypes(new Class[]{ java.util.HashMap.class, java.util.HashSet.class, java.util.Hashtable.class, java.util.LinkedHashMap.class, java.util.LinkedHashSet.class }); ``` Unfortunately these types are very common. If you only use HashMap or HashSet and your XML refers these only as default map or set, you may additionally change the default implementation of java.util.Map and java.util.Set at unmarshalling time:: ```Java xstream.addDefaultImplementation(java.util.TreeMap.class, java.util.Map.class); xstream.addDefaultImplementation(java.util.TreeSet.class, java.util.Set.class); ``` However, this implies that your application does not care about the implementation of the map and all elements are comparable. ### References See full information about the nature of the vulnerability and the steps to reproduce it in XStream's documentation for [CVE-2021-43859](https://x-stream.github.io/CVE-2021-43859.html). ### Credits The vulnerability was discovered and reported by r00t4dm at Cloud-Penetrating Arrow Lab. ### For more information If you have any questions or comments about this advisory: * Open an issue in [XStream](https://github.com/x-stream/xstream/issues) * Contact us at [XStream Google Group](https://groups.google.com/group/xstream-user)

CVE-2021-43859 Affected Xstream Versions

1 component(s)
Fixed Versions:
1.4.19
Product / Package Ecosystem Affected Versions Fixed Version
com.thoughtworks.xstream:xstream
Maven
< 1.4.19
1.4.19

References

GitHub Advisory / Wiki ADVISORY
https://github.com/x-stream/xstream/security/advisories/GHSA-rmr5-cpv2-vgjf
NVD — CVE-2021-43859 NVD
https://nvd.nist.gov/vuln/detail/CVE-2021-43859
Security Fix Commit FIX COMMIT
https://github.com/x-stream/xstream/commit/e8e88621ba1c85ac3b8620337dd672e0c0c3a846
Xstream Source Repository REPOSITORY
https://github.com/x-stream/xstream
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2022/02/msg00018.html
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2024/12/msg00023.html
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/VACQYG356OHUTD5WQGAQ4L2TTFTAV3SJ
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/XODFRE2ZL64FICBJDOPWOLPTSSAI4U7X
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VACQYG356OHUTD5WQGAQ4L2TTFTAV3SJ
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XODFRE2ZL64FICBJDOPWOLPTSSAI4U7X
Xstream Security Information SECURITY
https://www.oracle.com/security-alerts/cpuapr2022.html
Xstream Security Information SECURITY
https://www.oracle.com/security-alerts/cpujul2022.html
x-stream.github.io/cve-2021-43859.html WEB
https://x-stream.github.io/CVE-2021-43859.html
Xstream Security Information SECURITY
http://www.openwall.com/lists/oss-security/2022/02/09/1

Frequently Asked Questions

What is CVE-2021-43859?
CVE-2021-43859 is a security vulnerability in Xstream involving Denial of Service by injecting highly recursive collections or maps in XStream under CWE-502: Deserialization of Untrusted Data.
Which Xstream versions are affected?
Affected versions include releases prior to 1.4.19 across affected packages: com.thoughtworks.xstream:xstream.
What version fixes CVE-2021-43859?
Upgrading to 1.4.19 (or the latest patched release for your respective branch) resolves the vulnerability.
Is xstream affected?
Yes, com.thoughtworks.xstream:xstream is affected in releases prior to 1.4.19. Upgrade your dependency to 1.4.19 or later.
What is the CVSS score of CVE-2021-43859?
CVE-2021-43859 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-43859?
CVE-2021-43859 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check Maven dependencies for CVE-2021-43859?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.thoughtworks.xstream'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rmr5-cpv2-vgjf",
  "modified" : "2025-11-04T16:34:34Z",
  "published" : "2022-02-01T00:48:15Z",
  "aliases" : [ "CVE-2021-43859" ],
  "summary" : "Denial of Service by injecting highly recursive collections or maps in XStream",
  "details" : "### Impact\nThe vulnerability may allow a remote attacker to allocate 100% CPU time on the target system depending on CPU type or parallel execution of such a payload resulting in a denial of service only by manipulating the processed input stream.\n\n### Patches\nXStream 1.4.19 monitors and accumulates the time it takes to add elements to collections and throws an exception if a set threshold is exceeded.\n\n### Workarounds\nThe attack uses the hash code implementation for collections and maps to force an exponential calculation time due to highly recursive structures with in the collection or map. Following types of the Java runtime are affected in Java versions available in December 2021:\n\n- java.util.HashMap\n- java.util.HashSet\n- java.util.Hashtable\n- java.util.LinkedHashMap\n- java.util.LinkedHashSet\n- java.util.Stack (older Java revisions only)\n- java.util.Vector (older Java revisions only)\n- Other third party collection implementations that use their element's hash code may also be affected\n\nIf your object graph does not use referenced elements at all, you may simply set the NO_REFERENCE mode:\n```Java\nXStream xstream = new XStream();\nxstream.setMode(XStream.NO_REFERENCES);\n```\n\nIf your object graph contains neither a Hashtable, HashMap nor a HashSet (or one of the linked variants of it) then you can use the security framework to deny the usage of these types:\n```Java\nXStream xstream = new XStream();\nxstream.denyTypes(new Class[]{\n java.util.HashMap.class, java.util.HashSet.class, java.util.Hashtable.class, java.util.LinkedHashMap.class, java.util.LinkedHashSet.class\n});\n```\n\nUnfortunately these types are very common. If you only use HashMap or HashSet and your XML refers these only as default map or set, you may additionally change the default implementation of java.util.Map and java.util.Set at unmarshalling time::\n```Java\nxstream.addDefaultImplementation(java.util.TreeMap.class, java.util.Map.class);\nxstream.addDefaultImplementation(java.util.TreeSet.class, java.util.Set.class);\n```\nHowever, this implies that your application does not care about the implementation of the map and all elements are comparable.\n\n### References\nSee full information about the nature of the vulnerability and the steps to reproduce it in XStream's documentation for [CVE-2021-43859](https://x-stream.github.io/CVE-2021-43859.html).\n\n### Credits\nThe vulnerability was discovered and reported by r00t4dm at Cloud-Penetrating Arrow Lab.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [XStream](https://github.com/x-stream/xstream/issues)\n* Contact us at [XStream Google Group](https://groups.google.com/group/xstream-user)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.thoughtworks.xstream:xstream"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.19"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/x-stream/xstream/security/advisories/GHSA-rmr5-cpv2-vgjf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43859"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/x-stream/xstream/commit/e8e88621ba1c85ac3b8620337dd672e0c0c3a846"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/x-stream/xstream"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2022/02/msg00018.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2024/12/msg00023.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/VACQYG356OHUTD5WQGAQ4L2TTFTAV3SJ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/XODFRE2ZL64FICBJDOPWOLPTSSAI4U7X"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VACQYG356OHUTD5WQGAQ4L2TTFTAV3SJ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XODFRE2ZL64FICBJDOPWOLPTSSAI4U7X"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujul2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://x-stream.github.io/CVE-2021-43859.html"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2022/02/09/1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400", "CWE-502" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-31T20:12:15Z",
    "nvd_published_at" : "2022-02-01T12:15:00Z"
  }
}