Subdomain hijacking is one of those security problems that sounds technical and rare until you realize how often it happens and how easily it can be avoided. In plain terms, subdomain hijacking occurs when an attacker claims control of a subdomain (like blog.example.com or assets.example.com) because the domain owner left a DNS record pointing to a third-party service that is no longer in use. That dangling DNS entry becomes a vulnerability — a free-for-all invitation for someone else to register the underlying resource and host malicious content under your trusted subdomain.
This post walks through what subdomain hijacking is, how it happens in real environments, why it matters, how to detect it, and practical steps you can take today to prevent and remediate it.
What is subdomain hijacking?
At its core, subdomain hijacking is the result of mismatched lifecycle management between DNS records and cloud or third-party services. You create a DNS record that points a subdomain to a service (often via a CNAME to a hosted platform, or an A record to an IP address). Later, the resource on the third-party platform gets deleted, expired, or reassigned — but the DNS entry in your domain’s DNS zone remains. If the platform allows anyone to claim that resource again (for example, provisioning a new site at the same hostname), an attacker can register it and serve content from your subdomain.
Common vectors include:
- CNAMEs pointing to cloud-hosted platforms that allow custom domains (GitHub Pages, Netlify, Heroku, AWS S3 website endpoints, Azure, Vercel, etc.).
- A records or ALIAS records pointing to IPs that become reassigned or are under control of shared hosting.
- Misconfigured CDN or asset-hosting subdomains.
- Forgotten or unused subdomains created during development or testing.
Why subdomain hijacking is dangerous
A hijacked subdomain carries the trust of your main domain. That trust is what makes these hijacks attractive to attackers:
Phishing and social engineering
An attacker can host a convincing landing page on a hijacked subdomain and use it to harvest credentials, perform phishing campaigns, or send emails that appear to come from a trusted source.
Content injection and SEO abuse
Attackers may host spammy pages or drive-by redirects that damage your SEO, cause search engines to penalize your domain, or embed malicious JavaScript into pages users assume are legitimate.
Token and cookie theft
If the subdomain shares cookies or allows cross-origin interactions with other parts of your site, an attacker could attempt to steal session tokens or manipulate client-side behavior.
Brand and reputation damage
Visitors seeing malicious or irrelevant content on one of your subdomains will trust the domain less. News travels fast, and a single exploit can harm customer confidence.
Supply chain and third-party trust risks
If your subdomain is used to host assets for other services (like JS libraries, images, or widgets consumed on other sites), you can affect downstream users, amplifying the damage.
How subdomain hijacks typically occur — a simplified scenario
- During development or a marketing campaign, someone creates a CNAME: promo.example.com → project.hosting-service.com.
- The campaign ends, the host resource (project.hosting-service.com) is deleted or the account lapses, but the DNS record promo.example.com remains unchanged.
- Because the hosting platform allows anyone to register a new project at project.hosting-service.com, an attacker signs up and claims it.
- The attacker configures the project to use promo.example.com and uploads malicious content.
- Now requests to promo.example.com resolve to an attacker-controlled site, but users and browsers see the subdomain as trusted under example.com.
Real-world examples and common platforms
Platforms commonly involved in these incidents are not necessarily insecure — the problem is largely operational: forgotten records and the permissive way many hosting platforms let new users bind custom domains. Examples include:
- GitHub Pages: a deleted repo previously configured for a custom domain can be recycled and assigned by others.
- Netlify and Vercel: project names or subdomain targets that are re-used can lead to hijacking if the DNS remains.
- AWS S3 static website endpoints or CloudFront distributions that are deleted but left as DNS targets.
- Heroku apps or other PaaS instances that are removed but referenced by a CNAME.
Detection techniques — how to find potential hijacks
Detecting subdomain hijacking involves checking for DNS records that resolve to services that are unclaimed or exhibit unexpected behavior.
- Inventory and scanning
Start by creating a full inventory of your DNS records. Export your zone file or use your DNS provider’s API. Look for CNAME targets, ALIAS, or A records pointing to third-party hosts. - Service-specific checks
Many hosting services return distinctive pages or HTTP status codes when a hostname is not claimed or points to an unconfigured project. For example:
- Some sites return an HTTP 404 with a message like “No site configured for this domain.”
- Others return a 200 OK with a page prompting the owner to claim the hostname.
Scripted checks (curl, wget, or HTTP libraries) can be used to probe each hostname and identify suspicious responses. Example:
curl -I https://promo.example.com
and examine the status code and server headers for signs of an unclaimed host.
- Passive DNS and reverse lookups
Use passive DNS services to see historical resolution. If a subdomain recently changed targets or is pointing at an unexpected IP range, flag it. - Automated scanners and security tools
There are open-source and commercial scanners that look for dangling CNAMEs and orphaned DNS records. Tools like dnsvalidator, subjack, or custom scripts using APIs of GitHub, Netlify, Heroku, and others can detect common vectors. - Manual inspection for wildcard or broad CNAMEs
Watch for wildcard CNAMEs or patterns like *.dev.example.com pointing to a generic host. Wildcards expand your attack surface dramatically.
Prevention: practical, low-friction steps that work
- Maintain a DNS inventory
The single most effective step is to know what you own. Keep a living inventory of all zones and records. Use DNS provider APIs to export records on a schedule and compare snapshots. - Clean up unused records
Establish a process for timely removal of DNS records when a project is completed. If a subdomain was used for a temporary campaign, remove it as part of the campaign close-out checklist. - Avoid long-lived CNAMEs to user-controlled third-party targets
Where possible, avoid long-term CNAMEs to services that allow anyone to claim projects. If you must use them, implement ownership verification steps and monitor the target for changes. - Use host platform protections
When you map a custom domain to a third-party host, configure HTTPS and custom domain ownership verification if the platform supports it. Many hosts require a verification file or DNS token proving ownership — use that. - Implement TLS and HSTS carefully
HTTPS alone won’t prevent hijacking, but misconfigured TLS can be abused. Consider HSTS for subdomains you control to reduce risk of downgrade attacks. However, be cautious: HSTS on wildcards can lock you into behavior that complicates legitimate migrations. - Apply CAA and DNSSEC where appropriate
Certificate Authority Authorization (CAA) records restrict which CAs can issue certificates for your domain. DNSSEC adds integrity to your DNS records and complicates tampering. Both are worthwhile layers of defense. - Monitor for host-specific unclaimed-domain signatures
Write scripts to periodically check the HTTP/HTTPS response pages of your subdomains, looking for platform-specific strings that indicate the hostname is unclaimed. If the platform’s default “no site configured” text appears, flag the record for immediate review. - Restrict who can change DNS
Limit DNS changes to a small, audited group. Use RBAC and logging on your DNS provider so changes are visible and reversible. Treat DNS like a critical asset, not a routine convenience. - Be careful with wildcard records and multi-tenant configurations
Wildcards like *.staging.example.com can be convenient but dangerous. They allow any subdomain to resolve, increasing the chance of an orphaned entry being abused. If you need wildcards, tightly control who can create hostnames that resolve under them.
Remediation: what to do if a subdomain is hijacked
- Immediately remove the dangling DNS entry
If you discover a hijacked subdomain, the fastest mitigation is to remove the DNS record so the hostname no longer resolves to the attacker’s host. - Reclaim or reconfigure the third-party resource
If the DNS points to a service you control but was misconfigured, re-create/claim the resource on the hosting provider and configure it properly. For example, create a placeholder page indicating maintenance. - Revoke any compromised credentials
If the attacker likely had access to credentials or API tokens, rotate them. Audit logs for suspicious activity. - Notify affected stakeholders
If the hijack may have exposed customers or inserted spam, inform affected users, partners, and any teams responsible for legal or compliance. - Monitor for downstream effects
Watch search engines and monitoring systems for backlinks, search indexing of malicious content, or abuse originating from the subdomain.
Tools and commands that help
- dig and nslookup to check DNS records:
dig CNAME promo.example.com +short
nslookup promo.example.com
- curl for probing HTTP responses and headers:
curl -sI https://promo.example.com
curl -s https://promo.example.com | head -n 40
- Passive DNS and security services (SecurityTrails, VirusTotal Passive DNS) for historical mappings.
- Automated scanners (subjack, dnsrecon, aquatone) and custom scripts to check for platform-specific strings.
Operational checklist for teams
- Inventory your zones and export DNS records weekly.
- Tag records with owner, purpose, and expiration date.
- Require DNS record removal as part of project decommissioning.
- Schedule automated probes for all CNAME/A records and flag unclaimed responses.
- Enable DNS change logging and require approvals for public-facing subdomains.
- Educate developers about the risk of creating temporary hostnames that outlive the project.
- Treat wildcard DNS records as high risk and review them quarterly.
Responsible disclosure and reporting
If you discover a vulnerable dangling CNAME on someone else’s domain, follow responsible disclosure practices. Don’t exploit the vulnerability. Instead:
- Contact the domain’s registrar or hosting provider.
- Use any “report abuse” or security contact email listed on the domain’s WHOIS.
- If you’re unsure how to reach the owner, some third-party platforms have reporting channels for custom domain abuse.
Responsible disclosure helps the internet become safer without exposing users to additional harm.
Alaso read: Exploring the Real Impact of Parasite SEO on Your Website’s Rankings
Final thoughts
Subdomain hijacking is fundamentally an operations problem: it’s about lifecycle misalignment between DNS and services. Left unchecked, it’s a simple but powerful attack surface that can be exploited for phishing, malware distribution, SEO manipulation, and reputation damage. The fix isn’t glamorous — it’s bookkeeping, automation, and a bit of discipline.
If you manage domains, treat DNS as a first-class security item. Maintain inventories, remove stale records, monitor responses for platform-specific indicators of unclaimed hosts, and tighten controls around who can change DNS. Those practical steps will significantly lower your risk profile and keep your brand and users safe.

