Date: Fri, 12 Jun 2015 00:47:46 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-ports-bugs@FreeBSD.org Subject: [Bug 200801] security/ossec-hids-server: root escalation via syscheck feature Message-ID: <bug-200801-13@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200801 Bug ID: 200801 Summary: security/ossec-hids-server: root escalation via syscheck feature Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: Individual Port(s) Assignee: brd@FreeBSD.org Reporter: jason.unovitch@gmail.com Assignee: brd@FreeBSD.org Flags: maintainer-feedback?(brd@FreeBSD.org) Source: https://github.com/ossec/ossec-hids/releases/tag/2.8.2 Affected versions: 2.7 - 2.8.1 Beginning is OSSEC 2.7 (d88cf1c) 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: A vulnerable version is in use. The OSSEC agent is configured to use syscheck to monitor the file system for changes. The list of directories monitored by syscheck includes those writable by underprivileged users. 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. -- You are receiving this mail because: You are the assignee for the bug.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-200801-13>