Azure Introduction
Azure Pricing
Azure Threats
Unrestricted DNS Access
More Info:
Ensure that no network security groups allow unrestricted inbound access on TCP and UDP port 53
Risk Level
High
Address
Security
Compliance Standards
HIPAA, HITRUST, GDPR, SOC2, NISTCSF, PCIDSS, FedRAMP
Triage and Remediation
Remediation
To remediate the unrestricted DNS access issue in Azure, please follow the below steps:
Step 1: Login to the Azure portal (https://portal.azure.com/) using your credentials.
Step 2: In the left-hand side menu, click on the “Networking” option.
Step 3: Under the “Networking” menu, click on the “DNS zones” option.
Step 4: Select the DNS zone that you want to restrict access to.
Step 5: Under the “Settings” menu, click on the “Access control (IAM)” option.
Step 6: Click on the “Add” button to add a new role assignment.
Step 7: In the “Add role assignment” window, select the “Contributor” role from the “Role” dropdown menu.
Step 8: In the “Assign access to” section, select “User, group, or service principal” from the dropdown menu.
Step 9: In the “Select” field, enter the name of the user, group, or service principal that you want to restrict access to.
Step 10: Click on the “Save” button to save the changes.
By following the above steps, you can restrict access to the DNS zone and remediate the unrestricted DNS access issue in Azure.
To remediate Unrestricted DNS Access in AZURE using AZURE CLI, follow these steps:
- Open the AZURE CLI and login to your AZURE account.
- Run the following command to list all the virtual networks in your subscription:
az network vnet list
- Identify the virtual network that has unrestricted DNS access.
- Run the following command to update the virtual network and restrict DNS access:
Replace
az network vnet update --name <virtual_network_name> --resource-group <resource_group_name> --dns-servers ""
<virtual_network_name>
with the name of the virtual network that has unrestricted DNS access and<resource_group_name>
with the name of the resource group that contains the virtual network. - After running the command, verify that the DNS servers are restricted by running the following command:
This command should return an empty array, which means that DNS access is restricted.
az network vnet show --name <virtual_network_name> --resource-group <resource_group_name> --query 'dnsServers'
By following these steps, you can remediate Unrestricted DNS Access in AZURE using AZURE CLI.
To remediate unrestricted DNS access in Azure using Python, you can use the Azure SDK for Python. Here are the steps:
- Install the Azure SDK for Python using pip:
pip install azure-mgmt-dns
- Import the necessary modules:
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.dns import DnsManagementClient
- Authenticate using Service Principal credentials:
credentials = ServicePrincipalCredentials(
client_id='<client-id>',
secret='<client-secret>',
tenant='<tenant-id>'
)
Replace the <client-id>
, <client-secret>
, and <tenant-id>
with your own values.
- Create a DNS management client:
dns_client = DnsManagementClient(credentials, '<subscription-id>')
Replace <subscription-id>
with your own subscription ID.
- Get the DNS zone that needs to be remediated:
zone_name = '<zone-name>'
resource_group_name = '<resource-group-name>'
zone = dns_client.zones.get(resource_group_name, zone_name)
Replace <zone-name>
and <resource-group-name>
with your own values.
- Remove any records that allow unrestricted access:
for record in zone.records:
if record.a_records:
for a_record in record.a_records:
if a_record.ipv4_address == '0.0.0.0':
zone.records.remove(record)
if record.aaaa_records:
for aaaa_record in record.aaaa_records:
if aaaa_record.ipv6_address == '::':
zone.records.remove(record)
This code loops through all the records in the zone and removes any A or AAAA records that allow unrestricted access.
- Update the DNS zone:
dns_client.zones.create_or_update(resource_group_name, zone_name, zone)
This code updates the DNS zone with the changes made in step 6.
That’s it! This code should remediate unrestricted DNS access in Azure using Python.