id: azure-nsg-rdp-unrestricted info: name: Unrestricted RDP Access in Azure NSGs author: princechaddha severity: high description: | Ensure that Microsoft Azure network security groups (NSGs) do not allow unrestricted access on TCP port 3389, used for Remote Desktop Protocol (RDP), to prevent unauthorized remote access. impact: | Unrestricted RDP access can lead to unauthorized access and control over virtual machines, potentially resulting in data theft or malicious activities. remediation: | Configure NSG rules to restrict RDP access to only trusted IP addresses. Consider using VPNs or other secure methods for remote access. reference: - https://docs.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview tags: cloud,devops,azure,microsoft,nsg,azure-cloud-config flow: | code(1); for (let NsgData of iterate(template.nsgdata)) { NsgData = JSON.parse(NsgData) set("nsg", NsgData.name) set("resourcegroup", NsgData.resourceGroup) code(2) } self-contained: true code: - engine: - sh - bash source: | az network nsg list --query '[*].{name:name, resourceGroup:resourceGroup}' --output json extractors: - type: json name: nsgdata internal: true json: - '.[]' - engine: - sh - bash source: | az network nsg rule list --nsg-name $nsg --resource-group $resourcegroup --query "[?direction=='Inbound' && access=='Allow' && protocol=='TCP' && (destinationPortRange=='3389')]" matchers: - type: word words: - '"sourceAddressPrefix": "*"' - '"sourceAddressPrefix": "internet"' - '"sourceAddressPrefix": "any"' extractors: - type: dsl dsl: - 'nsg + " has unrestricted access on TCP port 3389"' # digest: 4a0a0047304502210084b9184c750d16417f2f77deb99cee5ab43ae68e8fbbfb9ecabe4769e1e424d402206344c52f682d71f9d528a2e3b7fbcfa5370ebd9eab6d30806bfcaa00dc7d5709:922c64590222798bb761d5b6d8e72950