OSSEC 2.7 <= 2.8.1 Local Root Escalation

32   2019-08-05 08:08   nipc
漏洞信息
漏洞编号: 1317
CVE编号: CVE-2015-3222
漏洞类型: -
漏洞来源: cxs
发布日期: 2015-06-12
CVSS
CVSS值: -
严重级别: 低危
利用范围: -
攻击复杂度: -
认证级别: -
漏洞描述

WLB-2015060067[***]http://cxsecurity.com/issue/WLB-2015060067[***]OSSEC 2.7 <= 2.8.1 Local Root Escalation[***]2015.06.12[***] Andrew Widdersheim[***] Low[***]N/A [***]CVE-2015-3222[***]Yes[***]No[***][***][***][***][***][***][***][***][***]Fix for CVE-2015-3222 which allows for root escalation via syscheck - https://github.com/ossec/ossec-hids/releases/tag/2.8.2@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** Affected versions: 2.7 - 2.8.1@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** Beginning is OSSEC 2.7 (d88cf1c9) a feature was added to syscheck, which is the daemon that monitors file changes on a system, called "report_changes". This feature is only available on *NIX systems. It's purpose is to help determine what about a file has changed. The logic to do accomplish this is as follows which can be found in src/syscheck/seechanges.c:@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 252 /* Run diff */@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 253 date_of_change = File_DateofChange(old_location);@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 254 snprintf(diff_cmd, 2048, "diff \"%s\" \"%s\"> \"%s/local/%s/diff.%d\" "@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 255 "2>/dev/null",@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 256 tmp_location, old_location,@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 257 DIFF_DIR_PATH, filename + 1, (int)date_of_change);@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 258 if (system(diff_cmd) != 256) {@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 259 merror("%s: ERROR: Unable to run diff for %s",@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 260 ARGV0, filename);@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 261 return (NULL);@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 262 }@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** Above, on line 258, the system() call is used to shell out to the system's "diff" command. The raw filename is passed in as an argument which presents an attacker with the possibility to run arbitrary code. Since the syscheck daemon runs as the root user so it can inspect any file on the system for changes, any code run using this vulnerability will also be run as the root user.@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** An example attack might be creating a file called "foo-$(touch bar)" which should create another file "bar".@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** Again, this vulnerability exists only on *NIX systems and is contingent on the following criteria:@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 1. A vulnerable version is in use.@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 2. The OSSEC agent is configured to use syscheck to monitor the file system for changes.@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 3. The list of directories monitored by syscheck includes those writable by underprivileged users.@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** 4. The "report_changes" option is enabled for any of those directories.@@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** The fix for this is to create temporary trusted file names that symlink back to the original files before calling system() and running the system's "diff" command. @@@@@@@@@@$$$$$$$$$$&&&&&&&&&&##########suijishu0518893******** [***]https://github.com/ossec/ossec-hids/releases/tag/2.8.2

POC

Fix for CVE-2015-3222 which allows for root escalation via syscheck - https://github.com/ossec/ossec-hids/releases/tag/2.8.2 Affected versions: 2.7 - 2.8.1 Beginning is OSSEC 2.7 (d88cf1c9) a feature was added to syscheck, which is the daemon that monitors file changes on a system, called "report_changes". This feature is only available on *NIX systems. It's purpose is to help determine what about a file has changed. The logic to do accomplish this is as follows which can be found in src/syscheck/seechanges.c: 252 /* Run diff */ 253 date_of_change = File_DateofChange(old_location); 254 snprintf(diff_cmd, 2048, "diff \"%s\" \"%s\"> \"%s/local/%s/diff.%d\" " 255 "2>/dev/null", 256 tmp_location, old_location, 257 DIFF_DIR_PATH, filename + 1, (int)date_of_change); 258 if (system(diff_cmd) != 256) { 259 merror("%s: ERROR: Unable to run diff for %s", 260 ARGV0, filename); 261 return (NULL); 262 } Above, on line 258, the system() call is used to shell out to the system's "diff" command. The raw filename is passed in as an argument which presents an attacker with the possibility to run arbitrary code. Since the syscheck daemon runs as the root user so it can inspect any file on the system for changes, any code run using this vulnerability will also be run as the root user. An example attack might be creating a file called "foo-$(touch bar)" which should create another file "bar". Again, this vulnerability exists only on *NIX systems and is contingent on the following criteria: 1. A vulnerable version is in use. 2. The OSSEC agent is configured to use syscheck to monitor the file system for changes. 3. The list of directories monitored by syscheck includes those writable by underprivileged users. 4. The "report_changes" option is enabled for any of those directories. The fix for this is to create temporary trusted file names that symlink back to the original files before calling system() and running the system's "diff" command