OSSEC HIDS

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:


OSSEC HIDS Notification.
2015 Feb 26 20:33:35

Received From: container->/var/log/syslog
Rule: 1002 fired (level 2) -> "Unknown problem somewhere in the system."
Portion of the log(s):

Feb 26 20:33:34 container kernel: [455208.047536] iptables denied: IN=eth0 OUT= MAC=04:01:3f:81:38:01:.....:08:30:08:00 SRC=111.111.111.111 DST=222.222.222.222 LEN=40 TOS=0x00 PREC=0x00 TTL=247 ID=54321 PROTO=TCP SPT=51660 DPT=11211 WINDOW=65535 RES=0x00 SYN URGP=0

 --END OF NOTIFICATION

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:  How to upgrade the Linux Mint 17.1 kernel from version 3.13 to 3.16

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.



    1
    7


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:


    $BAD_WORDS
    alert_by_email
    Unknown problem somewhere in the system.

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:



core_dumped|failure|error|attack|bad |illegal |denied|refused|unauthorized|fatal|failed|Segmentation Fault|Corrupted

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.

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.


denied

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


        1002
        $IGNORED_WORD
        Ignored IPTables deny messages.

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.

Share:

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn

Hola! Did you notice that LinuxBSDos.com no longer runs network ads?  Yep, no more ads from the usual suspects that track you across the Internet.  But since  I still need to pay to keep the site running, feel free to make a small donation by PayPal.

Subscribe for updates. Trust me, no spam!

Mailchimp Signup Form

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event for 2020.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.

2 Responses

  1. Not sure if there are a lot of VPNs that have a kill switch, but mine does as well (I’m a Surfshark user btw). I always have it on since I torrent a lot, and just in case my VPN connection drops, there wouldn’t be any leaks. Every time I check the IP leak for this VPN, there aren’t any, so I guess it’s a good indicator, but it’s always better to be cautious.

Leave a Reply

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

Get the latest

On social media
Via my newsletter
Mailchimp Signup Form

Partner links

1. Attend Algorithm Conference, a top AI and ML event for 2021.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.
Hacking, pentesting distributions

Linux Distributions for Hacking

Experts use these Linux distributions for hacking, digital forensics, and pentesting.

Categories
Archives

The authors of these books are confirmed to speak during

Algorithm Conference

T-minus AI

Author was the first chairperson of AI for the U.S. Air Force.

The case for killer robots

Author is the Director of the Center for Natural and Artificial Intelligence.

Why greatness cannot be planned

Author works on AI safety as a Senior Research Scientist at Uber AI Labs.

Anastasia Marchenkova

An invitation from Anastasia Marchenkova

Hya, after stints as a quantum researcher at Georgia Tech Quantum Optics & Quantum Telecom Lab, and the University of Maryland Joint Quantum Institute, I’m now working on superconducting qubit quantum processors at Bleximo. I’ll be speaking during Algorithm Conference in Austin, Texas, July 16 – 18, 2020. Meet me there and let’s chat about progress and hype in quantum computing.