Control: 5.1.4 Ensure that logging for Azure Key Vault is 'Enabled'
Description
Enable AuditEvent logging for key vault instances to ensure interactions with key vaults are logged and available.
Monitoring how and when key vaults are accessed, and by whom, enables an audit trail of interactions with confidential information, keys, and certificates managed by Azure Keyvault. Enabling logging for Key Vault saves information in an Azure storage account which the user provides. This creates a new container named insights-logs-auditevent automatically for the specified storage account. This same storage account can be used for collecting logs for multiple Key Vaults.
Remediation
From Azure Portal
- Go to
Key vaults
. - Select a Key vault.
- Select
Diagnostic settings
. - Click on
Edit setting
against an existing diagnostic setting, orAdd diagnostic setting
. - If creating a new diagnostic setting, provide a name.
- Configure an appropriate destination.
- Under Categories, check
Audit Logs
. - Under
Category groups
, checkaudit
andallLogs
. - Click
Save
.
From Azure CLI
To update an existing Diagnostic Settings
az monitor diagnostic-settings update --name "<diagnostics settings name>" -- resource <key vault resource ID> --set retentionPolicy.days=90
To create a new Diagnostic Settings
az monitor diagnostic-settings create --name <diagnostic settings name> -- resource <key vault resource ID> --logs "[{category:AuditEvents,enabled:true,retention- policy:{enabled:true,days:180}}]" --metrics "[{category:AllMetrics,enabled:true,retention- policy:{enabled:true,days:180}}]" <[--event-hub <event hub ID> --event-hub- rule <event hub auth rule ID> | --storage-account <storage account ID> |-- workspace <log analytics workspace ID> | --marketplace-partner-id <fullresource ID of third-party solution>]>
From PowerShell
Create the Log
settings object
$logSettings = @()$logSettings += New-AzDiagnosticSettingLogSettingsObject -Enabled $true - RetentionPolicyDay 180 -RetentionPolicyEnabled $true -Category AuditEvent
Create the Metric
settings object
$metricSettings = @()$metricSettings += New-AzDiagnosticSettingMetricSettingsObject -Enabled $true -RetentionPolicyDay 180 -RetentionPolicyEnabled $true -Category AllMetrics
Create the Diagnostic Settings
for each Key Vault
New-AzDiagnosticSetting -Name "<diagnostic setting name>" -ResourceId <key vault resource ID> -Log $logSettings -Metric $metricSettings [- StorageAccountId <storage account ID> | -EventHubName <event hub name> - EventHubAuthorizationRuleId <event hub auth rule ID> | -WorkSpaceId <log analytics workspace ID> | -MarketPlacePartnerId <full resource ID for third- party solution>]
Default Value
By default, Diagnostic AuditEvent logging is not enabled for Key Vault instances.
Usage
Run the control in your terminal:
powerpipe control run azure_compliance.control.cis_v210_5_1_4
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run azure_compliance.control.cis_v210_5_1_4 --share
SQL
This control uses a named query:
keyvault_logging_enabled