You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Prevent dangling DNS entries and avoid subdomain takeover
20
20
21
21
This article describes the common security threat of subdomain takeover and the steps you can take to mitigate against it.
22
22
23
-
24
23
## What is a subdomain takeover?
25
24
26
-
Subdomain takeovers are a common, high-severity threat for organizations that regularly create, and delete many resources. A subdomain takeover can occur when you have a [DNS record](../../dns/dns-zones-records.md#dns-records) that points to a deprovisioned Azure resource. Such DNS records are also known as "dangling DNS" entries. CNAME records are especially vulnerable to this threat. Subdomain takeovers enable malicious actors to redirect traffic intended for an organization’s domain to a site performing malicious activity.
25
+
Subdomain takeovers are a common, high-severity threat for organizations that regularly create, and delete many resources. A subdomain takeover can occur when you have a [DNS record](../../dns/dns-zones-records.md#dns-records) that points to a deprovisioned Azure resource. Such DNS records are also known as "dangling DNS" entries. CNAME records are especially vulnerable to this threat. Subdomain takeovers enable malicious actors to redirect traffic intended for an organization's domain to a site performing malicious activity.
27
26
28
27
A common scenario for a subdomain takeover:
29
28
@@ -35,29 +34,25 @@ A common scenario for a subdomain takeover:
35
34
36
35
1.**DEPROVISIONING:**
37
36
38
-
1. The Azure resource is deprovisioned or deleted after it is no longer needed.
39
-
40
-
At this point, the CNAME record `greatapp.contoso.com`*should* be removed from your DNS zone. If the CNAME record isn't removed, it's advertised as an active domain but doesn't route traffic to an active Azure resource. This is the definition of a “dangling” DNS record.
37
+
1. The Azure resource is deprovisioned or deleted after it is no longer needed.
38
+
39
+
At this point, the CNAME record `greatapp.contoso.com`*should* be removed from your DNS zone. If the CNAME record isn't removed, it's advertised as an active domain but doesn't route traffic to an active Azure resource. This is the definition of a "dangling" DNS record.
41
40
42
-
1. The dangling subdomain, `greatapp.contoso.com`, is now vulnerable and can be taken over by being assigned to another Azure subscription’s resource.
41
+
1. The dangling subdomain, `greatapp.contoso.com`, is now vulnerable and can be taken over by being assigned to another Azure subscription's resource.
43
42
44
43
1.**TAKEOVER:**
45
44
46
45
1. Using commonly available methods and tools, a threat actor discovers the dangling subdomain.
47
46
48
47
1. The threat actor provisions an Azure resource with the same FQDN of the resource you previously controlled. In this example, `app-contogreat-dev-001.azurewebsites.net`.
49
48
50
-
1. Traffic being sent to the subdomain `greatapp.contoso.com` is now routed to the malicious actor’s resource where they control the content.
51
-
52
-
49
+
1. Traffic being sent to the subdomain `greatapp.contoso.com` is now routed to the malicious actor's resource where they control the content.
53
50
54
51

55
52
56
-
57
-
58
53
## The risks of subdomain takeover
59
54
60
-
When a DNS record points to a resource that isn't available, the record itself should have been removed from your DNS zone. If it hasn't been deleted, it's a “dangling DNS” record and creates the possibility for subdomain takeover.
55
+
When a DNS record points to a resource that isn't available, the record itself should have been removed from your DNS zone. If it hasn't been deleted, it's a "dangling DNS" record and creates the possibility for subdomain takeover.
61
56
62
57
Dangling DNS entries make it possible for threat actors to take control of the associated DNS name to host a malicious website or service. Malicious pages and services on an organization's subdomain might result in:
63
58
@@ -69,8 +64,6 @@ Dangling DNS entries make it possible for threat actors to take control of the a
69
64
70
65
-**Further risks** - Malicious sites might be used to escalate into other classic attacks such as XSS, CSRF, CORS bypass, and more.
71
66
72
-
73
-
74
67
## Identify dangling DNS entries
75
68
76
69
To identify DNS entries within your organization that might be dangling, use Microsoft's GitHub-hosted PowerShell tools ["Get-DanglingDnsRecords"](https://aka.ms/DanglingDNSDomains).
@@ -94,20 +87,17 @@ The tool supports the Azure resources listed in the following table. The tool ex
94
87
| Azure App Service | microsoft.web/sites | properties.defaultHostName |`abc.azurewebsites.net`|
- at least reader level access to the Azure subscriptions
104
95
- read access to Azure resource graph
105
96
106
-
If you're a global administrator of your organization’s tenant, elevate your account to have access to all of your organization’s subscription using the guidance in [Elevate access to manage all Azure subscriptions and management groups](../../role-based-access-control/elevate-access-global-admin.md).
107
-
97
+
If you're a global administrator of your organization's tenant, elevate your account to have access to all of your organization's subscription using the guidance in [Elevate access to manage all Azure subscriptions and management groups](../../role-based-access-control/elevate-access-global-admin.md).
108
98
109
99
> [!TIP]
110
-
> Azure Resource Graph has throttling and paging limits that you should consider if you have a large Azure environment.
100
+
> Azure Resource Graph has throttling and paging limits that you should consider if you have a large Azure environment.
111
101
>
112
102
> [Learn more about working with large Azure resource data sets](../../governance/resource-graph/concepts/work-with-data.md).
113
103
>
@@ -117,7 +107,7 @@ If you're a global administrator of your organization’s tenant, elevate your a
117
107
118
108
Learn more about the PowerShell script, **Get-DanglingDnsRecords.ps1**, and download it from GitHub: https://aka.ms/Get-DanglingDnsRecords.
119
109
120
-
## Remediate dangling DNS entries
110
+
## Remediate dangling DNS entries
121
111
122
112
Review your DNS zones and identify CNAME records that are dangling or have been taken over. If subdomains are found to be dangling or have been taken over, remove the vulnerable subdomains and mitigate the risks with the following steps:
123
113
@@ -127,28 +117,27 @@ Review your DNS zones and identify CNAME records that are dangling or have been
127
117
128
118
1. Review your application code for references to specific subdomains and update any incorrect or outdated subdomain references.
129
119
130
-
1. Investigate whether any compromise has occurred and take action per your organization’s incident response procedures. Tips and best practices for investigating this issue can be found below.
120
+
1. Investigate whether any compromise has occurred and take action per your organization's incident response procedures. Tips and best practices for investigating this issue can be found below.
131
121
132
122
If your application logic is such that secrets such as OAuth credentials were sent to the dangling subdomain, or privacy-sensitive information was sent to the dangling subdomains, that data might have been exposed to third-parties.
133
123
134
124
1. Understand why the CNAME record was not removed from your DNS zone when the resource was deprovisioned and take steps to ensure that DNS records are updated appropriately when Azure resources are deprovisioned in the future.
135
125
136
-
137
126
## Prevent dangling DNS entries
138
127
139
128
Ensuring that your organization has implemented processes to prevent dangling DNS entries and the resulting subdomain takeovers is a crucial part of your security program.
140
129
141
-
Some Azure services offer features to aid in creating preventative measures and are detailed below. Other methods to prevent this issue must be established through your organization’s best practices or standard operating procedures.
130
+
Some Azure services offer features to aid in creating preventative measures and are detailed below. Other methods to prevent this issue must be established through your organization's best practices or standard operating procedures.
142
131
143
132
### Enable Microsoft Defender for App Service
144
133
145
-
Microsoft Defender for Cloud's integrated cloud workload protection platform (CWPP), Microsoft Defender for Cloud, offers a range of plans to protect your Azure, hybrid, and multi-cloud resources and workloads.
134
+
Microsoft Defender for Cloud's integrated cloud workload protection platform (CWPP)offers a range of plans to protect your Azure, hybrid, and multicloud resources and workloads.
146
135
147
136
The **Microsoft Defender for App Service** plan includes dangling DNS detection. With this plan enabled, you'll get security alerts if you decommission an App Service website but don't remove its custom domain from your DNS registrar.
148
137
149
138
Microsoft Defender for Cloud's dangling DNS protection is available whether your domains are managed with Azure DNS or an external domain registrar and applies to App Service on both Windows and Linux.
150
139
151
-
Learn more about this and other benefits of this Microsoft Defender plans in [Introduction to Microsoft Defender for App Service](../../security-center/defender-for-app-service-introduction.md).
140
+
Learn more about this and other benefits of this Microsoft Defender plans in [Introduction to Microsoft Defender for App Service](../../defender-for-cloud/defender-for-app-service-introduction.md).
152
141
153
142
### Use Azure DNS alias records
154
143
@@ -163,18 +152,14 @@ Despite the limited service offerings today, we recommend using alias records to
163
152
164
153
[Learn more about the capabilities of Azure DNS's alias records](../../dns/dns-alias.md#capabilities).
165
154
166
-
167
-
168
155
### Use Azure App Service's custom domain verification
169
156
170
-
When creating DNS entries for Azure App Service, create an asuid.{subdomain} TXT record with the Domain Verification ID. When such a TXT record exists, no other Azure Subscription can validate the Custom Domain that is, take it over.
157
+
When creating DNS entries for Azure App Service, create an asuid.{subdomain} TXT record with the Domain Verification ID. When such a TXT record exists, no other Azure Subscription can validate the Custom Domain that is, take it over.
171
158
172
159
These records don't prevent someone from creating the Azure App Service with the same name that's in your CNAME entry. Without the ability to prove ownership of the domain name, threat actors can't receive traffic or control the content.
173
160
174
161
[Learn more about how to map an existing custom DNS name to Azure App Service](../../app-service/app-service-web-tutorial-custom-domain.md).
175
162
176
-
177
-
178
163
### Build and automate processes to mitigate the threat
179
164
180
165
It's often up to developers and operations teams to run cleanup processes to avoid dangling DNS threats. The practices below will help ensure your organization avoids suffering from this threat.
@@ -196,33 +181,30 @@ It's often up to developers and operations teams to run cleanup processes to avo
196
181
197
182
- Maintain a service catalog of your Azure fully qualified domain name (FQDN) endpoints and the application owners. To build your service catalog, run the following Azure Resource Graph query script. This script projects the FQDN endpoint information of the resources you have access to and outputs them in a CSV file. If you have access to all the subscriptions for your tenant, the script considers all those subscriptions as shown in the following sample script. To limit the results to a specific set of subscriptions, edit the script as shown.
198
183
199
-
200
184
-**Create procedures for remediation:**
201
185
- When dangling DNS entries are found, your team needs to investigate whether any compromise has occurred.
202
186
- Investigate why the address wasn't rerouted when the resource was decommissioned.
203
187
- Delete the DNS record if it's no longer in use, or point it to the correct Azure resource (FQDN) owned by your organization.
204
188
205
-
206
189
### Clean up DNS pointers or Re-claim the DNS
207
190
208
-
Upon deletion of the classic cloud service resource, the corresponding DNS is reserved for 7 days. During the reservation period, re-use of the DNS will be forbidden EXCEPT for subscriptions belonging to the AAD tenant of the subscription originally owning the DNS. After the reservation expires, the DNS is free to be claimed by any subscription. By taking DNS reservations, the customer is afforded some time to either 1) clean up any associations/pointers to said DNS or 2) re-claim the DNS in Azure. The DNS name being reserved can be derived by appending the cloud service name to the DNS zone for that cloud.
191
+
Upon deletion of the classic cloud service resource, the corresponding DNS is reserved for 7 days. During the reservation period, re-use of the DNS will be forbidden EXCEPT for subscriptions belonging to the Azure AD tenant of the subscription originally owning the DNS. After the reservation expires, the DNS is free to be claimed by any subscription. By taking DNS reservations, the customer is afforded some time to either 1) clean up any associations/pointers to said DNS or 2) re-claim the DNS in Azure. The DNS name being reserved can be derived by appending the cloud service name to the DNS zone for that cloud.
209
192
210
-
Public - cloudapp.net
211
-
Mooncake - chinacloudapp.cn
212
-
Fairfax - usgovcloudapp.net
213
-
BlackForest - azurecloudapp.de
193
+
-Public - cloudapp.net
194
+
-Mooncake - chinacloudapp.cn
195
+
-Fairfax - usgovcloudapp.net
196
+
-BlackForest - azurecloudapp.de
214
197
215
-
i.e. a hosted service in Public named “test” would have DNS “test.cloudapp.net”
198
+
For example, a hosted service in Public named "test" would have DNS "test.cloudapp.net"
216
199
217
200
Example:
218
-
Subscription ‘A’ and subscription ‘B’ are the only subscriptions belonging to AAD tenant ‘AB’. Subscription ‘A’ contains a classic cloud service ‘test’ with DNS name ‘test.cloudapp.net’. Upon deletion of the cloud service, a reservation is taken on DNS name ‘test.cloudapp.net’. During the 7 day reservation period, only subscription ‘A’ or subscription ‘B’ will be able to claim the DNS name ‘test.cloudapp.net’ by creating a classic cloud service named ‘test’. No other subscriptions will be allowed to claim it. After the 7 days is up, any subscription in Azure can now claim ‘test.cloudapp.net’.
219
-
201
+
Subscription 'A' and subscription 'B' are the only subscriptions belonging to Azure AD tenant 'AB'. Subscription 'A' contains a classic cloud service 'test' with DNS name 'test.cloudapp.net'. Upon deletion of the cloud service, a reservation is taken on DNS name 'test.cloudapp.net'. During the 7 day reservation period, only subscription 'A' or subscription 'B' will be able to claim the DNS name 'test.cloudapp.net' by creating a classic cloud service named 'test'. No other subscriptions will be allowed to claim it. After the 7 days are up, any subscription in Azure can now claim 'test.cloudapp.net'.
220
202
221
203
## Next steps
222
204
223
205
To learn more about related services and Azure features you can use to defend against subdomain takeover, see the following pages.
224
206
225
-
-[Enable Microsoft Defender for App Service](../../security-center/defender-for-app-service-introduction.md) - to receive alerts when dangling DNS entries are detected
207
+
-[Enable Microsoft Defender for App Service](../../defender-for-cloud/enable-enhanced-security.md) - to receive alerts when dangling DNS entries are detected
226
208
227
209
-[Prevent dangling DNS records with Azure DNS](../../dns/dns-alias.md#prevent-dangling-dns-records)
0 commit comments