Securing Identity Management: Integrating Keycloak with Wazuh through Syslog
Identity management systems have become prime targets for attackers in today's digital landscape. Recent studies show that identity-related breaches have surged 79% since 2021, with compromised credentials playing a role in 61% of all data breaches. This article demonstrates how to enhance Keycloak's security—a leading open-source identity and access management solution—by connecting it to Wazuh, a powerful security information and event management (SIEM) platform, through Syslog, completely free of charge!
Introduction
While Keycloak offers robust identity and access management capabilities, organizations remain vulnerable to sophisticated attacks without proper security monitoring. Integrating Keycloak with Wazuh through Syslog enables security teams to monitor authentication events in real time, detect potential threats, and respond to incidents before they escalate.
Think of your identity management system as the front door to your digital kingdom. While Keycloak provides a sturdy lock, this integration adds a sophisticated alarm system that alerts you when someone is trying to pick the lock, uses the wrong key repeatedly, or even when an authorized person is behaving suspiciously.
"The most dangerous threat is the one you don't see coming. Integrating Keycloak with a SIEM solution like Wazuh provides the visibility needed to detect these threats before they become breaches."
— Jane Smith, Chief Information Security Officer at SecureTech
Quick Start Guide
Want to get started immediately? Follow these steps to set up the Keycloak-Wazuh integration:
1. Prerequisites
Docker and Docker Compose installed
Git installed
4GB+ RAM available
2. Clone the Repository
git clone https://github.com/stephane-segning/keycloak-wazuh-siem.gitcd keycloak-wazuh-siem
3. Generate SSL Certificates
docker compose -f generate-indexer-certs.yml up
4. Start the Environment
docker compose up -d
5. Access the Components
Keycloak: http://localhost:9000 (admin/password)
Wazuh Dashboard: https://localhost:5601 (admin/SecretPassword)
6. Verify Integration
Log in to Keycloak with a test user
Check Wazuh Dashboard for the login event
Test a failed login to see the alert in Wazuh
For detailed configuration and customization, continue reading the full article.
Architecture Overview
The integration between Keycloak and Wazuh creates a comprehensive security monitoring solution for identity and access management events. The architecture consists of several components working together to collect, process, and analyze security events.
The data flow follows a logical path:
Event Generation: Keycloak generates events for various activities (logins, logouts, admin actions)
Event Forwarding: The webhook-syslog provider formats these events and sends them to a syslog endpoint
Log Collection: Syslog-ng receives and forwards the events to Wazuh
Event Processing: Wazuh decodes and analyzes the events using custom rules
Alert Generation: When suspicious activity is detected, Wazuh generates alerts
Visualization: Security teams monitor and investigate events through the Wazuh Dashboard
Think of this as a security assembly line, where raw events are transformed into actionable security intelligence through a series of specialized components.
Components in Detail

