OSSEC HIDS

Configure OSSEC to not email alerts on IPTables denied messages

The tl;dr of this article is: It shows how to configure OSSEC, a host-based intrusion detection system, to not send email alerts whenever IPTables rejects or denies a traffic source.

The more detailed form follows.

So I use OSSEC to monitor and protect my cloud servers, which gives me a lot of confidence because OSSEC keeps me informed about what’s hitting my servers and what’s happening inside them.

In my setup, keeps me informed means that OSSEC sends me email alerts whenever something it’s been configured to monitor is triggered. And because I have active response enabled, with IPTables as the firewall application, OSSEC, by default, sends out alerts whenever IPTables denies a traffic source.

The content of such alerts, which are OSSEC level 2 alerts, take this form:

That, in a nut shell, is OSSEC informing me that the firewall denied a (potentially) bad guy. The problem: There can be at least a hundred of such alerts daily. And that’s from one server. From more than one server, it can get overwhelming. If I were using a web interface to manage the alerts, there’d be nothing to worry about, but I’m not.

Related Post:  Creativity: The key to the Virtual Reality gambling experience of the future

Ideally in OSSEC, a rule like 1002, which has a level set to 2, will not result in an email alert being sent. That’s because of this default settings in ossec.conf, OSSEC’s configuration file.

email_alert_level is the “inimum alert level to send e-mail notifications”. However, rule 1002 has an email alert override in its definition, which goes like this:

So because of the alert_by_email option, OSSEC will alert when rule 1002 is triggered, even though its level is lower than the default email alert level. In its rule definition, $BAD_WORDS is a variable which contains this listing:

The presence of denied in that variable is the reason OSSEC sends an alert when IPTables denies a traffic source with bad intentions. There are more than one solution to prevent OSSEC from alerting on IPTables denied messages but the best (I think) is to create a rule based on 1002 that does not send email alerts on such messages.

Related Post:  How Artificial Intelligence is influencing the gaming world

And here’s how it’s done: Define a custom rule that overrides part of rule 1002 that’s of interest.

In OSSEC, custom rules are defined in local_rules.xml (in /var/ossec/rules directory). So the plan is to create a variable in that file that contains the word(s) that I want to pass to my custom rule. Here’s the variable definition.

Yep, just one word. And the custom rule it’s used in is:

After the variable and the custom rule are in place, a restart of OSSEC is, of course, required. Once that final step of the process is completed, no more level 2 alerts related to IPTables denied messages.

Please share:
Tags: No tags

One Response

Add a Comment

Your email address will not be published. Required fields are marked *