skip to content

A site's apex and www records are proxied on Cloudflare, yet attackers reach the origin directly; which records in the zone could have exposed its IP?

level: seniorimportance: must knowfreq 60%

answer

  1. every gray cloud on the same server
  2. mail follows the server
  3. a wildcard answers anything
  4. the days before activation

basics

~20 s

Any answer carrying the origin's address: a DNS-only A, AAAA or CNAME for another service on that server, a mail host or _dc-mx answer, a DNS-only wildcard, and every record while the zone was pending activation.

solid answer

~50 s

Proxying `www` and the apex hides only those two names. I would query every record in the zone from outside and look for the origin's IP. Typical leaks: a **DNS-only** `A` or `CNAME` for `ssh`, `ftp`, `cpanel`, `dev` or a game server on the same machine; a mail hostname on that IP, or an `MX` aimed at a proxied name, which Cloudflare answers with a `_dc-mx` record that resolves to the origin; `SRV` answers rewritten to a `dc-` name; a **DNS-only wildcard** that answers any made-up name with the origin; and an SPF `TXT` that lists the server's address. The zone also answered every record as DNS-only while it was **pending** activation. The fix in DNS is to proxy every web record sharing the IP, move non-HTTP services and mail to other addresses and delete stale records; then the origin must be locked to Cloudflare and its IP changed.

code

bash · 13 lines
bash
#!/usr/bin/env bash
# Compare every public answer in the zone with the origin's addresses.
ORIGIN_IPS="192.0.2.10 2001:db8::10"
for name in example.com www.example.com api.example.com ssh.example.com \
            play.example.com mail.example.com "probe-$RANDOM.example.com"; do
  for type in A AAAA; do
    for ip in $(dig +short "$name" "$type"); do
      case " $ORIGIN_IPS " in *" $ip "*) echo "LEAK $name $type $ip";; esac
    done
  done
done
dig +short example.com MX     # a _dc-mx target means MX points at a proxied name
dig +short example.com TXT    # look for ip4:/ip6: in SPF

go deeper

for a junior

Know that any DNS-only record pointing at the same server reveals its IP, even when the website's own records are proxied.

for a middle

List the usual leaks: DNS-only service names, mail hosts, the _dc-mx rewrite, DNS-only wildcards, and the pending period before activation.

for a senior

Run the audit from outside, follow generated answers the records table hides, fix records in the right order, then hand off to lockdown and IP rotation.

for a principal

Make 'no DNS-only record on a web origin's IP' a review rule for every zone change, with an automated outside-in check that runs after each one.

## Why proxying two names is not enough A proxied record hides one name. An attacker does not need the website's name to find the server; any public record that resolves to the **same IP** will do. Cloudflare's own guidance is that when a DNS-only record points to the same origin as a proxied record, a `dig` against it reveals the origin's IP. So the audit question is not "is the website orange?" but "which answers from this zone contain the origin address?" ## Records that leak, one by one | Record | How it leaks | Fix in DNS | |---|---|---| | DNS-only `A`/`AAAA`/`CNAME` for another service on the server (`ssh`, `ftp`, `cpanel`, `dev`, `direct`, a game server) | The answer is the origin IP | Proxy it if it serves HTTP or HTTPS; otherwise move the service to another IP | | Mail hostname on the web server's IP | Mail records must be DNS-only | Host mail on a separate address | | `MX` pointing at a proxied hostname | Cloudflare answers with a generated `_dc-mx` name that resolves to the origin | Point `MX` at a DNS-only mail host on another IP, or delete an unused `MX` | | `SRV` pointing at a proxied hostname | Rewritten to a `dc-` name that resolves to the origin | Target a separate, DNS-only host | | DNS-only wildcard `*` | Any invented name answers with the origin | Proxy the wildcard, which all plans may do, or remove it | | SPF `TXT` listing the server's address | The address is printed in plain text | Send mail from a different IP | The dashboard helps: when a zone has unproxied records it shows a banner, and individual records can show warnings that they may expose the origin. The warnings do not change traffic. ## Leaks the zone cannot see in its table Two leaks do not show as a gray cloud today: 1. **The pending period.** When a domain is added to Cloudflare, records set to Proxied answer as **DNS-only** until the zone is activated, which can take up to 24 hours. During that window every query returned the origin's IP. Cloudflare recommends changing the origin addresses at the hosting provider after activation for exactly this reason. 2. **Answers generated at query time.** `_dc-mx` and `dc-` records are inserted into responses, not stored, so a review of the records table misses them; only a `dig` from outside shows them. An address that was published before the move, in old DNS answers kept by others, is the same problem from the past and belongs with origin lockdown. ## Changes that reopen a leak A clean zone does not stay clean by itself. The leaks usually come back through ordinary work: - a developer adds `staging` or `debug` as DNS-only to bypass caching while testing, on the production server; - a bulk proxy-status edit in the dashboard sets a mixed selection to **DNS only**; - someone turns on the account-level `enforce_dns_only` switch during an incident, which makes every proxied record in the account answer with its real content until it is switched off. Each of these is a reason to repeat the outside-in check after changes, not only once after the migration. ## Running the audit 1. Export the zone or list its records, and note every `A`, `AAAA` and `CNAME` with `proxied` set to `false`. 2. From outside the network, query each name and compare the answers with the origin's addresses (see the code example). 3. Query `MX`, `SRV` and `TXT` at the apex and at any service names, and follow any `_dc-mx` or `dc-` target. 4. Query a random, nonexistent name to catch a DNS-only wildcard. 5. For each hit, decide: proxy it, move the service to another IP, or delete the record. ## After DNS is clean Cleaning DNS stops new leaks but cannot take back an address that is already known. Two further steps belong with the origin lockdown material rather than with proxy status: - **accept traffic only from Cloudflare**, with a firewall allowlist of Cloudflare's ranges, Authenticated Origin Pulls or a Tunnel; - **change the origin's IP**, so the leaked address leads nowhere. The order matters: if the IP changes first and a gray-clouded `ssh` record still points at the new address, the new address leaks the same day.

  • Why does Cloudflare recommend changing the origin's IP after a zone is activated?
    While a zone is pending, records set to Proxied answer as DNS-only, so every query in that window returned the origin's address. Activation stops the leak but cannot recall it. Changing the address at the hosting provider after activation makes those answers useless; locking the origin to Cloudflare then stops the next leak from mattering.
  • Should every DNS-only record in the zone be switched to Proxied to stop leaks?
    No. Mail hosts, domain-verification CNAMEs, SaaS-hosted names and non-HTTP services break when proxied. The goal is that no DNS-only record shares the web origin's IP: proxy the records that carry HTTP or HTTPS, and move the rest to other addresses.
  • A team proxied a wildcard record; does that hide the origin for all names?
    It hides it for the names the wildcard answers, because a proxied wildcard returns Cloudflare's addresses. Specific records still answer on their own terms, so a DNS-only `ssh` record beside a proxied `*` leaks as before. Customers on all plans can proxy wildcard records.

  • Once www and the apex are orange-clouded, the origin IP cannot be found in DNS.
  • A _dc-mx answer only reveals the mail provider, never the web server.
  • Records were protected from the moment the domain was added, before activation.
  • A gray-clouded SSH record on the web server reveals nothing about the website.
  • Fixing the DNS records makes an already-leaked IP safe again.