1
1
---
2
+ reviewed : 2024-07-23
2
3
severity : Important
3
4
pillar : Security
4
- category : Monitor
5
+ category : SE:10 Monitoring and threat detection
5
6
resource : Azure Kubernetes Service
6
7
online version : https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.AKS.AuditLogs/
7
8
---
@@ -14,15 +15,18 @@ AKS clusters should collect security-based audit logs to assess and monitor the
14
15
15
16
## DESCRIPTION
16
17
17
- To capture security-based audit logs from AKS clusters, the following diagnostic log categories should be enabled:
18
+ The Azure Kubernetes Service (AKS) service supports collection of security-based audit logs from clusters.
19
+ The following log categories are available:
18
20
19
- - ` kube-audit ` or ` kube-audit-admin ` , or both.
20
- - ` kube-audit ` - Contains all audit log data for every audit event, including get, list, create, update, delete, patch, and post.
21
- - ` kube-audit-admin ` - Is a subset of the ` kube-audit ` log category.
22
- ` kube-audit-admin ` reduces the number of logs significantly by excluding the get and list audit events from the log.
23
- - ` guard ` - Contains logs for Azure Active Directory (AAD) authorization integration.
24
- For managed Azure AD, this includes token in and user info out.
25
- For Azure RBAC, this includes access reviews in and out.
21
+ - ` kube-audit ` - Audit log data for every audit event including _ get_ , _ list_ , _ create_ , _ update_ , _ delete_ , _ patch_ , and _ post_ .
22
+ - ` kube-audit-admin ` - Is a subset of the ` kube-audit ` log category that excludes _ get_ and _ list_ audit events.
23
+ - ` guard ` - Contains logs for Entra ID and Azure RBAC events.
24
+
25
+ In other words, both ` kube-audit ` and ` kube-audit-admin ` contain the same data except ` kube-audit-admin ` does not contain _ get_ and _ list_ events.
26
+
27
+ For most configurations, consider enabling logging for ` kube-audit-admin ` and ` guard ` .
28
+ This configuration provides good coverage and significantly reduces the number of logs and overall cost for collecting and storing AKS audit events.
29
+ Enable ` kube-audit ` only when required.
26
30
27
31
## RECOMMENDATION
28
32
@@ -35,127 +39,87 @@ Consider configuring diagnostic settings to capture security-based audit logs fr
35
39
To deploy AKS clusters that pass this rule:
36
40
37
41
- Deploy a diagnostic settings sub-resource.
38
- - Enable logging for the ` kube-audit ` / ` kube-audit-admin ` and ` guard ` categories.
42
+ - Enable logging for ` kube-audit-admin ` (or ` kube-audit ` ) and ` guard ` log categories.
39
43
40
44
For example:
41
45
42
46
``` json
43
47
{
44
- "comments" : " Azure Kubernetes Cluster" ,
45
- "apiVersion" : " 2020-12-01" ,
46
- "dependsOn" : [
47
- " [resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]"
48
- ],
49
- "type" : " Microsoft.ContainerService/managedClusters" ,
50
- "location" : " [parameters('location')]" ,
51
- "name" : " [parameters('clusterName')]" ,
52
- "identity" : {
53
- "type" : " UserAssigned" ,
54
- "userAssignedIdentities" : {
55
- "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]" : {}
48
+ "type" : " Microsoft.Insights/diagnosticSettings" ,
49
+ "apiVersion" : " 2021-05-01-preview" ,
50
+ "scope" : " [format('Microsoft.ContainerService/managedClusters/{0}', parameters('name'))]" ,
51
+ "name" : " audit" ,
52
+ "properties" : {
53
+ "logs" : [
54
+ {
55
+ "category" : " kube-audit-admin" ,
56
+ "enabled" : true ,
57
+ "retentionPolicy" : {
58
+ "days" : 0 ,
59
+ "enabled" : false
60
+ }
61
+ },
62
+ {
63
+ "category" : " guard" ,
64
+ "enabled" : true ,
65
+ "retentionPolicy" : {
66
+ "days" : 0 ,
67
+ "enabled" : false
56
68
}
57
- },
58
- "properties" : {
59
- "kubernetesVersion" : " [parameters('kubernetesVersion')]" ,
60
- "disableLocalAccounts" : true ,
61
- "enableRBAC" : true ,
62
- "dnsPrefix" : " [parameters('dnsPrefix')]" ,
63
- "agentPoolProfiles" : [
64
- {
65
- "name" : " system" ,
66
- "osDiskSizeGB" : 32 ,
67
- "count" : 3 ,
68
- "minCount" : 3 ,
69
- "maxCount" : 10 ,
70
- "enableAutoScaling" : true ,
71
- "maxPods" : 50 ,
72
- "vmSize" : " Standard_D2s_v3" ,
73
- "osType" : " Linux" ,
74
- "type" : " VirtualMachineScaleSets" ,
75
- "vnetSubnetID" : " [variables('clusterSubnetId')]" ,
76
- "mode" : " System" ,
77
- "osDiskType" : " Ephemeral" ,
78
- "scaleSetPriority" : " Regular"
79
- }
80
- ],
81
- "aadProfile" : {
82
- "managed" : true ,
83
- "enableAzureRBAC" : true ,
84
- "adminGroupObjectIDs" : " [parameters('clusterAdmins')]" ,
85
- "tenantID" : " [subscription().tenantId]"
86
- },
87
- "networkProfile" : {
88
- "networkPlugin" : " azure" ,
89
- "networkPolicy" : " azure" ,
90
- "loadBalancerSku" : " Standard" ,
91
- "serviceCidr" : " 192.168.0.0/16" ,
92
- "dnsServiceIP" : " 192.168.0.4" ,
93
- "dockerBridgeCidr" : " 172.17.0.1/16"
94
- },
95
- "autoUpgradeProfile" : {
96
- "upgradeChannel" : " stable"
97
- },
98
- "addonProfiles" : {
99
- "azurepolicy" : {
100
- "enabled" : true ,
101
- "config" : {
102
- "version" : " v2"
103
- }
104
- },
105
- "omsagent" : {
106
- "enabled" : true ,
107
- "config" : {
108
- "logAnalyticsWorkspaceResourceID" : " [parameters('workspaceId')]"
109
- }
110
- },
111
- "kubeDashboard" : {
112
- "enabled" : false
113
- }
69
+ }
70
+ ],
71
+ "workspaceId" : " [parameters('workspaceId')]" ,
72
+ "logAnalyticsDestinationType" : " Dedicated"
73
+ },
74
+ "dependsOn" : [
75
+ " [resourceId('Microsoft.ContainerService/managedClusters', parameters('name'))]"
76
+ ]
77
+ }
78
+ ```
79
+
80
+ ### Configure with Bicep
81
+
82
+ To deploy AKS clusters that pass this rule:
83
+
84
+ - Deploy a diagnostic settings sub-resource.
85
+ - Enable logging for ` kube-audit-admin ` (or ` kube-audit ` ) and ` guard ` log categories.
86
+
87
+ For example:
88
+
89
+ ``` bicep
90
+ resource auditLogs 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
91
+ name: 'audit'
92
+ scope: cluster
93
+ properties: {
94
+ logs: [
95
+ {
96
+ category: 'kube-audit-admin'
97
+ enabled: true
98
+ retentionPolicy: {
99
+ days: 0
100
+ enabled: false
114
101
}
115
- },
116
- "resources" : [
117
- {
118
- "apiVersion" : " 2016-09-01" ,
119
- "type" : " Microsoft.ContainerService/managedClusters/providers/diagnosticSettings" ,
120
- "name" : " [concat(parameters('clusterName'), '/Microsoft.Insights/service')]" ,
121
- "properties" : {
122
- "workspaceId" : " [parameters('workspaceId')]" ,
123
- "logs" : [
124
- {
125
- "category" : " kube-audit" ,
126
- "enabled" : true ,
127
- "retentionPolicy" : {
128
- "days" : 0 ,
129
- "enabled" : false
130
- }
131
- },
132
- {
133
- "category" : " kube-audit-admin" ,
134
- "enabled" : true ,
135
- "retentionPolicy" : {
136
- "days" : 0 ,
137
- "enabled" : false
138
- }
139
- },
140
- {
141
- "category" : " guard" ,
142
- "enabled" : true ,
143
- "retentionPolicy" : {
144
- "days" : 0 ,
145
- "enabled" : false
146
- }
147
- }
148
- ],
149
- "metrics" : []
150
- }
102
+ }
103
+ {
104
+ category: 'guard'
105
+ enabled: true
106
+ retentionPolicy: {
107
+ days: 0
108
+ enabled: false
151
109
}
110
+ }
152
111
]
112
+ workspaceId: workspaceId
113
+ logAnalyticsDestinationType: 'Dedicated'
114
+ }
153
115
}
154
116
```
155
117
118
+ <!-- external:avm avm/res/container-service/managed-cluster diagnosticSettings -->
119
+
156
120
## LINKS
157
121
158
- - [ Security audits ] ( https://learn.microsoft.com/azure/architecture/framework/ security/monitor-audit )
122
+ - [ SE:10 Monitoring and threat detection ] ( https://learn.microsoft.com/azure/well-architected/ security/monitor-threats )
159
123
- [ Monitoring AKS data reference] ( https://learn.microsoft.com/azure/aks/monitor-aks-reference )
160
- - [ Collect resource logs] ( https://learn.microsoft.com/azure/aks/monitor-aks#collect-resource -logs )
161
- - [ Template reference] ( https://learn.microsoft.com/azure/templates/microsoft.insights/diagnosticsettings?tabs=json )
124
+ - [ AKS control plane/ resource logs] ( https://learn.microsoft.com/azure/aks/monitor-aks#aks-control-planeresource -logs )
125
+ - [ Azure deployment reference] ( https://learn.microsoft.com/azure/templates/microsoft.insights/diagnosticsettings )
0 commit comments