Subdomain takeover: 12 Ways to Prevent this Attack

By Eyal Katz February 20, 2025

Subdomain takeovers don’t happen because attackers are geniuses. They happen because DNS records get messy. It’s not exactly an exciting gig to track old services or clean up unused subdomains, but ignoring it creates a security hole you can’t afford.

Microsoft discovered over 670 vulnerable subdomains in a single audit. On a larger scale, 21% of DNS records out there lead to unresolved content, and 63% of those throw ‘404 not found’ errors. To exploit this, attackers just need you to forget.

This guide cuts straight to the point: what subdomain takeovers are, why they happen, and the steps you can take to stop them. No fluff, just practical advice you can act on right away.

What, When, Where, and How: Key Questions About Subdomain Takeovers

Preventing subdomain takeovers requires understanding the technical nuances behind them. These attacks typically arise from dangling DNS records, service mismanagement, or gaps in decommissioning workflows. By examining the ‘what,’ ‘when,’ and ‘where,’ you can identify the exact circumstances that lead to vulnerabilities and how attackers exploit them.

Here’s the breakdown. 

What is a Subdomain Takeover?

A subdomain takeover occurs when an attacker gains control of a subdomain due to misconfigured or neglected DNS entries. Forgotten subdomains can become entry points for attackers. 

When is a Subdomain Vulnerable?

Subdomains are vulnerable when DNS entries point to decommissioned services or expired resources. For example, if your team retires a project hosted on Amazon S3 but the DNS record still points to a non-existent bucket, attackers can claim and exploit the bucket name (you don’t want that).

Where do Subdomain Takeovers Typically Happen?

Environments using multiple cloud services and third-party integrations are at higher risk. Complex configurations can lead to overlooked domains, creating opportunities for unauthorized access.

How do Attackers Exploit Subdomains?

Attackers target dangling DNS records, which are entries pointing to non-existent services. They use DNS scanning tools to find these vulnerabilities and can quickly register the expired service or set up a server to intercept traffic.

How Can You Detect Vulnerabilities?

Detecting vulnerabilities is all about staying alert. Regular DNS audits are a good start, but using automated tools and platforms like SpectralOps can make the process more manageable. Continuous monitoring systems are essential—they’ll alert you to any suspicious DNS changes as they happen.

How to detect vulnerabilities 

12 Ways to Prevent Subdomain Takeovers

Knowing the risks associated with subdomain takeovers is the first step; the real work begins when implementing countermeasures. Let’s review 12 practical strategies for protecting your infrastructure.

1. Regularly Audit DNS Records

You don’t want a situation where your developer team spins up a temporary subdomain for testing and then forgets about it after the project ends. Regular DNS audits can prevent such oversights.

Here’s what you can do:

  1. Catalog all DNS records, past and present, for a complete view.
  2. Use automation to monitor for discrepancies and automate audits, reducing manual work.
  3. Configure real-time alerts for unauthorized changes.
  4. Conduct quarterly audits or significant updates to catch risks early.
DNS Security Management Process

2. Remove Unused Subdomains

When decommissioning an application, it’s easy to overlook the associated subdomain, mainly when focused on future projects. To prevent exploitation (e.g., unauthorized claims by attackers, phishing schemes, or hosting malicious content), develop a clear protocol to evaluate each subdomain’s necessity and promptly remove unnecessary items to mitigate risks.

3. Monitor DNS Changes in Real-Time

Real-time monitoring of DNS changes, including updates to IP addresses, CNAME records, and MX records, is crucial to prevent unauthorized access and disruptions. You don’t want unnoticed DNS changes to expose vulnerabilities. Here’s how to stay secure:

  • Leverage for immediate alerts on unauthorized DNS modifications.
  • Configure notifications for key updates with platforms like Cloudflare’s DNS Analytics or Nagios.
  • Regularly analyze logs using advanced log management tools.

4. Avoid Using Wildcard DNS Records

Your team might set up a wildcard DNS record for convenience, but this can expose your domain to risks over time. Wildcard records route all subdomain queries to one IP, creating a broad entry for unauthorized access.

To prevent this:

  • Assign unique records to each subdomain for precise control and monitoring.
  • Lower the risk of unauthorized claims by avoiding wildcard records.
  • Implement specific records throughout your DNS to improve security.
  • Review and replace wildcard records with specific entries in your next DNS update to ensure thorough monitoring.

5. Use DNS Ownership Verification

You’re integrating a new service with your subdomain, and the provider asks you to verify domain ownership.

Here’s how this verification prevents unauthorized claims:

  1. Receive Verification Details: Obtain a unique TXT record from the provider as a verification token.
  2. Add the TXT Record: Access your DNS settings and place the token to establish ownership.
  3. Complete Verification: The provider confirms ownership by checking the TXT record, ensuring only authorized changes.
  4. Regular Updates: Update these records after personnel changes or infrastructure updates to maintain security.