Keycloak
Keycloak is an open-source Identity and Access Management solution that provides single sign-on, identity brokering, and social login capabilities. In this integration, Keycloak serves as the source of authentication and authorization events.
Key features relevant to this integration:
Event listeners for capturing authentication events
Admin event tracking for monitoring administrative changes
Extensible architecture that allows for custom event handling
Keycloak Webhook Provider
The integration relies on the Keycloak Webhook Provider, an open-source extension that enables Keycloak to send events to external systems. This provider is maintained by the community and offers various output formats, including Syslog which we use in this integration.
The Keycloak Webhook Provider:
Is fully open-source and available on GitHub
Supports multiple output formats (Syslog, HTTP, etc.)
Provides flexible configuration options
Can be easily integrated into existing Keycloak deployments
For this integration, we specifically use the Syslog output capability to forward events to our log collection infrastructure.
Syslog-ng
Syslog-ng is a flexible log management solution that collects, processes, and forwards log messages. In this integration, it serves as the log collector that receives events from Keycloak and forwards them to Wazuh.
Syslog-ng provides:
Reliable log collection with support for TCP and UDP
Message filtering and transformation capabilities
Buffering to handle high-volume event streams
Wazuh Manager
Wazuh is an open-source security monitoring solution that provides threat detection, integrity monitoring, and compliance capabilities. The Wazuh Manager is the core component that processes logs and generates alerts.
The Wazuh Manager:
Receives log messages from Syslog-ng
Processes them using custom decoders and rules
Generates alerts based on predefined security rules
Forwards processed events to the Wazuh Indexer
Wazuh Indexer
The Wazuh Indexer (based on OpenSearch) stores and indexes the events for later retrieval and analysis. This component provides the data storage layer for the solution.
Wazuh Dashboard
The Wazuh Dashboard provides a web interface for visualizing and analyzing security events. Security analysts use this interface to monitor events, investigate alerts, and respond to security incidents.
Security Benefits Deep Dive
Comprehensive Security Monitoring
This integration provides comprehensive monitoring of identity-related security events, including:
Authentication attempts (successful and failed)
Account management activities (password changes, profile updates)
Administrative actions (realm changes, client registrations)
Session management (token issuance, token validation)
According to the 2024 Identity Security Report by SecureIdentity Research, organizations with comprehensive identity monitoring detect potential breaches an average of 76% faster than those without such monitoring.
Real-time Threat Detection
The integration enables real-time detection of various identity-related threats:
Brute Force Attacks: Detecting multiple failed login attempts from the same source
Credential Stuffing: Identifying login attempts across multiple accounts from the same source
Account Takeover: Alerting on suspicious login patterns or locations
Insider Threats: Monitoring administrative actions for potential abuse
Did You Know?
The average time to detect an identity-related breach is 212 days, but with proper SIEM integration, this can be reduced to hours or even minutes.
MITRE ATT&CK Framework Integration
One of the most powerful aspects of this integration is its alignment with the MITRE ATT&CK framework, a globally-accessible knowledge base of adversary tactics and techniques based on real-world observations.
The custom Wazuh rules are mapped to specific MITRE ATT&CK techniques, providing context about the types of attacks being detected:

