2WoO Day 7: Supporting New Applications the Right Way
There are already several good posts out there about decoders and rules, and how one uses both to add new application support in OSSEC. What I haven’t seen is the non-technical process behind adding new apps and making sure it is successful. In this final post for the Second Annual Week of OSSEC, I’d like to share my thought process on the correct way to add new applications.
The first thing to consider is whether or not this will provide enough security value to you for the effort. If these logs ordinarily don’t contain useful information such as authentication attempts, it may not be worth the effort.
Assuming it is worth it, the next thing you want to look for is an authoritative source for all possible logs that the app may generate. This usually means going to the vendor’s web site or asking them directly. Be prepared, however, for the equivalent of blank stares and in some cases, subtle hostility, as they think you must be a competitor trying to pry out some secret sauce.
If you’re lucky enough to find a good source for log entries, you’ll need to spend some time studying them to find the gems and to look for format anomalies. Is the username always in the same place? Are the delimiters consistent? Could a delimiter end up in the user name? More often than not, they won’t be well-formatted and there may even be variations between different versions of the software. As a Mark Minasi book I once read said, “be prepared to learn that documentation lies.”
When writing your decoders and rules, be as specific as possible. Imagine that someone will try to tamper with the logs and break your rules. Make liberal use of the ^ and $ characters, denoting the start and end of strings. Be specific and avoid the use of regexes such as \. (which means anything) whenever possible.
When writing rules, try to pre-tune them in such a way as to alert the user only when it is important. Generally, this means you only want to alerts on things like policy changes, new privileged users, possible attacks, rare events, and so-on. Consider that two or more seemingly innocuous events combined together could be an attack, so think laterally and creatively. Try to use groups and the info tag in every rule.
Test, test, test. When you think it is perfect, test some more. Try to run them in a live environment for awhile to see how things go. I am certainly guilty of writing some bad decoders and rules, and have learned a lot from the experience. Sometimes the testing might even reveal a bug in OSSEC, or they might work when you test them, but stop working or work differently with another snapshot. So follow up with the anomalies.
Finally, if you think others might benefit, submit them to the project. You might even want to send them to the mailing list first for some peer review. If they’re useful, they may just get included in the next release, which means you will have the satisfaction of knowing you have helped many other people stay safe.