Cybersecurity Log Collection with Graylog and Wazuh: Building a Robust & Open-Source Architecture

Cas pratique Protection & Défense

15 octobre 2023

NXLog Graylog OpenSearch Wazuh

Introduction

In this age of constant cyber threats, the meticulous management of system and application logs has emerged as an imperative.

Not only do these logs allow us to identify and respond to current security incidents, but they also provide a vital window into the past, enabling forensic investigations that can span back several months.

This paper presents an architecture for collecting and retaining logs, outlines the challenges in log processing, and provides comprehensive open-source solutions, such as Graylog and Wazuh (both running on the OpenSearch database engine), to address these issues. The bibliographic references are provided at the end.

Keywords: Logs, Monitoring, Active Response, Graylog, NXLog, Wazuh, OpenSearch

The significance of logs

Logs serve as the silent sentinels that monitor the activities of systems, applications, and users by carrying out the following functions:

To sum up, logs are the lifeblood of cybersecurity, providing essential visibility, accountability, and historical context, ensuring that organizations can safeguard their digital assets and respond effectively to security challenges.

Challenges in log management

The collection and retention of logs pose several significant issues:

Implementing an architecture with Graylog and Wazuh

In this section, we delve into the practical implementation of a log collection and retention architecture using Graylog and Wazuh.

We won’t provide here a detailed guide on how to install Graylog and Wazuh on the OpenSearch engine (which natively allows resiliency and scalability). Instead, we focus on the key steps and best practices for integrating these platforms to optimize log management.

Why combine Graylog and Wazuh?

Combining Graylog and Wazuh offers a synergistic solution for enhanced log management and cybersecurity. Graylog excels in log collection, analysis, and visualization, providing a user-friendly interface for monitoring digital activities. Wazuh, on the other hand, specializes in advanced threat detection and response.

By integrating these two platforms, you create a robust architecture that not only centralizes log data but also leverages Wazuh’s real-time threat detection capabilities. This combination offers a comprehensive solution for identifying and mitigating security incidents, making it an ideal choice for organizations looking to bolster their cyber defenses.

Real-world implementation

We have implemented Graylog and Wazuh within a lab composed of several physical servers (Linux and Windows), application servers (web, mail, Docker…), workstations (Linux and Windows) and two firewalls: an IPFire instance serving as the external firewall and a pfSense instance serving as the internal firewall. This configuration allows us to demonstrate how to manage a heterogeneous IT infrastructure.

Architectural principles

As shown in the figure below, we have opted to centralize Graylog within our collection system. This configuration allows Graylog to efficiently manage the collection of logs from various endpoints and to send alerts to Wazuh. While this is not the only possible setup, it lets us leverage Graylog’s full capabilities for log management while enabling Wazuh to focus on SIEM functions, specifically alert processing and active responses.

Architecture of the lab: log collection with Graylog and alerting towards Wazuh

Graylog configuration

Graylog natively provides many capabilities for processing logs from devices using Syslog, and it can also ingest logs from specific devices such as Palo Alto firewalls. For Windows endpoints, an additional agent is needed — NXLog for instance (see below).

Graylog dashboards bring efficient monitoring of all incoming logs, and the inputs and streams features allow you to define specific ports, protocols, and indices (equivalent to database tables in OpenSearch terminology) for the ingestion of logs from each device or group of devices. For each index, log rotation can be specified (on a time period or on a file size criterion).

Graylog inputs

Graylog streams and indices

When it comes to Windows endpoints, NXLog agents offer a convenient solution to ensure compatibility with Event Monitoring, with a quick installation and a very simple configuration file. Example of an NXLog configuration file for a Windows endpoint:

<Extension gelf>
    Module      xm_gelf
</Extension>

<Input internal>
    Module      im_internal
</Input>

<Input eventlog>
    Module      im_msvistalog
</Input>

<Output graylog_udp>
    Module      om_udp
    Host        graylog.dudes.lan
    Port        12200
    OutputType  GELF
</Output>

<Route 1>
    Path        eventlog, internal => graylog_udp
</Route>

Triggering Wazuh

In order to relieve the Wazuh server, not all logs ingested by Graylog are forwarded to it: an alert mechanism, activated on a specific stream, notifies Wazuh only in the case of suspicious events (e.g. authentication errors).

Here is an example of event definition and Wazuh notification, through a dedicated API configured on the Wazuh server:

Graylog event definition

Graylog notification towards the Wazuh API

Wazuh configuration

The Graylog notification can be processed by Wazuh through an alerting rule (with alert level 11 in the example below) and associated with an active response, which necessarily takes place on a device with a Wazuh agent installed.

Wazuh alerting rule

Wazuh active response

Hence, Wazuh processes filtered alerts coming from Graylog for every endpoint from which logs are collected (including workstations or less sensitive applications, for instance), while directly operating major endpoints (firewalls, domain controllers…) through the Wazuh agent, which allows active responses. Below, the Wazuh dashboard with seven endpoints running the Wazuh or OSSEC agent.

Wazuh dashboard with seven agents

Security and privacy considerations

Ensuring the security and privacy of logs is a fundamental aspect of your log management architecture.

Implementing strict access control measures is essential to protect log data from unauthorized access. Define who can access the log data, make modifications, or delete logs. Use role-based access control (RBAC) to assign specific permissions to users or groups, ensuring that only authorized personnel can interact with log data.

Encrypting log data both in transit and at rest enhances its security. Use secure communication protocols for log transmission and implement encryption for log storage to protect against data interception and tampering. Where log data contains sensitive or personally identifiable information (PII), consider techniques like data anonymization and redaction: this protects privacy while still retaining valuable log data.

Finally, when sending alerts and log data from Graylog to Wazuh, prioritize secure transmission channels, so that data is encrypted and protected in transit to maintain its confidentiality and integrity.

Conclusion

The integration of Graylog and Wazuh offers a powerful solution for log management and cybersecurity. By centralizing log collection, optimizing security, and streamlining threat detection, this architecture empowers organizations to navigate the complex landscape of modern cyber threats. With scalability, data retention, and a strong focus on log security, this approach ensures the long-term health and integrity of digital infrastructures.

References

  1. ANSSI — Recommandations de sécurité pour l’architecture d’un système de journalisation
  2. ANSSI — Sécuriser la journalisation dans un environnement Microsoft Active Directory
  3. NXLog — Centralized log collection with NXLog and Graylog
  4. Wazuh — Documentation of the Wazuh security platform