Profile Applicability:

Level 1

Description:

It is recommended to configure a log metric filter and alert to monitor changes related to Identity and Access Management (IAM) custom roles, including creation, deletion, and updates. Monitoring these changes ensures proper tracking of custom role configurations and minimizes the risk of over-privileged roles being created or modified without oversight.

Rationale:

IAM provides predefined roles for granular access control. However, custom roles can be created to meet specific organizational needs. Monitoring the creation, deletion, or updates of custom roles is crucial to:

  • Prevent unauthorized modifications.

  • Detect over-privileged roles early.

  • Ensure adherence to the principle of least privilege.

Impact:

Enabling logging may result in increased costs for storing and analyzing log data.

Default Value:

IAM custom role changes are not monitored by default.

Audit Steps:

Using Google Cloud Console:

  1. Verify Log Metric Configuration:

  • In the User-defined Metrics section, ensure a metric exists with the filter:
resource.type="iam_role"
AND (protoPayload.methodName="google.iam.admin.v1.CreateRole"
OR protoPayload.methodName="google.iam.admin.v1.DeleteRole"
OR protoPayload.methodName="google.iam.admin.v1.UpdateRole")
  1. Verify Alerting Policy Configuration:

                             

  • Confirm there is at least one alert policy for the above metric.

  • Check that the alert condition is configured to trigger when:

    • Threshold: Any value above 0 for custom role changes.

    • Notifications: Appropriate notification channels are configured.

Using Google Cloud CLI:

  1. Verify Log Metric Configuration:

  • List log metrics:
gcloud logging metrics list --format json
  • Check for a metric with the filter:
resource.type="iam_role"
AND (protoPayload.methodName="google.iam.admin.v1.CreateRole"
OR protoPayload.methodName="google.iam.admin.v1.DeleteRole"
OR protoPayload.methodName="google.iam.admin.v1.UpdateRole")
  1. Verify Alerting Policy Configuration:

  • List alerting policies:
gcloud alpha monitoring policies list --format json
  • Ensure the output contains a policy where:
  • Condition Filter: Matches the above metric.

  • Enabled: true.

Remediation Steps:

Using Google Cloud Console:

  1. Create a Log Metric:

                           

  • Click CREATE METRIC and set:

                           

Filter:

resource.type="iam_role"
AND (protoPayload.methodName="google.iam.admin.v1.CreateRole"
OR protoPayload.methodName="google.iam.admin.v1.DeleteRole"
OR protoPayload.methodName="google.iam.admin.v1.UpdateRole")
  • Metric Type: Counter

  • Units: 1 (default)

                         

  • Click Create Metric.

                           

  1. Create an Alert Policy:

    • Locate the created metric under User-defined Metrics.

                         

  • Click the three-dot menu and select Create alert from Metric.

                                 

  • Configure:

    • Aggregator: Count

    • Threshold: Above 0.

    • Condition: Any change triggers the alert.

  • Configure notification channels and save the policy.

Using Google Cloud CLI:

Create a Log Metric:

gcloud logging metrics create <metric-name> \
  --description="Monitor IAM custom role changes" \
  --log-filter="resource.type='iam_role' AND \
  (protoPayload.methodName='google.iam.admin.v1.CreateRole' OR \
  protoPayload.methodName='google.iam.admin.v1.DeleteRole' OR \
  protoPayload.methodName='google.iam.admin.v1.UpdateRole')"

Create an Alert Policy:

gcloud alpha monitoring policies create \
  --display-name="<policy-name>" \
  --conditions="<condition-config>" \
  --notification-channels="<notification-channels>"

References:

  1. Logs-Based Metrics

  2. Custom Metrics in Monitoring

  3. Alerts in Monitoring

  4. IAM Custom Roles

CIS Controls:

Control

Description

IG 1

IG 2

IG 3

8.2 Collect Audit Logs

Enable audit logging across enterprise assets.

8.5 Collect Detailed Audit Logs

Enable detailed logs for sensitive data, including event source and timestamps.


6.2 Activate Audit Logging

Ensure audit logging is enabled on all systems and devices.

6.3 Enable Detailed Logging

Include detailed information such as event source, date, user, and timestamps.