Wildcard DNS Detection
DNS wildcard configuration creates security risks for your domain
Security Warning
Your domain uses wildcard DNS records that respond to any subdomain query. This configuration can enable subdomain hijacking attacks and make DNS rebinding vulnerabilities easier to exploit by allowing attackers to reference arbitrary subdomains under your domain name.
Understanding Wildcard DNS Security Risks
Wildcard DNS records create an inherent security trade-off between convenience and control. While they simplify DNS management by automatically resolving any subdomain request, they also provide attackers with a mechanism to create seemingly legitimate subdomains for malicious purposes. The wildcard asterisk (*) symbol tells DNS resolvers to return the same response for any subdomain that doesn't have an explicit record, effectively giving attackers unlimited subdomain creation abilities.
The security implications extend beyond simple subdomain abuse. Wildcard DNS configurations can facilitate sophisticated attacks including subdomain takeover attempts, DNS rebinding attacks that bypass same-origin policies, and social engineering campaigns that use legitimate-looking subdomains to deceive users. Organizations often implement wildcards without fully understanding how they can be weaponized by determined attackers.
How Wildcard DNS Enables Attacks:
Subdomain takeover attacks become easier when wildcards are present because attackers can claim unused subdomains that resolve through the wildcard but point to external services they control, effectively hijacking part of your domain namespace.
DNS rebinding bypasses are facilitated by wildcards because attackers can create arbitrary subdomains like "192-168-1-1.yourdomain.com" that resolve to your wildcard but are designed to target internal network addresses.
Social engineering campaigns become more convincing when attackers can create professional-looking subdomains like "secure-login.yourdomain.com" or "admin-portal.yourdomain.com" that appear to be legitimate services.
Immediate Wildcard DNS Security Actions
With these attack vectors understood, immediate action is required to assess and secure your wildcard DNS implementations. Begin by identifying all wildcard DNS records in your domain configuration, as many organizations implement wildcards without realizing their security implications. Test for wildcard behavior by querying random subdomains that shouldn't exist - if they resolve to IP addresses, you have active wildcards that need evaluation. Document which wildcards serve legitimate business purposes versus those that exist due to poor configuration management.
For essential wildcard implementations, implement application-level controls that validate subdomain requests against allowlists and reject suspicious patterns. Monitor DNS query logs for unusual subdomain access patterns that could indicate reconnaissance or exploitation attempts. Replace unnecessary wildcards with explicit DNS records for each legitimate subdomain to eliminate the attack surface.
Wildcard DNS Security Implementation
With the security risks clearly established and priorities identified, implementing protective measures becomes the next critical step. After auditing your wildcard DNS usage, the next step involves implementing technical controls to secure or remove these configurations. The following platform-specific examples show how to safely manage wildcard DNS records while maintaining necessary functionality.
BIND Wildcard Control
BIND provides several approaches to secure wildcard DNS configurations. The most effective strategy involves removing wildcard records entirely and replacing them with explicit subdomain entries that you control.
Remove Dangerous Wildcards
Start by identifying and commenting out existing wildcard records in your zone files. This prevents attackers from creating arbitrary subdomains:
; Remove dangerous wildcard record - this allowed ANY subdomain to resolve
; *.example.com. IN A 192.168.1.100Define Explicit Subdomains
Replace the wildcard with specific records for each legitimate subdomain. This approach gives you precise control over what resolves:
; Replace with specific subdomains - only these will resolve
www.example.com. IN A 192.168.1.100
api.example.com. IN A 192.168.1.101
mail.example.com. IN A 192.168.1.102Implement Security Views
BIND views allow different DNS responses based on client location. This separates internal infrastructure from external exposure:
; Internal view - provides full DNS resolution for internal networks
view "internal" {
match-clients { 192.168.0.0/16; 10.0.0.0/8; };
zone "example.com" {
type master;
file "/etc/bind/zones/internal/example.com.zone";
};
};
; External view - limited DNS exposure for public internet
view "external" {
match-clients { any; };
zone "example.com" {
type master;
file "/etc/bind/zones/external/example.com.zone";
};
};Security Benefit: Views prevent internal infrastructure exposure while maintaining necessary external services.
Unbound Wildcard Filtering
Unbound's filtering capabilities allow you to block suspicious wildcard abuse while maintaining legitimate DNS resolution. Configure these settings in /etc/unbound/unbound.conf to protect against common wildcard exploitation techniques.
Access Control for Suspicious Patterns
Set up access control tags to automatically refuse suspicious subdomain queries based on client location and pattern matching:
server:
# Allow internal networks to access tagged suspicious subdomains
access-control-tag-action: 192.168.0.0/16 allow suspicious_subdomains
# Block external clients from accessing suspicious patterns
access-control-tag-action: 0.0.0.0/0 refuse suspicious_subdomainsLocal Zones for Abuse Prevention
Create static local zones that catch common wildcard abuse attempts and redirect them to safe endpoints:
# Local zone to catch wildcard abuse - redirects to localhost
local-zone: "suspicious.example.com" static
local-data: "suspicious.example.com A 127.0.0.1"Query Monitoring and Logging
Enable comprehensive logging to track wildcard queries and identify potential abuse patterns:
# Log wildcard queries for monitoring suspicious activity
log-queries: yes
log-time-ascii: yesControlled Subdomain Resolution
Replace wildcards with specific local data entries that provide controlled resolution for legitimate subdomains:
# Use local data to replace wildcards with specific subdomains
local-zone: "api.example.com" transparent
local-data: "api.example.com A 192.168.1.101"
local-data: "www.example.com A 192.168.1.100"Protection Advantage: This configuration blocks malicious wildcard abuse while allowing legitimate subdomain access with full logging visibility.
PowerDNS Wildcard Management
PowerDNS offers sophisticated Lua scripting capabilities to dynamically filter wildcard abuse attempts while maintaining database-driven DNS record management. This approach provides both real-time protection and permanent wildcard removal.
Lua Script for Dynamic Filtering
Implement a preresolve Lua script that examines each DNS query and blocks suspicious subdomain patterns before they can be exploited:
-- Lua script to block suspicious subdomains
function preresolve(dq)
local qname = dq.qname:toString()
-- Block IP-like subdomains (common in DNS rebinding attacks)
if qname:match(".*%d+%-%d+%-%d+%-%d+%..*") then
dq:addAnswer(pdns.A, "127.0.0.1") -- Redirect to localhost
return true
end
-- Block extremely long or random-looking subdomains
if #qname > 50 or qname:match(".*[a-z0-9]{20,}%..*") then
return true -- Return NXDOMAIN for suspicious queries
end
return false -- Allow normal queries to continue
endThis script blocks two common attack patterns: IP-address-like subdomains used in DNS rebinding attacks, and unusually long random subdomains that indicate reconnaissance or brute-force attempts.
Database Wildcard Replacement
Remove dangerous wildcard records from the PowerDNS database and replace them with specific, controlled subdomain entries:
-- Remove wildcard records that allow arbitrary subdomain resolution
DELETE FROM records WHERE name='*.example.com' AND type='A';
-- Add specific subdomain records for legitimate services only
INSERT INTO records (domain_id, name, type, content, ttl)
VALUES (1, 'www.example.com', 'A', '192.168.1.100', 300);
INSERT INTO records (domain_id, name, type, content, ttl)
VALUES (1, 'api.example.com', 'A', '192.168.1.101', 300);Implementation Advantage: PowerDNS combines real-time Lua filtering with database-driven record management, providing both immediate protection and permanent wildcard elimination.
Cloudflare Wildcard Security
Cloudflare provides multiple layers of protection against wildcard DNS abuse through its dashboard controls and advanced Worker scripting capabilities. This combination offers both simple configuration options and sophisticated custom logic.
Dashboard Security Configuration
Start by accessing the DNS Records section in your Cloudflare dashboard where you can identify and replace dangerous wildcard entries. Navigate to DNS → Records and locate any asterisk (*) wildcard records that might be exposing your domain to abuse.
Replace these wildcards with specific subdomain records for each legitimate service you need to expose. This approach gives you precise control over which subdomains actually resolve while preventing attackers from creating arbitrary entries.
Configure Page Rules to control subdomain behavior by setting specific forwarding, caching, and security settings for different subdomain patterns. Enable Bot Management features to add an additional security layer that can detect and block automated subdomain scanning attempts.
Advanced Worker Script Protection
Deploy a Cloudflare Worker script that examines every incoming request and validates subdomain legitimacy before allowing access. This provides real-time protection against wildcard abuse attempts:
// Worker script to block suspicious subdomains
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url)
const hostname = url.hostname
// Block suspicious patterns that indicate attack attempts
if (hostname.match(/.*d+-d+-d+-d+..*/) || // IP-like subdomains
hostname.match(/.*[a-z0-9]{20,}..*/) || // Random long strings
hostname.length > 50) { // Excessively long hostnames
return new Response('Access Denied', { status: 403 })
}
// Allow only explicitly whitelisted subdomains
const allowedSubdomains = ['www', 'api', 'mail', 'admin']
const subdomain = hostname.split('.')[0]
if (!allowedSubdomains.includes(subdomain)) {
return new Response('Subdomain Not Found', { status: 404 })
}
return fetch(request) // Forward legitimate requests
}This Worker script blocks common attack patterns including IP-address-like subdomains used in DNS rebinding attacks, random character strings that indicate scanning attempts, and any subdomain not explicitly allowlisted. The script runs on Cloudflare's edge network, providing global protection with minimal latency impact.
Cloudflare Advantage: Combines easy dashboard management with powerful edge computing protection, offering comprehensive wildcard security without complex server-side configuration.
Application-Level Subdomain Validation
Even with DNS-level protections in place, implementing server-side validation provides a crucial additional security layer. This approach ensures that your application can defend against wildcard abuse even when DNS controls fail or are bypassed.
Nginx Host Header Validation
Configure Nginx to validate incoming Host headers and reject requests to unauthorized subdomains. This prevents attackers from bypassing DNS protections by directly targeting your server's IP address:
# Nginx subdomain validation using map directive
map $host $allowed_host {
~^(www|api|mail|admin).example.com$ 1; # Allow only these subdomains
default 0; # Reject everything else
}
server {
# Check if the requested host is allowed
if ($allowed_host = 0) {
return 444; # Close connection without response
}
# Continue with normal processing for allowed subdomains
location / {
proxy_pass http://backend;
}
}How This Protection Works
The map directive creates a conditional variable that checks the incoming Host header against a whitelist of allowed subdomains. When attackers attempt to access unauthorized subdomains, the server immediately closes the connection (HTTP status 444) without processing the request or revealing information about your infrastructure.
This validation runs before any application logic executes, providing efficient protection against both DNS-based attacks and direct IP address targeting. The regex pattern ensures exact subdomain matching while preventing bypasses through subdomain manipulation.
Defense Advantage: Application-level validation provides protection even when DNS controls are compromised, creating multiple security layers that attackers must bypass.
Building Comprehensive Subdomain Security
Develop organizational policies that address wildcard DNS risks in your broader security strategy. This includes establishing procedures for subdomain lifecycle management, implementing security reviews for new wildcard requests, and conducting regular audits of DNS configurations. Train development teams about the security implications of wildcard DNS and provide secure alternatives for dynamic subdomain requirements.
Consider implementing Content Security Policy headers, HTTP Strict Transport Security across all subdomains, and robust Host header validation in web applications. Regular penetration testing should specifically target subdomain abuse scenarios to ensure your defenses remain effective against evolving attack techniques that exploit wildcard configurations.
Last updated: July 25, 2025
