1
1
---
2
+ reviewed : 2024-02-07
2
3
severity : Important
3
4
pillar : Security
4
- category : Design
5
+ category : SE:06 Network controls
5
6
resource : Azure Kubernetes Service
6
7
online version : https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.AKS.AuthorizedIPs/
7
8
---
@@ -20,30 +21,184 @@ Access to the API server is required by various cluster functions as well as all
20
21
All activities performed against the cluster require authorization.
21
22
To improve cluster security, the API server can be restricted to a limited set of IP address ranges.
22
23
23
- Restricting authorized IP addresses for the API server as the following limitations:
24
+ Restricting authorized IP addresses for the API server has the following limitations:
24
25
25
26
- Requires AKS clusters configured with a Standard Load Balancer SKU.
26
27
- This feature is not compatible with clusters that use Public IP per Node.
28
+ - This feature is not compatible with AKS private clusters.
27
29
28
- When configuring this feature you must specify the IP address ranges that will be authorized.
30
+ When configuring this feature, you must specify the IP address ranges that will be authorized.
29
31
To allow only the outbound public IP of the Standard SKU load balancer, use ` 0.0.0.0/32 ` .
30
32
33
+ You should add these ranges to the allow list:
34
+
35
+ - Include output IP addresses for cluster nodes
36
+ - Any range where administration will connect to the API server, including CI/CD systems, monitoring, and management systems.
37
+
31
38
## RECOMMENDATION
32
39
33
40
Consider restricting network traffic to the API server endpoints to trusted IP addresses.
34
- Include output IP addresses for cluster nodes and any range where administration will occur from.
35
41
36
42
## EXAMPLES
37
43
44
+ ### Configure with Azure template
45
+
46
+ To deploy clusters that pass this rule:
47
+
48
+ - Set the ` properties.apiServerAccessProfile.authorizedIPRanges ` property to a list of authorized IP ranges.
49
+
50
+ For example:
51
+
52
+ ``` json
53
+ {
54
+ "type" : " Microsoft.ContainerService/managedClusters" ,
55
+ "apiVersion" : " 2023-11-01" ,
56
+ "name" : " [parameters('name')]" ,
57
+ "location" : " [parameters('location')]" ,
58
+ "identity" : {
59
+ "type" : " UserAssigned" ,
60
+ "userAssignedIdentities" : {
61
+ "[format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')))]" : {}
62
+ }
63
+ },
64
+ "properties" : {
65
+ "kubernetesVersion" : " [parameters('kubernetesVersion')]" ,
66
+ "disableLocalAccounts" : true ,
67
+ "enableRBAC" : true ,
68
+ "dnsPrefix" : " [parameters('dnsPrefix')]" ,
69
+ "agentPoolProfiles" : " [variables('allPools')]" ,
70
+ "aadProfile" : {
71
+ "managed" : true ,
72
+ "enableAzureRBAC" : true ,
73
+ "adminGroupObjectIDs" : " [parameters('clusterAdmins')]" ,
74
+ "tenantID" : " [subscription().tenantId]"
75
+ },
76
+ "networkProfile" : {
77
+ "networkPlugin" : " azure" ,
78
+ "networkPolicy" : " azure" ,
79
+ "loadBalancerSku" : " standard" ,
80
+ "serviceCidr" : " [variables('serviceCidr')]" ,
81
+ "dnsServiceIP" : " [variables('dnsServiceIP')]"
82
+ },
83
+ "apiServerAccessProfile" : {
84
+ "authorizedIPRanges" : [
85
+ " 0.0.0.0/32"
86
+ ]
87
+ },
88
+ "autoUpgradeProfile" : {
89
+ "upgradeChannel" : " stable"
90
+ },
91
+ "oidcIssuerProfile" : {
92
+ "enabled" : true
93
+ },
94
+ "addonProfiles" : {
95
+ "azurepolicy" : {
96
+ "enabled" : true
97
+ },
98
+ "omsagent" : {
99
+ "enabled" : true ,
100
+ "config" : {
101
+ "logAnalyticsWorkspaceResourceID" : " [parameters('workspaceId')]"
102
+ }
103
+ },
104
+ "azureKeyvaultSecretsProvider" : {
105
+ "enabled" : true ,
106
+ "config" : {
107
+ "enableSecretRotation" : " true"
108
+ }
109
+ }
110
+ }
111
+ },
112
+ "dependsOn" : [
113
+ " [resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]"
114
+ ]
115
+ }
116
+ ```
117
+
118
+ ### Configure with Bicep
119
+
120
+ To deploy resource that pass this rule:
121
+
122
+ - Set the ` properties.apiServerAccessProfile.authorizedIPRanges ` property to a list of authorized IP ranges.
123
+
124
+ For example:
125
+
126
+ ``` bicep
127
+ resource cluster 'Microsoft.ContainerService/managedClusters@2023-11-01' = {
128
+ location: location
129
+ name: name
130
+ identity: {
131
+ type: 'UserAssigned'
132
+ userAssignedIdentities: {
133
+ '${identity.id}': {}
134
+ }
135
+ }
136
+ properties: {
137
+ kubernetesVersion: kubernetesVersion
138
+ disableLocalAccounts: true
139
+ enableRBAC: true
140
+ dnsPrefix: dnsPrefix
141
+ agentPoolProfiles: allPools
142
+ aadProfile: {
143
+ managed: true
144
+ enableAzureRBAC: true
145
+ adminGroupObjectIDs: clusterAdmins
146
+ tenantID: subscription().tenantId
147
+ }
148
+ networkProfile: {
149
+ networkPlugin: 'azure'
150
+ networkPolicy: 'azure'
151
+ loadBalancerSku: 'standard'
152
+ serviceCidr: serviceCidr
153
+ dnsServiceIP: dnsServiceIP
154
+ }
155
+ apiServerAccessProfile: {
156
+ authorizedIPRanges: [
157
+ '0.0.0.0/32'
158
+ ]
159
+ }
160
+ autoUpgradeProfile: {
161
+ upgradeChannel: 'stable'
162
+ }
163
+ oidcIssuerProfile: {
164
+ enabled: true
165
+ }
166
+ addonProfiles: {
167
+ azurepolicy: {
168
+ enabled: true
169
+ }
170
+ omsagent: {
171
+ enabled: true
172
+ config: {
173
+ logAnalyticsWorkspaceResourceID: workspaceId
174
+ }
175
+ }
176
+ azureKeyvaultSecretsProvider: {
177
+ enabled: true
178
+ config: {
179
+ enableSecretRotation: 'true'
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ ```
186
+
38
187
### Configure with Azure CLI
39
188
40
189
``` bash
41
190
az aks update -n ' <name>' -g ' <resource_group>' --api-server-authorized-ip-ranges ' 0.0.0.0/32'
42
191
```
43
192
193
+ ### Configure with Azure PowerShell
194
+
195
+ ``` powershell
196
+ Set-AzAksCluster -Name '<name>' -ResourceGroupName '<resource_group>' -ApiServerAccessAuthorizedIpRange '0.0.0.0/32'
197
+ ```
198
+
44
199
## LINKS
45
200
46
- - [ Network security ] ( https://learn.microsoft.com/azure/architecture/framework/ security/design-network )
47
- - [ Secure access to the API server using authorized IP address ranges in Azure Kubernetes Service (AKS)] ( https://docs .microsoft.com/azure/aks/api-server-authorized-ip-ranges )
48
- - [ Best practices for cluster security and upgrades in Azure Kubernetes Service (AKS)] ( https://docs .microsoft.com/azure/aks/operator-best-practices-cluster-security#secure-access-to-the-api-server-and-cluster-nodes )
49
- - [ Azure deployment reference] ( https://docs .microsoft.com/azure/templates/microsoft.containerservice/managedclusters )
201
+ - [ SE:06 Network controls ] ( https://learn.microsoft.com/azure/well-architected/ security/networking )
202
+ - [ Secure access to the API server using authorized IP address ranges in Azure Kubernetes Service (AKS)] ( https://learn .microsoft.com/azure/aks/api-server-authorized-ip-ranges )
203
+ - [ Best practices for cluster security and upgrades in Azure Kubernetes Service (AKS)] ( https://learn .microsoft.com/azure/aks/operator-best-practices-cluster-security#secure-access-to-the-api-server-and-cluster-nodes )
204
+ - [ Azure deployment reference] ( https://learn .microsoft.com/azure/templates/microsoft.containerservice/managedclusters )
0 commit comments