A marketing campaign that ended, an abandoned staging site, an application moved to another host. The cloud resource was deleted, but the DNS record stayed. For an attacker, that forgotten subdomain can be enough to publish whatever they want at an address that carries your name.

Subdomain takeover in brief

Cause A DNS record points to a third-party resource that no longer exists
Condition The provider lets anyone create a resource with the same name again
Impact Arbitrary content served under your domain, cookie theft, convincing phishing
Effort for the attacker Low, often a free account with the provider
Fix Remove the DNS record, or reclaim the resource

How it happens

Take a realistic example. Your team launches a site for an event, hosted on Azure. It creates this subdomain:

event.example.ma.   CNAME   example-event.azurewebsites.net.

The event ends. Someone deletes the Azure app to cut the bill. Nobody thinks about DNS, which is handled by another team or an outside provider.

From then on, example-event.azurewebsites.net is a free name. An attacker creates an Azure app with that name, adds event.example.ma as a custom domain, and your DNS does the rest: visitors to event.example.ma land on their content.

Nothing was hacked in the usual sense. No flaw in your code, no stolen password. It is an inventory mistake.

What an attacker can do with it

The danger comes from the trust that browsers, your customers and your own applications place in your domain.

  • Phishing: a fake login page on event.example.ma is far more convincing than an unknown domain, and mail filters often let it through.
  • Session theft: if your session cookies are set for .example.ma, the browser also sends them to the taken-over subdomain, where the attacker can collect them.
  • Bypassing security rules: a CORS or CSP policy that trusts *.example.ma, or an overly broad OAuth redirect URL, now accepts a server the attacker controls.
  • Reputation damage: illegal or advertising content under your name, reported by your customers before you notice.

Good practice. Staging and campaign subdomains are the most exposed. They are created quickly, by different teams, and rarely removed cleanly.

The services most often involved

The risk depends on how each provider verifies domain ownership. Some have tightened their rules in recent years, others remain exploitable. The most common in our analyses:

Service Typical CNAME target Sign of a deleted resource
Azure App Service *.azurewebsites.net The name no longer resolves (NXDOMAIN)
AWS S3 *.s3.amazonaws.com "NoSuchBucket" error page
GitHub Pages *.github.io GitHub 404 page
Heroku *.herokuapp.com "No such app" page
SaaS platforms (shops, help desks, landing pages) Provider-specific name Page saying the site does not exist

An error message like these does not prove on its own that the subdomain can be taken over. You need to check, provider by provider, whether a third party can actually register the name.

How to check your subdomains

Start by listing your CNAME records. If you have access to your DNS zone, export it. Otherwise you can query a specific subdomain:

dig +short CNAME event.example.ma

Then check that the target still exists:

dig +short example-event.azurewebsites.net
curl -sI https://event.example.ma

A target that no longer answers, or returns the provider’s error page, deserves an immediate look.

The hard part is the inventory. A mid-sized company often has dozens of subdomains, some of them created by agencies or former contractors. Certificate Transparency logs and public DNS datasets often reveal names the internal team had forgotten. Attackers use exactly these sources.

Fix it and keep it from coming back

For a vulnerable subdomain:

  1. Remove the DNS record if it is no longer used. This is the safest fix.
  2. If the subdomain must stay, recreate the resource with the provider under your own account, then attach it properly.
  3. If a takeover may have happened, treat the domain’s cookies as exposed: force active sessions to log out.

To keep it from coming back:

  • reverse the decommissioning order: DNS first, then the resource;
  • keep an inventory of subdomains with an owner for each;
  • scope cookies to the subdomain that needs them rather than the whole domain;
  • watch for new subdomains and for CNAMEs that point to third-party services.

At HEXBOX, attack surface mapping flags subdomains that point to third-party services. A suspicious CNAME remains a signal until it is verified. During a test, we confirm whether the resource can really be taken over, without claiming it ourselves, then we verify the fix.

Check your subdomains with HEXBOX