gcloud-postgresql-log-checkpoints-disabled: PostgreSQL Log Checkpoints Flag Disabled

日期: 2025-08-01 | 影响软件: PostgreSQL | POC: 已公开

漏洞描述

Ensure that the "log_checkpoints" database flag is enabled for all PostgreSQL database instances available within your Google Cloud Platform (GCP) account. The "log_checkpoints" flag allows checkpoints and restart points to be logged in the PostgreSQL server log. By default, this flag is disabled, and enabling it ensures better tracking and debugging of database operations.

PoC代码[已公开]

id: gcloud-postgresql-log-checkpoints-disabled

info:
  name: PostgreSQL Log Checkpoints Flag Disabled
  author: princechaddha
  severity: medium
  description: |
    Ensure that the "log_checkpoints" database flag is enabled for all PostgreSQL database instances available within your Google Cloud Platform (GCP) account. The "log_checkpoints" flag allows checkpoints and restart points to be logged in the PostgreSQL server log. By default, this flag is disabled, and enabling it ensures better tracking and debugging of database operations.
  impact: |
    Disabling the "log_checkpoints" flag may result in limited visibility into checkpoint operations, making it difficult to troubleshoot and monitor PostgreSQL database activities effectively.
  remediation: |
    Enable the "log_checkpoints" flag for all PostgreSQL database instances by updating the database configuration using the Google Cloud Console or gcloud CLI.
  reference:
    - https://cloud.google.com/sql/docs/postgres/flags
  tags: cloud,devops,gcp,gcloud,google-cloud-sql,postgresql,gcp-cloud-config

flow: |
  code(1)
  for(let projectId of iterate(template.projectIds)){
    set("projectId", projectId)
    code(2)
    for(let sqlInstance of iterate(template.sqlInstances)){
      set("sqlInstance", sqlInstance)
      code(3)
    }
  }

self-contained: true

code:
  - engine:
      - sh
      - bash
    source: |
      gcloud projects list --format="json(projectId)"

    extractors:
      - type: json
        name: projectIds
        internal: true
        json:
          - '.[].projectId'

  - engine:
      - sh
      - bash
    source: |
      gcloud sql instances list --project $projectId --filter='DATABASE_VERSION:POSTGRES*' --format="json(name)"

    extractors:
      - type: json
        name: sqlInstances
        internal: true
        json:
          - '.[].name'

  - engine:
      - sh
      - bash
    source: |
      gcloud sql instances describe $sqlInstance --format="json(settings.databaseFlags)"

    matchers:
      - type: word
        words:
          - 'off'

    extractors:
      - type: dsl
        dsl:
          - '"PostgreSQL Log Checkpoints flag is disabled in database instance: " + sqlInstance + " in project: " + projectId'
# digest: 4a0a00473045022100e25f6c8c1925b65cd8dd47e4e03a5a28448cdc3d276021098c2d156044e1271102203339363363afa6f0a81053c581d6daaf123ce9704b3a60e3e5fadd9307b3988f:922c64590222798bb761d5b6d8e72950

相关漏洞推荐