Azure / Azure-Network-Security

Resources for improving Customer Experience with Azure Network Security
MIT License
767 stars 294 forks source link

Error with the Get-DanglingDnsRecords script when DNS contains wild character *.abc.xyz.mno.net against multiple azure subscriptions #365

Open NavidKhan8 opened 2 months ago

NavidKhan8 commented 2 months ago

Describe the bug In clear words, please provide a concise description of the bug

We are using Microsoft recommended PowerShell module for identifying dangling DNS in Azure platform and it was working fine for last one year but from last month it's failing with below error message

Powershell module link reference : https://learn.microsoft.com/en-us/azure/security/fundamentals/subdomain-takeover#identify-dangling-dns-entries

Upon investigation found a bug with the module which was unable to handle the DNS entry point name if it has wild character for example *.abc.xyz.mno.net as an entry

It was due to using -match instead of -contains, below is code snippet found an issue

if ($item.FQDN -match "azurefd.net") {
                $count = (($AzResourcesHash.GetEnumerator() | Where { $item.FQDN **-match**  $_.key }) | Measure-Object).Count

I can fix this either changing from -match to -contains or asking users to delete wild character in DNS name but we have around 100s of DNSs so wouldn't able to control user on creating DNS name so it will be ideal to handle such scenario in the script

Reproduce Steps to reproduce the behavior: Install-Module -Name AzDanglingDomain -Scope CurrentUser Import-Module -Name AzDanglingDomain -Force Get-DanglingDnsRecords -FetchDnsRecordsFromAzureSubscription

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots/images to help explain your problem.

Environment- if applicable

Desktop (please complete the following information if applicable):

Logs- if applicable

Additional context Add any other context about the problem here. Opened a case with MS for the same and they have directed to open a GitHub issue so that internal team can review.

github-actions[bot] commented 2 months ago

Message that will be displayed on users' first issue

Sagarthore11 commented 2 months ago

Hello Team,

We are also facing the same problem. Can you please up us on it

Thanks

Sagarthore11 commented 2 months ago

Hello Experts,

Greetings for the day

Could you please help us on it

Thanks

shabaz-github commented 2 months ago

@abhijeetgaiha / @tanviohri - Please take a look into this issue.

Sagarthore11 commented 1 month ago

Hello @abhijeetgaiha , @tanviohri

Thank you for helping us it.

Could you pls help us with the status if there are any ?

chinmay0402 commented 1 month ago

Hey @Sagarthore11, we'll consider the suggested change after we've tested it out, since this adds handling for DNS entry types the script does not support currently.

Sagarthore11 commented 1 month ago

Hello @chinmay0402

Thank you so much for your response.

@NavidKhan8