Fix for CVE-2015-3222 which allows for root escalation via syscheck #622
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'spurpose 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
:Above, on line
258
, thesystem()
call is used to shell out to thesystem'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:
system for changes.
by underprivileged users.
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 thesystem's
diff
command.