Skip to content

Commit

Permalink
Add CIS Azure 4.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
romulets committed Jan 4, 2024
1 parent 01eb274 commit 22188af
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 4 deletions.
2 changes: 1 addition & 1 deletion security-policies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![CIS EKS](https://img.shields.io/badge/CIS-Amazon%20EKS%20(60%25)-FF9900?logo=Amazon+EKS)](RULES.md#eks-cis-benchmark)
[![CIS AWS](https://img.shields.io/badge/CIS-AWS%20(87%25)-232F3E?logo=Amazon+AWS)](RULES.md#aws-cis-benchmark)
[![CIS GCP](https://img.shields.io/badge/CIS-GCP%20(85%25)-4285F4?logo=Google+Cloud)](RULES.md#gcp-cis-benchmark)
[![CIS AZURE](https://img.shields.io/badge/CIS-AZURE%20(31%25)-0078D4?logo=Microsoft+Azure)](RULES.md#azure-cis-benchmark)
[![CIS AZURE](https://img.shields.io/badge/CIS-AZURE%20(32%25)-0078D4?logo=Microsoft+Azure)](RULES.md#azure-cis-benchmark)

![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/oren-zohar/a7160df46e48dff45b24096de9302d38/raw/csp-security-policies_coverage.json)

Expand Down
6 changes: 3 additions & 3 deletions security-policies/RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@

## AZURE CIS Benchmark

### 47/151 implemented rules (31%)
### 48/151 implemented rules (32%)

#### Automated rules: 47/77 (61%)
#### Automated rules: 48/77 (62%)

#### Manual rules: 0/74 (0%)

Expand Down Expand Up @@ -472,7 +472,7 @@
| [3.7](bundle/compliance/cis_azure/rules/cis_3_7) | Storage Accounts | Ensure that 'Public access level' is disabled for storage accounts with blob containers | :white_check_mark: | Automated |
| [3.8](bundle/compliance/cis_azure/rules/cis_3_8) | Storage Accounts | Ensure Default Network Access Rule for Storage Accounts is Set to Deny | :white_check_mark: | Automated |
| [3.9](bundle/compliance/cis_azure/rules/cis_3_9) | Storage Accounts | Ensure 'Allow Azure services on the trusted services list to access this storage account' is Enabled for Storage Account Access | :white_check_mark: | Automated |
| 4.1.1 | SQL Server - Auditing | Ensure that 'Auditing' is set to 'On' | :x: | Automated |
| [4.1.1](bundle/compliance/cis_azure/rules/cis_4_1_1) | SQL Server - Auditing | Ensure that 'Auditing' is set to 'On' | :white_check_mark: | Automated |
| [4.1.2](bundle/compliance/cis_azure/rules/cis_4_1_2) | SQL Server - Auditing | Ensure no Azure SQL Databases allow ingress from 0.0.0.0/0 (ANY IP) | :white_check_mark: | Automated |
| [4.1.3](bundle/compliance/cis_azure/rules/cis_4_1_3) | SQL Server - Auditing | Ensure SQL server's Transparent Data Encryption (TDE) protector is encrypted with Customer-managed key | :white_check_mark: | Automated |
| [4.1.4](bundle/compliance/cis_azure/rules/cis_4_1_4) | SQL Server - Auditing | Ensure that Azure Active Directory Admin is Configured for SQL Servers | :white_check_mark: | Automated |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
metadata:
id: e570dc22-4f5d-51db-a193-983cb7d20afe
name: Ensure that 'Auditing' is set to 'On'
profile_applicability: '* Level 1'
description: Enable auditing on SQL Servers.
rationale: |-
The Azure platform allows a SQL server to be created as a service.
Enabling auditing at the server level ensures that all existing and newly created databases on the SQL server instance are audited.
Auditing policy applied on the SQL database does not override auditing policy and settings applied on the particular SQL server where the database is hosted.
Auditing tracks database events and writes them to an audit log in the Azure storage account.
It also helps to maintain regulatory compliance, understand database activity, and gain insight into discrepancies and anomalies that could indicate business concerns or suspected security violations.
audit: |-
**From Azure Portal**
1. Go to `SQL servers`
2. For each server instance
3. Click on `Auditing`
4. Ensure that `Enable Azure SQL Auditing` is set to `On`
**From PowerShell**
Get the list of all SQL Servers
```
Get-AzSqlServer
```
For each Server
```
Get-AzSqlServerAudit -ResourceGroupName <ResourceGroupName> -ServerName <SQLServerName>
```
Ensure that `BlobStorageTargetState`, `EventHubTargetState`, or `LogAnalyticsTargetState` is set to `Enabled`.
remediation: |-
**From Azure Portal**
1. Go to `SQL servers`
2. Select the SQL server instance
3. Under `Security`, click `Auditing`
4. Click the toggle next to `Enable Azure SQL Auditing`
5. Select an Audit log destination
6. Click `Save`
**From PowerShell**
Get the list of all SQL Servers
```
Get-AzSqlServer
```
For each Server, enable auditing and set the retention for at least 90 days.
**Log Analytics Example**
```
Set-AzSqlServerAudit -ResourceGroupName <resource group name> -ServerName <SQL Server name> -RetentionInDays <Number of Days to retain the audit logs, should be 90days minimum> -LogAnalyticsTargetState Enabled -WorkspaceResourceId "/subscriptions/<subscription ID>/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/<workspace name>
```
**Event Hub Example**
```
Set-AzSqlServerAudit -ResourceGroupName "<resource group name>" -ServerName "<SQL Server name>" -EventHubTargetState Enabled -EventHubName
"<Event Hub name>" -EventHubAuthorizationRuleResourceId "<Event Hub Authorization Rule Resource ID>"
```
**Blob Storage Example***
```
Set-AzSqlServerAudit -ResourceGroupName "<resource group name>" -ServerName "<SQL Server name>" -BlobStorageTargetState Enabled
-StorageAccountResourceId "/subscriptions/<subscription_ID>/resourceGroups/<Resource_Group>/providers/Microsoft.Stora
ge/storageAccounts/<Storage Account name>"
```
impact: ''
default_value: ''
references: |-
1. https://docs.microsoft.com/en-us/azure/security-center/security-center-enable-auditing-on-sql-servers
2. https://docs.microsoft.com/en-us/powershell/module/azurerm.sql/get-azurermsqlserverauditing?view=azurermps-5.2.0
3. https://docs.microsoft.com/en-us/powershell/module/azurerm.sql/set-azurermsqlserverauditingpolicy?view=azurermps-5.2.0
4. https://docs.microsoft.com/en-us/azure/sql-database/sql-database-auditing
5. https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-logging-threat-detection#lt-3-enable-logging-for-security-investigation
section: SQL Server - Auditing
version: '1.0'
tags:
- CIS
- AZURE
- CIS 4.1.1
- SQL Server - Auditing
benchmark:
name: CIS Microsoft Azure Foundations
version: v2.0.0
id: cis_azure
rule_number: 4.1.1
posture_type: cspm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package compliance.cis_azure.rules.cis_4_1_1

import data.compliance.lib.common
import data.compliance.policy.azure.data_adapter
import future.keywords.every
import future.keywords.if

finding = result if {
# filter
data_adapter.is_sql_server

# set result
result := common.generate_result_without_expected(
common.calculate_result(is_audit_enabled),
{"Resource": data_adapter.resource},
)
}

default is_audit_enabled = false

is_audit_enabled if {
data_adapter.resource.extension.sqlBlobAuditPolicy.state == "Enabled"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package compliance.cis_azure.rules.cis_4_1_1

import data.cis_azure.test_data
import data.compliance.policy.azure.data_adapter
import data.lib.test
import future.keywords.if

test_violation if {
eval_fail with input as test_data.generate_azure_asset_with_ext("azure-sql-server", {}, {"sqlBlobAuditPolicy": {"state": "Disabled"}})

eval_fail with input as test_data.generate_azure_asset_with_ext("azure-sql-server", {}, {})
}

test_pass if {
eval_pass with input as test_data.generate_azure_asset_with_ext("azure-sql-server", {}, {"sqlBlobAuditPolicy": {"state": "Enabled"}})
}

test_not_evaluated if {
not_eval with input as test_data.not_eval_non_exist_type
}

eval_fail if {
test.assert_fail(finding) with data.benchmark_data_adapter as data_adapter
}

eval_pass if {
test.assert_pass(finding) with data.benchmark_data_adapter as data_adapter
}

not_eval if {
not finding with data.benchmark_data_adapter as data_adapter
}

0 comments on commit 22188af

Please sign in to comment.