亿邮电子邮件系统远程命令执行漏洞分析与复现
字数 784 2025-08-10 08:29:01
亿邮电子邮件系统远程命令执行漏洞分析与复现
漏洞概述
亿邮电子邮件系统存在一个远程命令执行漏洞,攻击者可以通过构造特定的HTTP请求,利用系统监控功能中的命令注入漏洞,在服务器上执行任意命令。
漏洞分析
漏洞定位
-
通过全局搜索
moni_detail找到关键文件:em_controller_action_app_mailadmin_moni_detail.class.php -
在该文件中发现关键函数
_get_graph(),该函数用于生成监控图像
关键代码分析
protected function _get_graph() {
$cluster = $this->__request->get_request('cluster', '');
$hostname = $this->__request->get_request('hostname', 'elephant110');
$type = $this->__request->get_request('type', 'cpu_report');
$date_type = $this->__request->get_request('date_type', 'hour');
$date_value = $this->__request->get_request('date_value', '1');
$columns = $this->__request->get_request('columns', 2);
$size = $this->__request->get_request('size', 'small');
require_once PATH_EYOUM_LIB . 'em_monitor.class.php';
$graph = new em_monitor;
$condition = em_condition::factory('monitor', 'report:get_report');
$condition->set_clustername($cluster);
$condition->set_hostname($hostname);
switch ($type) {
case 'cpu_report':
case 'mem_report':
case 'network_report':
case 'packet_report':
case 'load_report':
$condition->set_graph($type);
break;
default:
$condition->set_graph('metric');
$condition->set_metricname($type);
break;
}
$size_array = $this->_get_recover_size($type);
$graph->set_graph_size($size_array);
$condition->set_size($size);
$start = em_monitor::get_start_timestamp($date_value . ' ' . $date_type);
$condition->set_start($start);
$condition->set_end('now');
$graph->set_graph($condition);
$graph->set_debug(true);
$graph->draw();
}
漏洞触发点
draw()函数是关键漏洞点:
public function draw() {
$command = implode(' ', $this->__graph);
/*Make sure the image is not cached*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
if ($this->__debug) {
$fp = fopen('/tmp/monitor.log', 'w');
fwrite($fp, $command . "\n");
fclose($fp);
}
header("Content-type: image/gif");
passthru($command);
}
- 漏洞成因:
- 系统使用
passthru()函数直接执行命令 - 命令内容由用户可控参数构造
- 缺乏对用户输入的严格过滤和验证
- 系统使用
漏洞复现
复现步骤
-
构造恶意HTTP请求,利用
passthru()函数执行任意命令 -
示例攻击向量:
http://target/mail/em_monitor?type=;id; -
通过控制
type等参数,可以注入任意命令
利用方式
- 命令注入:通过参数注入系统命令
- 信息泄露:执行
id、whoami等命令获取系统信息 - 远程控制:建立反向shell连接
漏洞修复建议
-
输入验证:
- 对所有用户输入进行严格过滤
- 使用白名单机制限制参数值
-
安全函数使用:
- 避免直接使用
passthru()等危险函数 - 使用
escapeshellarg()或escapeshellcmd()对命令参数进行转义
- 避免直接使用
-
权限控制:
- 限制Web服务器用户权限
- 使用最小权限原则
-
代码审计:
- 检查所有使用系统命令执行的代码
- 确保没有其他类似的漏洞存在
技术要点总结
- 漏洞类型:远程命令执行(RCE)
- 危险函数:
passthru() - 影响范围:使用受影响版本的亿邮电子邮件系统
- 利用条件:无需认证即可利用(取决于具体配置)
- 危害等级:高危