6

FireEye 红队失窃工具大揭秘之:分析复现 Confluence路径穿越漏洞 (CVE-2019-3398)

 3 years ago
source link: https://www.freebuf.com/vuls/257716.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

前言

最近,全球领先的网络安全公司 FireEye 疑遭某 APT 组织的攻击,其大量政府客户的信息遭越权访问,且红队工具被盗。虽然目前尚不清楚这些红队工具将被如何处置,但FireEye 公司在 GitHub 上发布了一些应对措施。奇安信代码安全实验室将从技术角度,对 GitHub 仓库中的相关漏洞进行分析复现,希望能给读者带来一些启发,做好防御措施。

漏洞简介

Atlassian Confluence Server是澳大利亚Atlassian公司的一套协同软件服务器版本,具有企业知识管理功能,并支持用于构建企业WiKi。Atlassian Confluence Data Center 是 Atlassian Confluence 的数据中心版本。

Atlassian Confluence Server 和Confluence Data Center 在downloadallattachments 资源中存在路径穿越漏洞。当远程用户能够向博客页面添加附件,或创建空间,或对某个空间具有管理员权限,就可能使用包含目录遍历序列(‘../’)的文件名造成路径穿越问题,且在一定条件下可以执行任意代码。

受影响产品

Atlassian Confluence Server
confluence Data Center

受影响版本

2.0.0 
	

修复版本

6.6.13
6.12.4
6.13.4
6.14.3
6.15.2

漏洞验证环境

Centos7
Jdk-1.8.0_272
Mysql 5.7
Confluence 6.15.1

漏洞验证和分析

搭建好环境后,创建一篇博客,title 和 content 随意任选。

该漏洞关键点有两个:上传一个文件名带有 “../” 的附件和下载该附件所在博客页面的全部附件。上传触发点位于对现有博客进行编辑时的页面上:

eAb6vuQ.jpg!mobile

可添加附件,插入文件或图片。

QZZVzmf.jpg!mobile

上传附件时更改文件名。

VjyuIzB.jpg!mobile

Insert 之后进行 update 保存。该上传功能处理代码位于Confluence安装目录下confluence/WEB-INF/atlassian-bundled-plugins/confluence-drag-and-drop-6.15.1.jar/com.atlassian,confluence.plugins/dragdrop/UploadAcrion.class文件中。

ArMZvy6.jpg!mobile

由于该段代码中未对 filename 做安全检查,因而 “../” 字段可以成功插入filename中。

在该博客页面点击附件可以查看附件列表。 FvERJzF.jpg!mobile

全部下载功能需要该博客页面有至少两个附件,上传成功后博客附件文件名会带有“../”。

rYzMZb.jpg!mobile

点击 Downdload All,可以看到文件名为 download、随机字符和时间拼接成的zip文件,即 downloadG6tgT025851.zip,响应的 location 位置在download/tmp/ 下,直接在根目录下搜索该文件,可以找到存储地址。

J773U3F.jpg!mobile

该zip文件的上两级目录中存在 test.txt 文件。该 download all 的处理功能代码位于 confluence 安装目录下的 confluence/WEB-INF/lib/confluence-6.15.1.jar/com/atlassian/confluence/pages/DownloadLAllAttachmentsOnPageAction.class文件中。

I3E7zq2.jpg!mobile

整个复制过程并没有对文件名和文件内容做安全检查。

yIBFnq.jpg!mobile

EFNniy.jpg!mobile

getTempDirectoryForZipping() 和getZipFilename()两个函数会根据时间和随机数生成附件文件缓存的目录,目录会存放在 confluence.home/temp/下,confluence.home对应如下:

YBf22mf.jpg!mobile

可知前面下载全部附件时zip的文件名结构和存放位置。copy时,缓存流中的附件 ../../test.txt 就存放在/confluencehome/temp/downloadG6tgT025851/ 下。

将此目录打包后,由于目录遍历序列(‘../’)的作用,/confluencehome/test.txt文件也就保留了下来。因此也就造成了目录穿越漏洞。

F7v2InE.jpg!mobile

补丁

更新至最新版。

参考

https://www.securityfocus.com/bid/108067/info
https://packetstormsecurity.com/files/155235/Atlassian-Confluence-6.15.1-Directory-Traversal.html

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK