# CVE-2022-41966: XStream Denial of Service via stack overflow

> Remote attackers can cause a stack overflow and crash the application by sending crafted XML input to the XStream library.

- **Severity:** High 8.2 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 27 Dec 2022
- **Updated:** 11 Apr 2025
- **Also known as:** DEBIAN-CVE-2022-41966, DLA-3267-1, DSA-5315-1, GHSA-j563-grx4-pjpv, ROOT-APP-MAVEN-CVE-2022-41966, UBUNTU-CVE-2022-41966

## What is CVE-2022-41966?

CVE-2022-41966 is a high-severity denial of service vulnerability in x-stream xstream, published on 27 Dec 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

XStream serializes Java objects to XML and back again. Versions prior to 1.4.20 may allow a remote attacker to terminate the application with a stack overflow error, resulting in a denial of service only via manipulation the processed input stream. The attack uses the hash code implementation for collections and maps to force recursive hash calculation causing a stack overflow. This issue is patched in version 1.4.20 which handles the stack overflow and raises an InputManipulationException instead. A potential workaround for users who only use HashMap or HashSet and whose XML refers these only as default map or set, is to change the default implementation of java.util.Map and java.util per the code example in the referenced advisory. However, this implies that your application does not care about the implementation of the map and all elements are comparable.

Weakness: CWE-674 (Uncontrolled Recursion), CWE-502 (Deserialization of Untrusted Data), CWE-121 (Stack-based Buffer Overflow), CWE-120 (Buffer Copy without Checking Size of Input)

## Which versions are affected by CVE-2022-41966?

2 open source packages ship an affected version, including com.thoughtworks.xstream:xstream. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `com.thoughtworks.xstream:xstream` | Maven | All versions | 1.4.20 |
| `com.thoughtworks.xstream:xstream` | Maven | All versions | 1.4.20 |

Products: Xstream Xstream.

## How do I fix CVE-2022-41966?

Upgrade com.thoughtworks.xstream:xstream to 1.4.20 or later.

## Is CVE-2022-41966 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-41966 exists.

Public exploit code:

- https://github.com/111ddea/Xstream_cve-2022-41966 (github_poc): https://github.com/111ddea/Xstream_cve-2022-41966

## Other vulnerabilities in x-stream xstream

- [CVE-2022-40151](https://insights.sbomify.com/CVE-2022-40151/): Stack Buffer Overflow in xstream (medium 6.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-41966 and fix it if it is affected.

What it is: CVE-2022-41966 is a high-severity denial of service vulnerability in x-stream xstream, published on 27 Dec 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-41966 exists.

Affected packages and fixed versions:
- com.thoughtworks.xstream:xstream (Maven): affected all versions; fixed in 1.4.20
- com.thoughtworks.xstream:xstream (Maven): affected all versions; fixed in 1.4.20

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-41966/ (Markdown: https://insights.sbomify.com/CVE-2022-41966/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-41966
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-41966
- OSV: https://osv.dev/vulnerability/CVE-2022-41966

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-41966/
Summaries are generated and may contain mistakes; the official description above is the record.
