> [!NOTE]
> Premium and Enterprise (Deprecated) [service tiers](https://docs.cloud.google.com/security-command-center/docs/service-tiers.md.txt)

> [!CAUTION]
> The Security Command Center Enterprise service tier will shut down on May 21, 2027. If your organization uses the Enterprise service tier, then the organization will automatically move to the Premium service tier on or after May 21, 2027. Contact your account representative or a [Google Cloud sales specialist](https://cloud.google.com/contact) if you have questions.

This document describes a threat finding type in Security Command Center. Threat findings are generated by
[threat detectors](https://docs.cloud.google.com/security-command-center/docs/concepts-security-sources.md.txt#threats) when they detect
a potential threat in your cloud resources. For a full list of available threat findings, see [Threat findings index](https://docs.cloud.google.com/security-command-center/docs/threat-findings-index.md.txt).

## Overview

The AlloyDB for PostgreSQL database superuser account (`postgres`)
wrote to user tables. The superuser (a role with very broad access) generally
shouldn't be used to write to user tables. A user account with more limited access
should be used for normal daily activity. When a superuser writes to a user
table, that could indicate that an attacker has escalated privileges or has
compromised the default database user and is modifying data. It could also
indicate normal but unsafe practices.

[Event Threat Detection](https://docs.cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview.md.txt) is the source of
this finding.

## How to respond

To respond to this finding, do the following:

### Step 1: Review finding details

1. Open an `Privilege Escalation: AlloyDB Database Superuser Writes to User Tables` finding, as directed in [Reviewing findings](https://docs.cloud.google.com/security-command-center/docs/how-to-investigate-threats.md.txt#reviewing_findings).
2. On the **Summary** tab of the finding details panel, review the
   information in the following sections:

   - **What was detected** , especially the following fields:
     - **Database display name**: the name of the database in the AlloyDB for PostgreSQL instance that was affected.
     - **Database user name**: the superuser.
     - **Database query**: the SQL query executed while writing to user tables.
   - **Affected resource** , especially the following fields:
     - **Resource full name**: the resource name of the AlloyDB for PostgreSQL instance that was affected.
     - **Parent full name**: the resource name of the AlloyDB for PostgreSQL instance.
     - **Project full name**: the Google Cloud project that contains the AlloyDB for PostgreSQL instance.
   - **Related links** , especially the following fields:
     - **Cloud Logging URI**: link to Logging entries.
     - **MITRE ATT\&CK method**: link to the MITRE ATT\&CK documentation.
3. To see the complete JSON for the finding, click the **JSON** tab.

### Step 2: Check logs

1. In the Google Cloud console, go to **Logs Explorer** by clicking the link in `cloudLoggingQueryURI` (from [Step 1](https://docs.cloud.google.com/security-command-center/docs/findings/threats/alloydb-superuser-writes-to-user-tables.md.txt#privesc_alloydb_database_superuser_writes_to_user_tables_findings)). The **Logs Explorer** page includes all logs related to the relevant AlloyDB for PostgreSQL instance.
2. Check the logs for PostgreSQL pgaudit logs, which contain the queries executed by the superuser, by using the following filters:
   - `protoPayload.request.user="postgres"`

### Step 3: Research attack and response methods

1. Review the MITRE ATT\&CK framework entry for this finding type: [Exfiltration Over Web Service](https://attack.mitre.org/techniques/T1078/001/).
2. To determine if additional remediation steps are necessary, combine your investigation results with MITRE research.

### Step 4: Implement your response


The following response plan might be appropriate for this finding, but might also impact operations.
Carefully evaluate the information you gather in your investigation to determine the best way to
resolve findings.

- [Review the users allowed to connect to the database](https://docs.cloud.google.com/alloydb/docs/database-users/about#manage-users).
- [Consider changing the password for the superuser](https://docs.cloud.google.com/alloydb/docs/database-users/about#change-password).
- Consider [creating a new, limited access user](https://docs.cloud.google.com/alloydb/docs/database-users/about#create) for the different types of queries used on the instance.
  - [Grant the new user only the necessary permissions needed to execute their queries](https://docs.cloud.google.com/alloydb/docs/database-users/about#create).
  - Update the credentials for the clients that connect to the AlloyDB for PostgreSQL instance

## Example finding JSON

The following is an example of the finding 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"
    }
}
```

## What's next

- Learn [how to work with threat
  findings in Security Command Center](https://docs.cloud.google.com/security-command-center/docs/how-to-investigate-threats).
- Refer to the [Threat findings index](https://docs.cloud.google.com/security-command-center/docs/threat-findings-index.md.txt).
- Learn how to [review a
  finding](https://docs.cloud.google.com/security-command-center/docs/how-to-investigate-threats#reviewing_findings) through the Google Cloud console.
- Learn about the [services that
  generate threat findings](https://docs.cloud.google.com/security-command-center/docs/concepts-security-sources#threats).