Auditing with osquery: Part Two — Configuration and Implementation

Palantir
11 min readintermediate
--
View Original

Overview

This article delves into the configuration and implementation of auditing with osquery, focusing on command-line flags, logging strategies, and performance considerations. It provides practical insights for engineers looking to effectively utilize osquery for system auditing while minimizing performance impacts.

What You'll Learn

1

How to configure osquery for effective auditing

2

Why selective logging can reduce performance impact in osquery

3

How to troubleshoot common osquery auditing issues

Prerequisites & Requirements

  • Basic understanding of Linux auditing concepts
  • Familiarity with command-line interface and osquery

Key Questions Answered

What command-line flags are essential for osquery auditing?
Key command-line flags for osquery auditing include --audit_allow_sockets, --audit_allow_process_events, and --logger_plugin=filesystem. These flags enable specific auditing features such as recording network connections and process executions, which are crucial for effective auditing.
How can I reduce the log volume generated by osquery?
To reduce log volume, select specific columns to log instead of using wildcards in queries. For instance, limiting the data collected from process_events and socket_events can decrease the overall logging footprint by up to 25%, making auditing more efficient.
What are common troubleshooting steps for osquery auditing?
Common troubleshooting steps include ensuring osquery is run as root, verifying the presence of necessary flags in osquery.flags, and checking that the configuration files are correctly set up in /etc/osquery. These steps help identify misconfigurations that may prevent event logging.
What performance implications should I be aware of when using osquery?
Using osquery for auditing introduces performance overhead due to additional kernel operations for syscall comparisons and the processing of audit events by osquery. Understanding these implications is crucial for maintaining system performance while implementing auditing.

Key Statistics & Figures

Maximum buffered events
500,000
This is the maximum number of events osquery can buffer between SELECT statements, which helps manage log volume.
Performance overhead increase
6 seconds
The osquery stress test showed that enabling auditing increased the time taken to complete operations by approximately 6 seconds.

Technologies & Tools

Backend
Osquery
Used for auditing system events and managing logs.
Backend
Auditd
Used for recording audit events in the Linux kernel.

Key Actionable Insights

1
Be selective about the data you log with osquery to minimize performance impact. Instead of logging all columns from tables like process_events, choose only the necessary ones.
This approach not only reduces the volume of logs generated but also helps in maintaining system performance, especially in environments with numerous hosts.
2
Regularly monitor the processes that generate the most logs and adjust your auditing strategy accordingly.
By identifying and filtering out noisy processes, you can significantly reduce the logging volume and improve the efficiency of your auditing setup.
3
Implement custom audit rules to exclude processes that are not relevant for security monitoring.
This can help in reducing CPU cycles consumed by osquery, allowing for a more efficient auditing process without losing critical visibility on important events.

Common Pitfalls

1
Failing to run osquery as root can prevent it from recording necessary events.
This is a common oversight that can lead to incomplete auditing and missed security events, making it crucial to ensure proper permissions are set.
2
Using wildcard queries can lead to excessive log volume and performance degradation.
While it may seem convenient, this practice can overwhelm your logging system and make it difficult to analyze relevant data effectively.

Related Concepts

Linux Audit Framework
Performance Monitoring
Custom Audit Rules