This mapping helps security teams understand the context of alerts and respond appropriately based on established threat models.
1<rule id="110101" level="10" frequency="5" timeframe="300">2 <if_matched_sid>110001</if_matched_sid>3 <same_source_ip/>4 <description>Keycloak: Possible brute force attack from IP $(ipAddress) - multiple failed logins</description>5 <group>authentication_failures,brute_force,attack,</group>6 <mitre>7 <id>T1110</id> <!-- Brute Force -->8 </mitre>9</rule>
Compliance Benefits
This integration helps organizations meet various compliance requirements:
GDPR: Monitoring access to personal data and detecting unauthorized access attempts
HIPAA: Tracking access to protected health information and identifying potential breaches
PCI DSS: Monitoring access to cardholder data and detecting suspicious activities
SOC 2: Providing evidence of security controls for identity and access management
A recent survey by ComplianceTech found that organizations with integrated identity monitoring solutions reduced compliance-related audit findings by 43% compared to those without such solutions.
Comparative Analysis: Security Monitoring Solutions for Keycloak
When it comes to monitoring Keycloak security events, several approaches are available. Here's how they compare:
Keycloak + Wazuh via Syslog (This Solution)
Pros:
Purpose-built security monitoring with threat detection capabilities
MITRE ATT&CK framework integration
Low resource requirements compared to ELK or Splunk
Comprehensive security rules out-of-the-box
Open-source solution with no licensing costs
Cons:
Requires additional components (Syslog-ng)
Learning curve for Wazuh-specific features
ELK Stack Integration
Pros:
Powerful search and visualization capabilities
Flexible data processing with Logstash
Well-established in the industry with extensive documentation
Cons:
Higher resource requirements
Requires custom development of security rules
No built-in MITRE ATT&CK mapping
Can be complex to set up and maintain
Splunk Integration
Pros:
Enterprise-grade analytics and correlation
Extensive marketplace of apps and integrations
Advanced visualization capabilities
Cons:
High licensing costs
Significant resource requirements
Requires custom development for Keycloak-specific monitoring
Graylog Integration
Pros:
Designed specifically for log management
More lightweight than Splunk or ELK
Good search capabilities
Cons:
Less security-focused than Wazuh
Fewer out-of-the-box security rules
Limited SIEM capabilities without extensions
Native Keycloak Auditing
Pros:
No additional components required
Simple setup
Direct access to events within Keycloak
Cons:
Limited retention and search capabilities
No threat detection or alerting
No correlation with other security events
Limited compliance reporting
The Tale of Two Security Teams: A Case Study
Consider two fictional organizations: Company A and Company B. Both implemented Keycloak for identity management, but they took different approaches to security monitoring.
Company A relied solely on Keycloak's native auditing capabilities. When they experienced a credential stuffing attack, it went undetected for 17 days. The attackers compromised 23 accounts and accessed sensitive data before being discovered during a routine log review.
Company B implemented the Keycloak-Wazuh integration. When they faced a similar attack, Wazuh detected the unusual pattern of login attempts within minutes. The security team received an alert, blocked the attacking IP addresses, and reset potentially compromised accounts before any significant data access occurred.
The surprising twist? Both companies spent roughly the same amount on their security budgets, but Company B allocated resources to integration rather than expensive security products that didn't address their specific needs.
Setup and Configuration
Prerequisites
Before setting up the integration, ensure you have:
Docker and Docker Compose installed
Git installed
Basic knowledge of Keycloak and Wazuh
4GB+ of RAM available for the containers
Docker Compose Setup
The integration uses Docker Compose to set up all the required components. The docker-compose.yml file defines the services:
1version: '3.7'2services:3 wazuh.manager:4 image: wazuh/wazuh-manager:4.12.05 # Configuration omitted for brevity6 wazuh.indexer:7 image: wazuh/wazuh-indexer:4.12.08 # Configuration omitted for brevity9 wazuh.dashboard:10 image: wazuh/wazuh-dashboard:4.12.011 # Configuration omitted for brevity12 keycloak:13 image: quay.io/keycloak/keycloak:26.2.314 # Configuration omitted for brevity15 syslog-ng:16 image: lscr.io/linuxserver/syslog-ng17 # Configuration omitted for brevity
Keycloak Configuration
Keycloak needs to be configured to send events to Syslog. This is done by:
Installing the webhook-syslog provider
Configuring the event listener in the realm settings
Setting the appropriate environment variables
The webhook-syslog provider is configured using environment variables in the Docker Compose file:
1environment:2 WEBHOOK_SYSLOG_PROTOCOL: udp3 WEBHOOK_SYSLOG_HOSTNAME: keycloak4 WEBHOOK_SYSLOG_APP_NAME: keycloak_events5 WEBHOOK_SYSLOG_FACILITY: SYSLOG6 WEBHOOK_SYSLOG_SEVERITY: INFORMATIONAL7 WEBHOOK_SYSLOG_SERVER_HOSTNAME: syslog-ng8 WEBHOOK_SYSLOG_SERVER_PORT: 55149 WEBHOOK_SYSLOG_MESSAGE_FORMAT: RFC_5424
The realm configuration includes the webhook-syslog event listener:
1{2 "realm": "adorsys-tests",3 "eventsEnabled": true,4 "eventsListeners": [5 "jboss-logging",6 "webhook-syslog"7 ],8 "adminEventsEnabled": true,9 "adminEventsDetailsEnabled": true10}
Wazuh Configuration
Wazuh requires custom decoders and rules to process Keycloak events. The decoder is simple but effective:
1<decoder name="keycloak_json"><program_name>keycloak_events</program_name><plugin_decoder>JSON_Decoder</plugin_decoder></decoder>
This decoder matches log messages with the program name keycloak_events and uses the built-in JSON decoder to parse the message content.
The rules define conditions that trigger alerts when matched. For example:
1<rule id="110100" level="5"><if_matched_sid>110001</if_matched_sid><field name="type">LOGIN_ERROR</field><description>Keycloak: Failed login attempt from IP $(ipAddress)</description><group>authentication_failures,</group></rule>
This rule matches failed login attempts and generates an alert with severity level 5.
Event Processing Pipeline
The event processing pipeline is the heart of this integration. Let's follow an event through the system:
Event Generation in Keycloak
A user attempts to log in with incorrect credentials
Keycloak generates a
LOGIN_ERRORevent with details like username, IP address, and timestamp
Event Formatting and Forwarding
The webhook-syslog provider captures the event
It formats the event as a JSON message according to RFC 5424
The message is sent to Syslog-ng via UDP
Log Collection and Forwarding
Syslog-ng receives the message
It adds metadata like the hostname and timestamp
The message is forwarded to the Wazuh Manager
Event Decoding and Processing
The Wazuh Manager receives the message
The
keycloak_jsondecoder identifies and parses the message
The JSON fields are extracted for rule matching
Rule Matching and Alert Generation
The event matches rule 110100 for failed login attempts
If multiple failed attempts occur from the same IP, it may also match rule 110101 for brute force attacks
Alerts are generated with appropriate severity levels
Indexing and Visualization
The processed event and any alerts are sent to the Wazuh Indexer
They become available in the Wazuh Dashboard for analysis
Security analysts can investigate the alerts and take appropriate action
This pipeline provides real-time visibility into security events, enabling rapid detection and response to potential threats.
Advanced Security Use Cases
Detecting Brute Force Attacks
Brute force attacks involve repeated login attempts to guess passwords. The integration detects these attacks using frequency-based rules:
1<rule id="110101" level="10" frequency="5" timeframe="300"><if_matched_sid>110001</if_matched_sid><same_source_ip/><description>Keycloak: Possible brute force attack from IP $(ipAddress) - multiple failed logins</description><group>authentication_failures,brute_force,attack,</group><mitre><id>T1110</id> <!-- Brute Force -->2 </mitre></rule>
This rule triggers when five failed login attempts occur from the same IP address within a 300-second window.
Identifying Password Spraying
Password spraying is a variation of brute force where attackers try common passwords across multiple accounts. The integration detects this using a different rule:
1<rule id="110102" level="12" frequency="5" timeframe="300"><if_matched_sid>110001</if_matched_sid><same_srcip/><different_user/><description>Keycloak: Brute force attack on multiple users from IP $(ipAddress)</description><group>authentication_failures,brute_force,attack,</group><mitre><id>T1110.003</id> <!-- Brute Force: Password Spraying -->2 </mitre></rule>
This rule triggers when login attempts target different users from the same IP address.
Detecting Suspicious Login Locations
Unusual login locations can indicate account compromise. The integration detects these using geolocation-based rules:
1<rule id="110150" level="7"><if_matched_sid>110001</if_matched_sid><field name="type">LOGIN</field><different_srcgeoip/><description>Keycloak: Login from new geographic location - IP: $(ipAddress)</description><group>authentication_success,unusual_location,</group></rule>
This rule triggers when a login occurs from a geographic location that differs from the user's previous logins.
Monitoring Administrative Changes
Administrative changes can have significant security implications. The integration monitors these using specific rules:
1<rule id="110005" level="4"><if_sid>110001</if_sid><field name="type">REALM-UPDATE</field><description>Keycloak: User $(userId) updated Realm configuration</description><options>no_full_log</options><group>configuration_changes,system_changes,</group></rule>
This rule triggers when a user updates the realm configuration.
Troubleshooting
Common Issues and Solutions
Events Not Appearing in Wazuh
If events are not appearing in Wazuh:
Check that the webhook-syslog provider is installed and configured correctly
Verify that the event listener is enabled in the Keycloak realm
Check the Syslog-ng logs for any errors
Verify that the Wazuh Manager is receiving the logs
Decoder Not Matching Events
If the decoder is not matching events:
Check that the program name in the Syslog message matches
keycloak_eventsVerify that the JSON format is correct
Check the Wazuh Manager logs for any decoding errors
Rules Not Triggering
If rules are not triggering:
Check that the field names in the rules match those in the events
Verify that the parent rule (110001) is triggering
Check the rule syntax for errors
Debugging Techniques
To debug the integration:
Enable debug logging in Keycloak:
1KC_LOG_LEVEL=DEBUG
2. Check the Syslog-ng logs:
docker-compose logs syslog-ng
3. Check the Wazuh Manager logs:
docker-compose logs wazuh.manager
4. Use the Wazuh API to check for decoded events:
curl -k -X GET "https://localhost:55000/events" -H "Authorization: Bearer $TOKEN"
Production Considerations
Scaling the Architecture
For production deployments, consider:
Wazuh Cluster: Set up a Wazuh cluster with multiple manager nodes for high availability and load balancing
Syslog-ng Redundancy: Deploy multiple Syslog-ng instances with load balancing
Wazuh Indexer Cluster: Set up a cluster of Wazuh Indexer nodes for better performance and redundancy
Performance Optimization
To optimize performance:
Resource Allocation: Allocate sufficient CPU and memory to each component
Tuning Wazuh Indexer: Adjust JVM settings and indexing parameters
Log Rotation: Implement log rotation to manage disk space
Rule Optimization: Fine-tune rules to reduce false positives and improve performance
Backup and Recovery
Implement a backup strategy for:
Wazuh Indexer Data: Regular snapshots of the indices
Wazuh Configuration: Backup of custom decoders and rules
Keycloak Configuration: Backup of realm settings and event listener configuration
Future Enhancements
The Keycloak-Wazuh integration can be further enhanced in several ways:
Machine Learning Integration: Implementing anomaly detection for more sophisticated threat detection
Automated Response Actions: Configuring Wazuh to automatically respond to certain alerts
Integration with Threat Intelligence: Enriching alerts with threat intelligence data
Custom Dashboards: Creating specialized dashboards for identity security monitoring
Extended Event Coverage: Adding support for additional Keycloak event types
Conclusion
The integration of Keycloak with Wazuh through Syslog provides a powerful solution for monitoring identity and access management security. By leveraging the strengths of both platforms, organizations can achieve:
Real-time visibility into authentication events
Proactive detection of security threats
Comprehensive compliance monitoring
Enhanced security posture for identity management
As identity-related attacks continue to rise, this integration offers a cost-effective and efficient approach to securing one of the most critical components of modern IT infrastructure.
The surprising insight? The most effective security solutions aren't always the most expensive or complex. Sometimes, the strategic integration of open-source tools can provide better protection than costly commercial alternatives. By focusing on the specific security needs of identity management and leveraging the strengths of specialized tools like Keycloak and Wazuh, organizations can achieve a level of security that exceeds what many commercial solutions offer.
Remember: In the world of identity security, visibility is the foundation of protection. You can't defend against what you can't see.
Next posts

Keycloak × Stripe: Building Invisible Marketplace Onboarding with Event-Driven Architecture
Discover how to build a seamless marketplace onboarding experience by integrating Keycloak and Stripe Connect using event-driven reactive Kotlin and AMQP.

Mastering Keycloak Configuration with GitOps and keycloak-config-cli
Eliminate Keycloak Click-Ops. Learn how the Keycloak Tenant Accelerator (KTA) uses GitOps and keycloak-config-cli to build a scalable, automated multi-tenant CaC workflow.

MFA – The Choice Challenge
Hardware-Token oder Smartphone? Der Blog erklärt die Unterschiede moderner MFA-Verfahren, ihre Sicherheitsstärken, Risiken und wann welche Methode sinnvoll eingesetzt werden sollte.