A customer asks for “the SaaS pattern” where any subdomain works without having to add a DNS record per customer. A wildcard A or CNAME is the right answer technically. The same record is also the reason every typo on the internet resolves to the server, every cert authority issues wildcard certs nobody asked for, and a phishing investigator finds plausible-looking subdomains under your domain that you didn’t know existed.
What’s happening
A wildcard record like *.example.com IN A 192.0.2.10 matches any subdomain not explicitly defined. random.example.com, api.example.com, definitely-not-phishing.example.com — all resolve to the wildcard’s target. Resolution stops being explicit; whatever name a client invents resolves.
The behaviour is precisely what a multi-tenant SaaS needs (each customer gets <customer>.example.com automatically), and precisely the wrong thing for a typical cPanel-hosted website. Specific issues:
- A typo like
wwww.example.comresolves to the same IP aswww.example.com. The browser shows a connection, the user is confused. - Cert issuance for
*.example.comrequires DNS-01 challenge. If the wildcard resolves to your IP, an automated cert tool may also issue specific-name certs for unintended subdomains. - A phisher registers an account on a service that uses CNAME-validation (Heroku, AWS, others) and points the CNAME at
phishing-target.example.com— the wildcard makes the subdomain “live” from your zone, and now there’s a TLS-served phishing site under your name.
Wildcards also interact with CNAMEs in subtle ways. *.example.com IN CNAME other.example.com is legal but unintuitive: the wildcard’s target gets a CNAME, not an A, so the resolver has to do an extra lookup.
How to verify
Check whether a zone has a wildcard:
dig +short '*.example.com' A
dig +short totally-fake-name.example.com A
If totally-fake-name.example.com resolves to anything, the zone has a wildcard. Compare to:
whmapi1 dumpzone domain=example.com | grep -E '^\*'
For subdomains that exist explicitly, list them:
whmapi1 dumpzone domain=example.com | grep -E '^[a-z0-9_-]+ +[0-9]+ +IN +(A|CNAME)' | head
If the customer’s intent is “explicit subdomains only”, anything in the dumpzone matching ^* is wrong.
What to do
- Decide whether wildcards are intentional. Multi-tenant SaaS, vanity URLs that change frequently, white-label hosting where customers control their own subdomains — wildcards are appropriate. Most other cases — don’t use them.
- If you remove a wildcard, audit the actual subdomain traffic first.
tail -1000 /var/log/cpanel/accesslog | awk '{print $11}' | sort -ushows what hostnames are being requested. Any subdomain in use that doesn’t have an explicit record needs one before you remove the wildcard. - If you keep the wildcard, lock it down with these guardrails:
- Make the wildcard target a default landing page (not the customer’s real site), so a typo gets a “not found” page, not a misleading copy of the real site.
- Configure the web server to return 404 on unknown
Host:headers (Apache’s<VirtualHost _default_>returning a 404, LiteSpeed equivalent). - Monitor for unexpected hostname resolution against the zone — a phisher pointing a CNAME at your zone will produce odd lookups in
namedquery logs.
- For cert management, prefer specific certs over wildcards when the subdomain list is known and stable. Wildcards are operationally easier but have a broader blast radius if the private key is compromised.
- Don’t put a wildcard at the apex (
@ IN A *doesn’t mean what people sometimes think — there’s no wildcard at apex). Wildcards only apply to subdomains below the apex.
For a SaaS deployment that legitimately needs wildcards, scope them with subdomain prefixes: *.tenant.example.com IN A ... rather than *.example.com IN A .... That isolates the wildcard to a clearly multi-tenant subtree and keeps the parent zone strict.
Stack Harbor reviews wildcard usage during zone audits as part of managed cPanel operations.