Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

@cx-andre-pereira cx-andre-pereira commented Oct 16, 2025

Reason for Proposed Changes

  • Currently there are no queries addressing the Terraform/gcp "google_logging_metric" and "google_monitoring_alert_policy" resources's "filter" fields. This query is meant to ensure those resources's filters properly check for changes to Identity
    and Access Management (IAM) role creation, deletion and updating activities.

  • Quoting CIS_Google_Cloud_Platform_Foundation_Benchmark_v4.0.0 page 90: "Google Cloud IAM provides predefined roles that give granular access to specific Google Cloud Platform resources and prevent unwanted access to other resources. However, to cater to organization-specific needs, Cloud IAM also provides the ability to create custom roles. Project owners and administrators with the Organization Role Administrator role or the IAM Role Administrator role can create custom roles. Monitoring role creation, deletion and updating activities will help in identifying any over- privileged role at early stages."

  • Additionally page 90 states the specific filter that should be present :

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"
OR protoPayload.methodName="google.iam.admin.v1.UndeleteRole")

Proposed Changes

  • Developed an initial implementation for a query that ensures "Custom Role Changes" are accounted for by a given filter.

  • Initial implementations for this query had a more complex interpretation logic for the specific logging query language used, but that has been simplified to a regex that accepts only the specific filter with some freedom for spacing wherever possible (regex), sample negative2.tf specifically tests for "unusual" spacing.

  • Based on the audit described by the CIS entry the query will flag if :

    • There is at least one"google_logging_metric" resource in the project and none contain the correct filter
    • There is at least one "google_monitoring_alert_policy" resource in the project and none contain the filter/reference a logging metric that contains the correct filter
    • There is at least one "google_monitoring_alert_policy" resource that contains the filter but none of them declare "notification_channels".

Note: there are currently issues with the search values, i could not get them to point to the "filter" field for either of the target resources in the scan results.

Tenable Reference

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions bot added feature New feature query New query feature terraform Terraform query gcp PR related with GCP Cloud labels Oct 16, 2025
@github-actions
Copy link
Contributor

kics-logo

KICS version: v2.1.13

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review October 30, 2025 16:47
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner October 30, 2025 16:47
…re_that_the_log_metric_filter_and_alerts_exist_for_costum_role_changes
…og_metric_filter_and_alerts_exist_for_costum_role_changes' of https://github.com/Checkmarx/kics into AST-116618_5_2-Logging_and_Monitoring_ensure_that_the_log_metric_filter_and_alerts_exist_for_costum_role_changes
@github-actions github-actions bot added the azure PR related with Azure Cloud label Oct 31, 2025
…re_that_the_log_metric_filter_and_alerts_exist_for_costum_role_changes
@github-actions github-actions bot removed the azure PR related with Azure Cloud label Oct 31, 2025
…re_that_the_log_metric_filter_and_alerts_exist_for_costum_role_changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature gcp PR related with GCP Cloud query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant