目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1359 元

100%

CVE-2021-21341 PoC — XStream 代码问题漏洞

来源
关联漏洞
标题: XStream 代码问题漏洞 (CVE-2021-21341)
Description:XStream是Xstream团队的一个轻量级的、简单易用的开源Java类库,它主要用于将对象序列化成XML(JSON)或反序列化为对象。 XStream 1.4.16 之前版本存在代码问题漏洞,该漏洞允许远程攻击者根据CPU类型或此类有效负载的并行执行,导致拒绝服务。
Description
XStream DoS CVE-2021-21341
介绍
# 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);
```
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →