63 lines
2.3 KiB
YAML
63 lines
2.3 KiB
YAML
id: azure-nsg-restricted-port-range
|
|
info:
|
|
name: Restricted Port Range in Azure NSGs
|
|
author: princechaddha
|
|
severity: medium
|
|
description: |
|
|
Ensure that Azure network security groups (NSGs) do not have ranges of ports configured to allow inbound traffic, which can expose associated virtual machines to Denial-of-Service (DoS) or brute-force attacks. Only specific ports required by your application should be open following cloud security best practices.
|
|
impact: |
|
|
Having a range of ports open can increase the vulnerability to DoS and brute-force attacks, compromising the security of your Azure virtual machine instances.
|
|
remediation: |
|
|
Modify the NSG rules to only allow inbound traffic on necessary ports specific to your application requirements. This practice minimizes potential attack vectors.
|
|
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 --output json --query '[*].{name:name, resourceGroup:resourceGroup}'
|
|
|
|
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'].{PortRange:destinationPortRanges, Rule: name, Priority: priority}"
|
|
|
|
matchers:
|
|
- type: word
|
|
words:
|
|
- "0-65535"
|
|
- "80-8080"
|
|
- "111-32800"
|
|
|
|
extractors:
|
|
- type: json
|
|
name: destinationPortRange
|
|
internal: true
|
|
json:
|
|
- '.[].destinationPortRange'
|
|
|
|
- type: dsl
|
|
dsl:
|
|
- 'nsg + " allows a range of ports " + destinationPortRange + " which may be vulnerable to attacks"'
|
|
# digest: 490a00463044021f21859c98924805e6bdd21c851b2a919a44e039851f63966c6521da18e78a54022100ab249a26f01c954b6fe266ef91cedd236f41441b864954ab208a2f1ead51e9e1:922c64590222798bb761d5b6d8e72950 |