權限提升:AlloyDB 資料庫超級使用者寫入使用者資料表

本文說明 Security Command Center 中的威脅發現項目類型。威脅偵測工具在雲端資源中偵測到潛在威脅時,就會產生威脅發現項目。如需可用威脅發現項目的完整清單,請參閱威脅發現項目索引

總覽

AlloyDB for PostgreSQL 資料庫超級使用者帳戶 (postgres) 寫入使用者資料表。超級使用者 (存取權非常廣的角色) 一般不應寫入使用者資料表。日常活動應使用存取權較有限的使用者帳戶。超級使用者寫入使用者資料表可能表示攻擊者已提升權限或竊取預設資料庫使用者的身分,然後修改資料。這也可能表示您採用的做法不安全,但並非異常活動。

Event Threat Detection 是這項發現項目的來源。

回應方式

如要回應這項發現項目,請按照下列步驟操作:

步驟 1:查看調查結果詳細資料

  1. 按照「查看發現項目」一文的說明,開啟Privilege Escalation: AlloyDB Database Superuser Writes to User Tables發現項目。
  2. 在調查結果詳細資料面板的「摘要」分頁中,查看下列各節的資訊:

    • 偵測到的內容,尤其是下列欄位:
      • 資料庫顯示名稱:受影響的 AlloyDB for PostgreSQL 執行個體中的資料庫名稱。
      • 資料庫使用者名稱:超級使用者。
      • 資料庫查詢:寫入使用者資料表時執行的 SQL 查詢。
    • 受影響的資源,尤其是下列欄位:
      • 資源完整名稱:受影響的 AlloyDB for PostgreSQL 執行個體資源名稱。
      • 父項完整名稱:AlloyDB for PostgreSQL 執行個體的資源名稱。
      • 專案完整名稱:包含 AlloyDB for PostgreSQL 執行個體的專案。 Google Cloud
    • 相關連結,尤其是下列欄位:
      • Cloud Logging URI:記錄項目連結。
      • MITRE ATT&CK 方法:連結至 MITRE ATT&CK 文件。
  3. 如要查看發現項目的完整 JSON,請按一下「JSON」分頁標籤。

步驟 2:檢查記錄

  1. 在 Google Cloud 控制台中,按一下 cloudLoggingQueryURI 中的連結 (來自步驟 1),前往「Logs Explorer」。「記錄檔瀏覽器」頁面會顯示與相關 AlloyDB for PostgreSQL 執行個體有關的所有記錄。
  2. 使用下列篩選器檢查 PostgreSQL pgaudit 記錄,其中包含超級使用者執行的查詢:
    • protoPayload.request.user="postgres"

步驟 3:研究攻擊和應變方法

  1. 查看這類發現項目的 MITRE ATT&CK 框架項目: 透過網路服務進行資料外洩
  2. 如要判斷是否需要採取其他補救措施,請將調查結果與 MITRE 研究結合。

步驟 4:實作回應

下列應變計畫可能適用於這項發現,但也可能影響作業。 請仔細評估調查期間收集到的資訊,找出解決問題的最佳方式。

發現項目 JSON 範例

以下是發現項目 JSON 的範例。

{
    "finding": {
      "name": "organizations/ORGANIZATION_ID/sources/SOURCE_ID/findings/FINDING_ID",
      "parent": "organizations/ORGANIZATION_ID/sources/SOURCE_ID",
      "resource_name": "//alloydb.googleapis.com/projects/PROJECT_ID/locations/REGION/clusters/CLUSTER/instances/INSTANCE_NAME",
      "state": "ACTIVE",
      "category": "Privilege Escalation: AlloyDB Database Superuser Writes to User Tables",
      "sourceProperties": {
        "sourceId": {
          "projectNumber": "PROJECT_NUMBER",
          "customerOrganizationNumber": "ORGANIZATION_ID"
        },
        "detectionCategory": {
          "ruleName": "alloydb_user_granted_all_permissions",
        },
        "detectionPriority": "LOW",
        "affectedResources": [
          {
            "gcpResourceName": "//cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER"
          },
          {
            "gcpResourceName": "//alloydb.googleapis.com/projects/PROJECT_ID/locations/REGION/clusters/CLUSTER/instances/INSTANCE_NAME"
          }
        ],
        "evidence": [{
          "sourceLogId": {
            "projectId": "PROJECT_ID",
            "resourceContainer": "projects/PROJECT_ID",
            "timestamp": {
              "seconds": "0",
              "nanos": 0.0
            },
            "insertId": "INSERT_ID"
          }
        }],
        "findingId": "FINDING_ID",
        "contextUris": {
          "mitreUri": {
            "displayName": "MITRE Link",
            "url": "https://attack.mitre.org/techniques/T1078/001/"
          },
          "cloudLoggingQueryUri": [{
            "displayName": "Cloud Logging Query Link",
            "url": "LOGGING_LINK"
          }]
        }
      },
      "eventTime": "EVENT_TIMESTAMP",
      "createTime": "CREATE_TIMESTAMP",
      "severity": "LOW",
      "workflowState": "NEW",
      "canonicalName": "projects/PROJECT_NUMBER/sources/SOURCE_ID/findings/FINDING_ID"
      "mute": "UNDEFINED",
      "findingClass": "THREAT",
      "mitreAttack": {
          "primaryTactic": "PRIVILEGE_ESCALATION",
          "primaryTechniques": [
            "VALID_ACCOUNTS"
          ],
          "additionalTactics": [
            "PERSISTENCE"
          ],
          "additionalTechniques": [
            "ACCOUNT_MANIPULATION"
          ]
        },
      "database": {
        "displayName": "DATABASE_NAME",
        "userName": "USER_NAME",
        "query": "QUERY",
      },
      "access": {
        "serviceName": "alloydb.googleapis.com",
        "methodName": "alloydb.instances.query"
      }
    },
    "resource": {
      "name": "//alloydb.googleapis.com/projects/PROJECT_ID/locations/REGION/clusters/CLUSTER/instances/INSTANCE_NAME",
      "displayName": "projects/PROJECT_ID/locations/REGION/clusters/CLUSTER/instances/INSTANCE_NAME",
      "type": "google.alloydb.Instance",
      "cloudProvider": "GOOGLE_CLOUD_PLATFORM",
      "service": "alloydb.googleapis.com",
      "location": "REGION",
      "gcpMetadata": {
        "project": "//cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER",
        "projectDisplayName": "PROJECT_ID",
        "parent": "//cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER",
        "parentDisplayName": "PROJECT_ID",
        "folders": [
          {
            "resourceFolder": "//cloudresourcemanager.googleapis.com/folders/FOLDER_NUMBER",
            "resourceFolderDisplayName": FOLDER_NAME
          }
        ],
        "organization": "organizations/ORGANIZATION_ID"
      },
      "resourcePath": {
        "nodes": [
          {
            "nodeType": "GCP_PROJECT",
            "id": "projects/PROJECT_NUMBER",
            "displayName": "PROJECT_ID"
          },
          {
            "nodeType": "GCP_FOLDER",
            "id": "folders/FOLDER_NUMBER",
            "displayName": "FOLDER_NAME"
          },
          {
            "nodeType": "GCP_ORGANIZATION",
            "id": "organizations/ORGANIZATION_ID"
          }
        ]
      },
      "resourcePathString": "organizations/ORGANIZATION_ID/folders/FOLDER_NUMBER/projects/PROJECT_NUMBER"
    }
}

後續步驟