DNS Ownership Verification Process

6. Conduct External Vulnerability Scans

Preparing to launch a major update to your infrastructure means addressing any hidden vulnerabilities. External vulnerability scans help identify dangling DNS records or misconfigurations.

Tools like Spectral analyze your network to find inactive DNS records and configuration errors. These scans provide a critical external perspective, revealing weaknesses that might be overlooked internally and highlighting areas that need attention.

7. Implement Strong Asset Management Practices

As you expand your tech stack with new third-party services, it’s easy to lose track of the subdomains associated with them. Use identity and access management tools to monitor all subdomains and third-party services, keeping your digital inventory complete and current. Implementing robust attack surface management solutions can further enhance your ability to identify and mitigate potential vulnerabilities. Adopting a Minimum Viable Security (MVS) approach can streamline this process, ensuring that security measures are implemented efficiently without overburdening development teams. This practice maintains a clear picture of your assets.

Schedule regular updates and conduct periodic reviews, especially when adding new services or retiring old ones. Organizing your inventory reduces risks and ensures that every subdomain is monitored.

8. Automate Subdomain Management

Your team is deploying multiple updates across various projects, and manually tracking DNS changes becomes overwhelming. Automation can make this process more manageable. Utilizing top security automation tools can streamline subdomain management and reduce the risk of human error. 

Here’s how:

  • Use tools like SpectralOps to track subdomain changes and detect vulnerabilities.
  • Automate DNS updates and monitoring to maintain oversight and free your team for strategic work.
  • Rely on automation to keep your systems secure and compliant amid frequent changes.
  • Leveraging durable workflows can also help create reliable, long-running automation tasks for subdomain management. 

9. Conduct Regular Security Training for Teams

Have you noticed some team members aren’t current on subdomain threats during a security audit? Regular training can fix this. Keep your team informed about current threats and best practices. Focus on identifying vulnerabilities, incident response, and preventive measures.

Create an ongoing learning environment to boost your team’s confidence in protecting digital assets. This strategy reduces errors and ensures your team is well-prepared to face new threats.

10. Perform Penetration Testing on Subdomains

After a significant infrastructure update, you might worry about unnoticed security gaps. Engaging professional testers to simulate real-world attacks on your subdomains is a good idea. This process helps identify weaknesses that regular audits might miss.

Conduct these tests regularly, especially after significant changes, to proactively detect vulnerabilities. This approach helps keep your defenses reliable and your subdomains safe from new threats.

11. Apply the Principle of Least Privilege for DNS Access

When multiple team members have broad access to DNS settings, the risk of unauthorized changes increases. To address this concern, apply the principle of least privilege:

  • Provide DNS access only to those who need it for their specific roles, limiting potential entry points for attackers. Implementing role-based access control (RBAC) in your SaaS applications can enhance security by ensuring users have appropriate access levels.
  • Adopting a Zero Trust Architecture further enforces strict access controls, ensuring no entity is inherently trusted.
  • Conduct periodic audits to ensure access levels remain appropriate and aligned with current responsibilities.
  • Use role-based controls to manage permissions to grant only necessary access.

12. Establish Clear Decommissioning Procedures

Your team is wrapping up a project that involves several temporary subdomains. Without a clear plan, these subdomains might linger, posing security risks. To prevent this, establish a step-by-step decommissioning process:

  1. Keep a detailed list of the project’s subdomains and DNS records.
  2. Identify and document any dependencies that decommissioning might affect.
  3. Remove all associated DNS records once a service is discontinued to prevent dangling entries.
  4. Embed decommissioning protocols into your project management workflows to maintain consistency.
Preventing Security Risks from Temporary Subdomains

Preventing Security Risks from Temporary Subdomains

What’s the Way Forward? Start Now to Secure Your Subdomains

It’s time you take decisive action to protect your subdomains—don’t wait until it’s too late. You might be wondering, “Where can I start?” We’ve shared 12 actionable ways to get you going. There are plenty of tools available online to make the process even easier. SpectralOps is one of them, and you can easily integrate it into your systems. You don’t need a PhD in cybersecurity to get started; it’s so straightforward that if you’re quick, you might be up and running in just three minutes. See precisely how SpectralOps can fit into your security strategy by taking a closer look and starting with a free account today.

Related articles

top 12 open source security solutions

Top 12 Open Source Code Security Tools

Open source software is everywhere. From your server to your fitness band. And it’s only becoming more common as over 90% of developers acknowledge using open

top 10 java vulnerabilities

Top 10 Most Common Java Vulnerabilities You Need to Prevent

It’s easy to think that our code is secure. Vulnerabilities or potential exploits are often the things we think about last. Most of the time, our

6 steps to a data breach response plan

6 Steps to Developing a Data Breach Response Plan

Experiencing a data breach is never pleasant. Just ask any of the hundreds of businesses that suffered a data breach in the past year, exposing billions

Stop leaks at the source!