---
title: "Remove DNS records you no longer use · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/secrets-and-configuration/dangling-dns
id: APS-68
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 828
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Remove DNS records you no longer use

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Secrets and configuration](https://agentwranglers.se/playbook/application-security/secrets-and-configuration.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-68
- Level: Recommended
- Chapter: [Secrets and configuration](https://agentwranglers.se/playbook/application-security/secrets-and-configuration.md)
- Rule: Delete every DNS record that points at a server, bucket or hosted service you no longer own, before you give that resource up.
- Check: For every CNAME and A record in the zone, the target resolves and serves your own content. No target answers NXDOMAIN or a provider page such as "no such bucket" or "there isn't a site here".
- How: Keep the DNS zone in version control, or export it each month. When you shut down a cloud app, bucket or landing page, remove its DNS record first. A record left pointing at a freed name lets anyone claim it and serve pages on your subdomain. The new owner can then read cookies set for your whole domain and phish your users.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Shell example

```sh
dig +short CNAME shop.example.com        # example-shop.hosting.example.net.
dig +short example-shop.hosting.example.net   # must resolve
curl -s https://shop.example.com/ | grep -i "no such\|isn't a site\|not found"   # must print nothing
```

## Sources

- [OWASP WSTG on subdomain takeover](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management/10-Subdomain_Takeover/)
- [Microsoft Learn on preventing dangling DNS entries](https://learn.microsoft.com/en-us/azure/security/fundamentals/subdomain-takeover)

## Related rules

- WEB-167 [Keep the domain name yours](https://agentwranglers.se/playbook/website/hosting-and-network/domain-renewal.md) in Website
- EML-12 [Lock down domains that never send mail](https://agentwranglers.se/playbook/email/sending-domain-and-authentication/no-mail-domains.md) in Email
- INF-35 [Keep DNS records in code](https://agentwranglers.se/playbook/infrastructure/networking-and-dns/dns-as-code.md) in Infrastructure and environments
- INF-54 [Delete resources that sit idle](https://agentwranglers.se/playbook/infrastructure/cost-and-ownership/delete-idle-resources.md) in Infrastructure and environments

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/application-security/secrets-and-configuration/dangling-dns">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Keep software current and quiet](https://agentwranglers.se/playbook/application-security/secrets-and-configuration/patch-and-hide-versions.md)
- [Secrets and configuration](https://agentwranglers.se/playbook/application-security/secrets-and-configuration.md)
