Intermediate·16 min read·Updated 2026-10-15

Subdomain Takeover: Detection, Claim Hijacking & Prevention

Original WeSecureX guide for authorized testing of sites you own. Linked Sources are citations for verification - not copied articles. Ads are not served on this page.

A Subdomain Takeover occurs when a domain's DNS configuration includes a record (typically a CNAME, ALIAS, or MX record) pointing to a third-party cloud provider service (such as GitHub Pages, AWS S3, Azure App Service, Heroku, or Shopify) that has been deprovisioned or abandoned. Because the DNS entry remains active (a 'dangling' record), any attacker who registers the abandoned resource name on the target cloud platform gains complete control over the subdomain. Attacker-controlled subdomains pose severe security risks: they bypass Same-Origin Policy cookie scope boundaries, harvest session tokens, hijack OAuth redirect flows, and facilitate convincing phishing campaigns under your primary brand name. This guide outlines automated detection, continuous attack surface management (ASM), and DNS deprovisioning controls backed by the [WeSecureX Surface Recon Engine](/surface), [Subdomain Finder](/tools/subdomain-finder), and [DNS Record Lookup](/tools/dns-record-lookup). Read our in-depth blog on [What is Attack Surface Management and Why Your Business Needs It](/blog/what-is-attack-surface-management-and-why-your-business-needs-it).

Quick Answer

Audit all subdomains using automated DNS enumeration tools, resolve CNAME chains to identify un-claimed third-party hostnames, remove dangling DNS records immediately upon service deprovisioning, and implement continuous Attack Surface Management scanning.

Key Takeaways
  • Subdomain takeovers occur when active DNS CNAMEs point to deleted cloud service accounts.
  • Attacker-controlled subdomains can hijack cookies and bypass OAuth redirect allowlists.
  • Always delete DNS CNAME records before shutting down third-party SaaS accounts.
  • Continuous Attack Surface Management (ASM) is required to detect dangling DNS records.
Visual Diagram · Dangling CNAME Subdomain Takeover Exploitation Sequence
1

1. Service Provisioning

Organization creates `blog.company.com` CNAME pointing to third-party host `company-blog.github.io`.

2

2. Incomplete Deprovisioning

Organization deletes GitHub Pages repository, but forgets to delete the `blog.company.com` CNAME record in DNS.

3

3. Resource Claiming

Attacker discovers 404 CNAME target and registers `company-blog.github.io` under their own GitHub account.

4

4. Brand Hijack & Cookie Theft

Attacker serves phishing content on `blog.company.com`, capturing parent domain session cookies.

ShareShare on XLinkedIn

1. Subdomain Takeover Mechanics & Cloud Fingerprints

WeSecureX Attack Surface Recon Engine discovering dangling DNS records and subdomains
WeSecureX Attack Surface Recon Engine discovering dangling DNS records and subdomainsWeSecureX Platform View

Subdomain takeovers occur when a DNS CNAME record points to an external cloud service that no longer has an active tenant account claimed for that hostname. In modern cloud ecosystems, development and marketing teams frequently commission specialized SaaS micro-sites, temporary landing pages, and documentation repos hosted on third-party multi-tenant providers. When campaigns end or code repositories are migrated, engineers often delete the underlying cloud resource while neglecting to notify the infrastructure administrator managing the authoritative DNS zone file.

Because the DNS pointer remains active, any external user who queries subdomain.example.com is redirected to the cloud provider's edge routing infrastructure. When the cloud provider discovers that no customer account claims that specific identifier, it returns a unique HTTP 404 error page. Threat actors scanning Certificate Transparency feeds and passive DNS databases monitor these fingerprints continuously. By simply creating a new free account on the third-party provider and registering the identical resource name, the adversary claims complete ownership of the corporate subdomain.

The security implications are severe: the attacker can provision free SSL certificates via Let's Encrypt, bypass Content Security Policy (CSP) allowlists across your corporate infrastructure, steal sensitive session cookies configured with Domain=.example.com, and intercept OAuth authorization codes. Audit your active CNAME records continuously with the WeSecureX Surface Monitor, test public records using the Subdomain Finder, and learn how attack surface exposure fuels cyber breaches in our Attack Surface Management Guide.

Cloud Service ProviderCNAME Target PatternTakeover Signature / ResponseExploitation ComplexityWeSecureX Verification
GitHub Pages*.github.ioThere isn't a GitHub Pages site here. (404)Low (Instant repo claim)Automated CNAME 404 crawl
AWS S3 Website*.s3-website-*.amazonaws.com<Code>NoSuchBucket</Code> (404)Low (Instant bucket creation)S3 bucket existence probe
Azure App Service*.azurewebsites.netThe resource you are looking for has been removed.Medium (Azure region matching)DNS NXDOMAIN check
Heroku App*.herokuapp.comNo such app (Heroku 404 page)Low (App name claim)HTTP response matching
Shopifyshops.myshopify.comSorry, this shop is currently unavailable.Low (Store creation)Shopify domain claim check

2. Automated Detection & ASM Workflows

WeSecureX Free Tools Directory showing DNS and Subdomain Finder utilities
WeSecureX Free Tools Directory showing DNS and Subdomain Finder utilitiesWeSecureX Platform View

Modern organizations operate hundreds or thousands of DNS records across complex multi-cloud accounts, making manual spreadsheet audits obsolete. Effective defense requires continuous automated Attack Surface Management (ASM) that systematically inspects DNS zones, verifies endpoint health, and flags unallocated cloud targets before malicious actors discover them.

