Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1110 CNY

100%

CVE-2021-21341 PoC — XStream can cause a Denial of Service

Source
Associated Vulnerability
Title:XStream can cause a Denial of Service (CVE-2021-21341)
Description:XStream is a Java library to serialize objects to XML and back again. In XStream before version 1.4.16, there is vulnerability which 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. No user is affected who followed the recommendation to setup XStream's security framework with a whitelist limited to the minimal required types. If you rely on XStream's default blacklist of the Security Framework, you will have to use at least version 1.4.16.
Description
XStream DoS CVE-2021-21341
Readme
# CVE-2021-21341 XStream DoS

## XStream Official Announcement

[CVE-2021-21341](https://x-stream.github.io/CVE-2021-21341.html)

**Vulnerability**

CVE-2021-21341: XStream can cause a Denial of Service.

**Affected Versions**

All versions until and including version 1.4.15 are affected, if using the version out of the box. No user is affected, who followed the recommendation to setup XStream's security framework with a whitelist limited to the minimal required types.

**Description**

The processed stream at unmarshalling time contains type information to recreate the formerly written objects. XStream creates therefore new instances based on these type information. An attacker can manipulate the processed input stream and replace or inject a manipulated ByteArrayInputStream (or derived class), that can cause an endless loop resulting in a denial of service.

## Docker Demo

![cve-2021-21341](https://user-images.githubusercontent.com/56715563/116986789-31fe6a80-ad09-11eb-8d97-d15702601606.gif)

## Set Up XStream Environment & PoC Execution

1. Build an image from a Dockerfile (Set Up)

```
$ docker build -t cve-2021-21341 .
```

2. Run java -jar xstream in a new container (PoC Execution)

```
$ docker run -it --rm cve-2021-21341
```

## Output

```
Security framework of XStream not explicitly initialized, using predefined black list on your own risk.

(never end)
```

## Solution

- Update xstream version to 1.4.16 or higher

Change pom.xml to bellow

```
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.16</version>
        </dependency>
```

- Use XStream's security framework

Add NoTypePermission.NONE

```
import com.thoughtworks.xstream.security.NoTypePermission; // Add

XStream xstream = new XStream();
xstream.addPermission(NoTypePermission.NONE); // Add
xstream.fromXML(xml);
```
File Snapshot

[4.0K] /data/pocs/078242de11c4edec0a51bba7f481d92f6d5b46c1 ├── [ 131] Dockerfile ├── [1.6K] pom.xml ├── [1.9K] README.md └── [4.0K] src └── [4.0K] main └── [4.0K] java └── [1.9K] main.java 3 directories, 4 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →