CNAME cloaking

On this page 7

CNAME cloaking is a web tracking technique in which a website points one of its own subdomains to a third-party tracking service through a DNS CNAME record, so that the tracker appears to the browser as a first-party resource. In tracking and privacy practice, it is classified as an evasion method because it sidesteps protections that treat third-party cookies and scripts differently from first-party ones.

The technique is also called CNAME-based tracking or first-party disguise. It matters because it can defeat cookie restrictions and filter lists, and because it can expose first-party cookies of the site, including session data, to an outside company.

How CNAME cloaking works in DNS

A CNAME record is a DNS alias: it tells resolvers that one hostname is another name for a different hostname. In CNAME cloaking, a site owner creates a subdomain such as metrics.example.com and sets its CNAME to a hostname operated by the tracking vendor, for example client123.tracker-vendor.net.

The browser sees requests to metrics.example.com, which shares the registrable domain of the visited site. Cookies set by that subdomain are therefore same-site cookies, while the traffic actually terminates on the vendor’s servers. The browser never sees the vendor name unless it resolves the full DNS chain.

The steps below summarize what happens during a typical page load.

StepWhat happensPrivacy effect
DNS lookupSubdomain resolves through a CNAME to the vendorVendor identity is hidden from the page
Script or pixel requestBrowser loads a resource from the subdomainTreated as first-party by many filters
Cookie handlingVendor server sets a cookie on the site domainIdentifier gets first-party lifetime rules
Cookie leakageBrowser sends parent-domain cookies to the subdomainVendor may receive session or login cookies
Data collectionVendor logs events, identifiers and IP addressProfile builds despite third-party blocking
Request flow on a cloaked subdomain

Why trackers use first-party disguise

The main motive is longer and more reliable identifiers. Browsers such as Safari, Firefox and Brave block or partition third-party cookies, and many browsers limit cookies created by JavaScript. A cookie set through an HTTP response header from a same-site subdomain historically escaped those limits.

A second motive is filter list evasion. Blocklists match on hostnames, and a unique subdomain on each customer site is far harder to list than one central tracker domain. Vendors marketed this as first-party analytics or ad-blocker resilience, which framed it as a feature rather than an evasion.

The third motive is data quality for advertisers: with fewer blocked requests, attribution and conversion measurement look more complete. That benefit for the site comes at the cost of user expectations that blocking tools are working.

Privacy and security risks

The most serious risk is unintended cookie exposure. Cookies scoped to the parent domain, such as .example.com, are sent automatically to every subdomain, including the cloaked one. If authentication or session cookies are scoped this way, the tracking vendor receives them with each request.

The table below lists the main risks and who bears them.

RiskMechanismWho is affected
Session cookie leakageParent-domain cookies sent to the vendorUsers and the site’s security posture
Subdomain takeoverDangling CNAME after the vendor contract endsSite reputation and user accounts
Opaque data sharingUsers cannot see which company receives dataUsers and consent validity
Bypassed user choicesBlockers and browser limits are evadedUsers who opted for protection
Compliance exposureUndisclosed processor or controllerThe site owner under GDPR and ePrivacy
Risks created by cloaked tracking subdomains

A dangling CNAME is a known security pitfall: if the vendor hostname is released and someone else registers it, that party can serve content on the site’s own subdomain. Regular DNS audits remove records that point to services no longer in use.

How browsers and blockers respond

Countermeasures work by resolving the full DNS chain and judging the final destination rather than the visible hostname. Browser vendors also cap the lifetime of cookies that look like they come from disguised third parties.

DefenseApproachLimitation
Safari Intelligent Tracking PreventionCaps cookies set by cloaked responses to about 7 daysDoes not block the request itself
uBlock Origin in FirefoxUses the browser DNS API to uncloak hostnamesNot available in Chromium extension APIs
Brave ShieldsResolves CNAME chains before applying filtersDepends on accurate tracker lists
DNS-level blockersBlock the vendor hostname at the resolverEncrypted DNS in the browser can bypass them
Uncloaking filter listsPublish known cloaked subdomains per siteAlways lag behind new deployments
Main defenses against CNAME cloaking

Safari later extended its limits to some cookies set by servers whose IP address differs from the main site, which targets proxy setups as well as CNAME records. These measures make cloaking less durable but not impossible, which is why it remains a monitored technique.

CNAME cloaking belongs to a family of methods that blur the line between first-party and third-party contexts. It differs from its neighbors in where the disguise happens and who controls the infrastructure.

TechniqueWhere the disguise happensWho runs the server
CNAME cloakingDNS alias on a site subdomainThird-party vendor
Server-side tagging proxySite-owned endpoint forwarding dataSite owner, then vendors
Bounce trackingRedirect through a tracker domainThird-party vendor
Link decorationIdentifier appended to URLsVaries by implementation
Device fingerprintingNo storage, device traits onlyThird-party or first-party
Neighboring methods in web tracking

A server-side proxy owned by the site is not cloaking in itself, because the site controls what it forwards. It becomes ethically similar when it is used to evade user choices rather than to minimize data, so intent and disclosure matter as much as architecture.

The idea in brief

Imagine a shop that lets an outside marketing firm set up a desk inside, wearing the shop’s own uniform. Customers think they are talking to the shop, but their details go to the outside firm. CNAME cloaking is that uniform, applied to a website address.

Browsers and blockers try to stop outside trackers, but they mostly judge by the name on the door. Because the tracker borrows the website’s own name, many protections let it through. Newer browsers now check who is really behind the desk.

A practical scenario

An online retailer notices that a large share of its visitors block third-party analytics. A vendor proposes a cloaked setup, and the retailer creates stats.shop-example.com with a CNAME to the vendor. Within weeks, measured sessions rise, because blocklists no longer match the requests.

A security review later finds that the retailer’s login cookie is scoped to the whole domain, so the vendor’s servers have been receiving session cookies on every page view. The retailer rescopes the login cookie to the main hostname, replaces the CNAME with a site-owned proxy that forwards only aggregated events, discloses the vendor in its cookie policy and removes the old DNS record to prevent a subdomain takeover.