The automated discovery workflow combines three rigorous engineering stages: First, comprehensive subdomain enumeration leverages passive Certificate Transparency (CT) log aggregation, forward DNS brute-forcing, and search engine telemetry to map all active hostnames. Second, DNS resolution recursively follows CNAME lookup chains (sub.example.com -> bucket.s3.amazonaws.com -> IP) to identify non-existent domains (NXDOMAIN) and dead hostnames. Third, active HTTP fingerprinting queries the target endpoint and evaluates HTTP response codes and HTML body signatures against an updated catalog of over 70 multi-tenant cloud provider error pages.

Whenever a dangling CNAME signature is confirmed, the system dispatches automated alerts to infrastructure teams, allowing them to delete the orphan DNS pointer immediately. Inspect your DNS records using the DNS Record Lookup Tool and test your infrastructure with our Website Vulnerability Scanner.

typescript
// Automated CNAME Health Verification Script in TypeScript / Node.js
import dns from 'dns/promises';

export async function verifyCnameHealth(subdomain: string) {
  try {
    const cnames = await dns.resolveCname(subdomain);
    if (!cnames || cnames.length === 0) return { status: 'SAFE_A_RECORD' };

    const targetCname = cnames[0];
    
    // Resolve A record of the target CNAME
    const ipAddresses = await dns.resolve4(targetCname).catch(() => []);
    
    if (ipAddresses.length === 0) {
      return {
        status: 'DANGLING_CNAME_RISK',
        subdomain,
        targetCname,
        recommendation: 'Verify cloud account ownership or delete DNS CNAME record immediately.',
      };
    }

    return { status: 'OK', targetCname };
  } catch (error) {
    return { status: 'DNS_RESOLVE_ERROR', error };
  }
}

3. Prevention & DNS Governance Best Practices

WeSecureX Website Scanner verifying perimeter security and DNS records
WeSecureX Website Scanner verifying perimeter security and DNS recordsWeSecureX Platform View

Eliminating subdomain takeovers requires treating DNS records with the exact same software change management and continuous integration rigor as production application code. Organizations must dismantle the silo between cloud infrastructure deprovisioning and DNS record maintenance.

First, adopt atomic Infrastructure as Code (IaC) using Terraform, Pulumi, or AWS CloudFormation. Configure resource lifecycle definitions such that cloud assets and their corresponding DNS pointers are created and destroyed in the same atomic deployment execution. If an engineer destroys an S3 bucket or Heroku app in code, the DNS pointer is expunged simultaneously, preventing dangling records from lingering in authoritative nameservers.

Second, enforce least-privilege DNS governance. Restrict zone file write permissions to authorized DevOps teams and mandate multi-factor authentication (MFA) on all domain registrar accounts. Third, scope sensitive session cookies strictly to explicit Fully Qualified Domain Names (Domain=app.example.com) rather than broad apex wildcards (Domain=.example.com), ensuring that an adversary who hijacks an auxiliary subdomain cannot extract parent domain credentials. Learn more about continuous attack surface hygiene in our Essential Cybersecurity Best Practices Guide and test your perimeter with the WeSecureX Website Scanner.

Apply it with WeSecureX

WeSecureX enumerates the subdomains tied to your verified domain and checks each dangling DNS record against its provider's fingerprint. A takeover risk is flagged when a CNAME points at an unclaimed service.

Dangling record it tests

text
blog.yoursite.com  CNAME  yoursite.github.io

Provider fingerprint on the host

http
HTTP/1.1 404 Not Found
There isn't a GitHub Pages site here.
What the finding shows

The finding names the subdomain, the CNAME target, and the provider's unclaimed-resource banner. Together they show the name can be claimed by someone else.

Fix: remove or reclaim the record

text
# Delete the stale CNAME, or re-create the resource at the provider
# so the host is owned again.

After the rescan

Rescan the attack surface. Once the record is removed or reclaimed, the dangling fingerprint is gone and the finding is cleared.

Checks that belong with this topic

  • Maintain a real-time asset inventory of all registered subdomains and DNS records.
  • Automate daily DNS resolution scans to flag unresolved CNAME targets.
  • Integrate DNS record deletion into cloud infrastructure teardown pipelines.
  • Scope sensitive session cookies strictly to explicit subdomains.
  • Monitor Certificate Transparency logs for unrecognized subdomain SSL certs.
  • Audit attack surface health in the [WeSecureX Surface Dashboard](/surface).

Actionable Checklist

WeSecureX Platform · Scanner Engine

Automated Vulnerability Scanner

Launch targeted or full-domain security audits to detect OWASP Top 10 vulnerabilities automatically.

Includes: OWASP Top 10 automated test suites · Real-time severity scoring (CVSS v3.1) · Instant remediation code snippets

Frequently Asked Questions

A dangling DNS record is an active CNAME or A record that points to a cloud resource or IP address that is no longer allocated to your organization.

Yes. If session cookies are set with `Domain=.example.com`, any sub-domain (like `hijacked.example.com`) can read those cookies in user browsers.

If an OAuth provider allows wildcard redirect URIs (e.g., `https://*.example.com/oauth/callback`), an attacker who takes over `blog.example.com` can steal authorization codes.

Because the DNS CNAME routes visitor traffic directly to the attacker's cloud account, completely bypassing your organization's WAF or origin servers.

Use the [WeSecureX Surface Monitor](/surface) and [Subdomain Finder](/tools/subdomain-finder) to run automated DNS CNAME resolution and fingerprint matching across your domain portfolio.

Authoritative Sources & References

  • OWASP - Subdomain Takeover Vulnerability AdvisoryOWASP (official)
    View Source

Continue exploring related technical architecture and defensive guides

Security Research & Engineering Articles

All articles