Guide Uses Elastic and Cloudflare to Block Traefik Scanners

Summary
The guide uses Elastic Security to detect Traefik probing from repeated 403 and 404 responses, then automatically blocks source IPs through a Cloudflare WAF workflow. It also explains how to reuse the response for other detections.
Key points
- An ES|QL rule detects probing by aggregating 403 and 404 responses by source IP and distinct URI paths.
- The author adjusts the example rule’s thresholds from more than 500 errors across 250 paths to more than 100 errors across 50 paths.
- A custom ingest pipeline copies agent.name into the host.name field required by the detection rule.
- An Elastic workflow updates a Cloudflare WAF rule to block the detected IP and acknowledges the alert.
- The same blocking workflow can be attached to detections for SQL injection or file inclusion attempts.
- The author validates the workflow with ffuf or gobuster and notes that accumulated IP expressions can exceed Cloudflare’s WAF expression length limit.
Article Details
- Defense Focus
- Detect web server discovery and directory fuzzing in Traefik access logs, then automatically block the source IP at the Cloudflare edge.
- Detection Methods
- Aggregate HTTP 403 and 404 responses by source IP within the polling window and flag high volumes across distinct URI paths.
- The article’s adjusted thresholds trigger when event_count is greater than 100 and url_original_count_distinct is greater than 50; it also recommends excluding authorized scanners with a source.ip filter.
- Use a custom ingest pipeline to copy agent.name into host.name, which the detection rule requires.
- Data Sources
- Traefik access logs ingested into the logs-traefik.access-default datastream
- Source IP, HTTP response codes, and requested URI paths from the access logs
- Elastic Security alerts generated by the detection rule
- Rule Types
- ES|QL threshold detection rule
- YAML-configured alert-triggered workflow
- Cloudflare WAF custom rule using an IP-based block expression
- Defensive Actions
- On a matching alert, add the source IP to an existing Cloudflare WAF block rule or create the rule if it does not exist.
- Acknowledge the Elastic Security alert after the Cloudflare update.
- Use a custom ingest pipeline rather than modifying the integration’s default pipeline so the host.name mapping survives integration upgrades.
- Tune thresholds for the environment and exclude authorized scanners to reduce false positives and accidental blocking.
- Monitor the Cloudflare custom-rule expression length and periodically clear the rule if it approaches the stated limit.
- After validation, remove your own IP from the block rule to avoid locking yourself out.
MITRE ATT&CK
T1083 · File and Directory DiscoveryThe article describes directory fuzzing through repeated requests for non-existent paths and admin-related resources, including paths such as /wp-admin/includes/header.php.T1595 · Active ScanningThe detection identifies automated probing of exposed services from repeated 403 and 404 responses generated by a source IP.
Vendors
CloudflareThe article shows how Traefik access logs can be used in Elastic Security to detect web server discovery and fuzzing, then automatically block the source IP at the Cloudflare edge.ElasticThe article shows how Traefik access logs can be used in Elastic Security to detect web server discovery and fuzzing, then automatically block the source IP at the Cloudflare edge.
Products
Authelia#TraefikCloudflareThe article shows how Traefik access logs can be used in Elastic Security to detect web server discovery and fuzzing, then automatically block the source IP at the Cloudflare edge.Elastic AgentThe Elastic Agent collects logs from Traefik servers.Elastic SecurityThe article shows how Traefik access logs can be used in Elastic Security to detect web server discovery and fuzzing, then automatically block the source IP at the Cloudflare edge.Proxmox Virtual EnvironmentMy homelab setup utilizes Proxmox VE for containers and VMs.Traefik ProxyThe article shows how Traefik access logs can be used in Elastic Security to detect web server discovery and fuzzing, then automatically block the source IP at the Cloudflare edge.
