This project combines the power of Wazuh XDR and Cloudflare to deliver automated threat detection and mitigation at scale.
- Wazuh XDR for threat detection and incident response
- 🔹 Cloudflare for edge-level traffic filtering and IP blocking
- ✅ Real-time detection of malicious activity using Wazuh's correlation engine
- ✅ Automatic blocking of suspicious IPs via Cloudflare’s firewall API
- ✅ Scalable and automated protection — no manual intervention needed
- ✅ Faster incident response with proactive threat mitigation
- Wazuh analyzes logs, detects threats, and raises alerts
- Malicious IPs are sent to Cloudflare for immediate blocking
- All activity is monitored and logged for full auditability
- Go to your Cloudflare account.
- Navigate to Manage Account → Configurations → Lists.
- Click Create new list.
- Name it (e.g.,
wazuh_blocked_ips), selectIP Addressas content type, and click Create. - Copy the List ID (
CLOUDFLARE_IP_LIST_ID).
- Found on your domain’s main page under the API section. Save it as
CLOUDFLARE_ACCOUNT_ID.
- Go to My Profile → API Tokens → Create Token.
- Use the Edit Cloudflare IP Lists template or define custom permissions:
- Account → Account Settings → Read
- Account → Cloudflare IP Lists → Edit (or Write)
- Assign the token to your account and copy it immediately. Save as
CLOUDFLARE_API_TOKEN.
- Go to Security → WAF → Firewall Rules.
- Click Create Firewall Rule.
- Name it (e.g.,
Block Wazuh IPs), and configure:- Field:
IP Source Address - Operator:
is in list - Value: your IP list (
wazuh_blocked_ips) - Action:
Block,Managed Challenge, orJS Challenge
- Field:
- Click Deploy.
- Copy the active response script to
/var/ossec/active-response/bin/cloudflare-block-ip.py: - Install the python modules requeriments: apt install python-requests
- Make it executable:
chmod +x /var/ossec/active-response/bin/cloudflare-block-ip.py
-
In
/var/ossec/etc/ossec.conf, add:<ossec_config> <command> <name>cloudflare-block</name> <executable>cloudflare-block-ip.py</executable> <timeout_allowed>yes</timeout_allowed> </command> <active-response> <disabled>no</disabled> <command>cloudflare-block</command> <location>server</location> <rules_id>5712,5720</rules_id> <timeout>60</timeout> </active-response> </ossec_config>
-
Restart Wazuh:
systemctl restart wazuh-manager
- Make sure Wazuh has outbound internet access to reach the Cloudflare API.
- You can customize the rule to respond to different threat types or log sources.
You can create a docs/ folder with:
- Sample logs that trigger the response
- Extended JSON example from GCP
- Testing instructions
Contributions welcome! Please open an issue or submit a pull request.