Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Allow file change before syscheck raise an alert #790

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

calve
Copy link
Contributor

@calve calve commented Apr 1, 2016

Hi,

When my hosts gets an upgrade, either distribution packages or
in-house applications, I get flooded with Integrity file changed
alerts for files and software I upgraded.

Actually, I do not want those alerts, whose lower the signal/noise
ratio. Morever, I tend to just not read these kind of alerts since I
feel most of them are false-positive.

At the moment, OSSEC miss a feature to allow a file to change prior to
the actual update.

I thought of the following requierements:

  • we must be able to tell OSSEC that a particular file could change
  • we must be able to allow changes for specific agents
  • we must be able to set an upper time-limit until the file is allowed to change
  • if the file changes after the time limit, we must get an alert
  • if the file changes twice during the time limit, we must get an alert ...
  • ... unless it have been allowed to change a second time, in which case we don't want an alert
  • the agent should be able to tell the monitor which files could change
  • we must get an alert if a changement have not been allowed
  • actually, we always want an alert whenever one file changes
  • we want different alerts levels depending on whether it have been allowed or not

Based on these requierements, I extended syscheckd to accept a
-u <timestamp>. Called with this switch, syscheckd won't start
in daemon, but will read paths from stdin. Those path will be sent to
the monitor, together with the timestamp.

On the monitor (whatever host is running analysisd actually), we
watch for those message and produce allowchanges token in an
agent-specific queue. This token contains

  1. a flag to know whether the token is still valid
  2. a timestamp until which it is not valid anymore
  3. the filepath allowed to change.

Now everytime analysisd is about to
generated an alert for an integrity change, it try to consume one
token for the file. If a token have been found, we set the decoder to
syscheck-allowchange, and users can write their rules according to their needs.
Otherwise, the old behaviour still apply.

As a security consideration, we could argue that this mechanism allow
an attacker to silentely changes binary on the agents if she allows
the changes before being evil. In fact, the monitor already trust
syscheckd for the file integrity, so an attacker with root access
could simply just turn it off.

What do you think about it ?

@@ -0,0 +1,110 @@
/* Copyright (C) 2009 Trend Micro Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an entirely new file, you should probably take ownership.

@calve calve changed the title Allowchange publishable Allow file change before syscheck raise an alert Apr 1, 2016
@calve calve changed the title Allow file change before syscheck raise an alert WIP: Allow file change before syscheck raise an alert Apr 2, 2016
@calve
Copy link
Contributor Author

calve commented Apr 2, 2016

Note; I don't expect this pull request to be merged as-is, I opened it for discussion.

@lostinthetubez
Copy link

Being able to account for file system changes caused by updates is something many system admins have asked about in the past. Would you mind sharing how you have been using this proposed feature? I'm not clear on how one would go about automating, say, an 'apt-get upgrade' or a 'yum update', but am very curious.

@calve
Copy link
Contributor Author

calve commented Apr 4, 2016

Would you mind sharing how you have been using this proposed feature?

I have to say that I do not use the proposed patch in production, nor have I fully tested it (as in a multiple remote agents setup).

For apt, I expect to be able to get the list of file changes before running the upgrade with a mix of apt-file to get the list of files changes, then hook some glue before running the actual update.

Probably something like apt-file $(apt-get list-upgrades) | ossec-syscheckd -u $(date +5min) && apt-get upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants