> [!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

All privileges over a PostgreSQL database (or all
functions or procedures in a database) were granted to one or more database
users.

[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 the `Exfiltration: Cloud SQL Over-Privileged Grant` 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 Cloud SQL PostgreSQL instance that was affected.
     - **Database user name**: the PostgreSQL user who granted excess privileges.
     - **Database query**: the PostgreSQL query executed that granted the privileges.
     - **Database grantees**: the grantees of the overbroad privileges.
   - **Affected resource** , especially the following fields:
     - **Resource full name**: the resource name of the Cloud SQL PostgreSQL instance that was affected.
     - **Parent full name**: the resource name of the Cloud SQL PostgreSQL instance.
     - **Project full name**: the Google Cloud project that contains the Cloud SQL 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.
     - **Related findings**: links to any related findings.
3. To see the complete JSON for the finding, click the **JSON** tab.

### Step 2: Review database privileges

1. [Connect to the PostgreSQL database](https://docs.cloud.google.com/sql/docs/postgres/connect-admin-ip.md.txt).
2. [List and show access privileges](https://www.postgresql.org/docs/14/app-psql.html#APP-PSQL-META-COMMANDS) for the following:
   - Databases. Use the `\l` or `\list` metacommand and check what privileges are assigned for the database listed in **Database display name** (from [Step 1](https://docs.cloud.google.com/security-command-center/docs/findings/threats/cloudsql-exfil-user-granted-all-permissions.md.txt#cloudsql_findings_over_privileged_grant)).
   - Functions or procedures. Use the `\df` metacommand and check what privileges are assigned for functions or procedures in the database listed in **Database display name** (from [Step 1](https://docs.cloud.google.com/security-command-center/docs/findings/threats/cloudsql-exfil-user-granted-all-permissions.md.txt#cloudsql_findings_over_privileged_grant)).

### Step 3: Check logs

1. In the Google Cloud console, go to **Logs Explorer** by clicking the link in **Cloud Logging URI** (from [Step 1](https://docs.cloud.google.com/security-command-center/docs/findings/threats/cloudsql-exfil-user-granted-all-permissions.md.txt#cloudsql_findings_over_privileged_grant)). The **Logs Explorer** page includes all logs related to the relevant Cloud SQL instance.
2. In the **Logs explorer** , check the PostgreSQL `pgaudit` logs, which record executed queries to the database, by using the following filters:
   - `protoPayload.request.database="var class="edit">database"`

### Step 4: 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/T1567/).
2. To determine if additional remediation steps are necessary, combine your investigation results with MITRE research.

### Step 5: 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.

- Contact the owner of the instance with overprivileged grants.
- Consider [revoking](https://www.postgresql.org/docs/14/sql-revoke.html) all permissions for the grantees that are listed in **Database grantees** until the investigation is completed.
- To limit access to the database (from **Database display name** of [Step 1](https://docs.cloud.google.com/security-command-center/docs/findings/threats/cloudsql-exfil-user-granted-all-permissions.md.txt#cloudsql_findings_over_privileged_grant)), [revoke](https://www.postgresql.org/docs/14/sql-revoke.html) unnecessary permissions from the grantees (from **Database grantees** of [Step 1](https://docs.cloud.google.com/security-command-center/docs/findings/threats/cloudsql-exfil-user-granted-all-permissions.md.txt#cloudsql_findings_over_privileged_grant)).

## 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": "//cloudsql.googleapis.com/projects/PROJECT_ID/instances/INSTANCE_NAME",
      "state": "ACTIVE",
      "category": "Exfiltration: CloudSQL Over-Privileged Grant",
      "sourceProperties": {
        "sourceId": {
          "projectNumber": "PROJECT_NUMBER",
          "customerOrganizationNumber": "ORGANIZATION_ID"
        },
        "detectionCategory": {
          "ruleName": "cloudsql_exfil",
          "subRuleName": "user_granted_all_permissions"
        },
        "detectionPriority": "LOW",
        "affectedResources": [
          {
            "gcpResourceName": "//cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER"
          },
          {
            "gcpResourceName": "//cloudsql.googleapis.com/projects/PROJECT_ID/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/T1567/002/"
          },
          "cloudLoggingQueryUri": [{
            "displayName": "Cloud Logging Query Link",
            "url": "LOGGING_LINK"
          }],
          "relatedFindingUri": {
            "displayName": "Related CloudSQL Exfiltration findings",
            "url": "RELATED_FINDINGS_LINK"
          }
        }
      },
      "eventTime": "2022-01-19T21:36:07.901Z",
      "createTime": "2022-01-19T21:36:08.695Z",
      "severity": "LOW",
      "workflowState": "NEW",
      "canonicalName": "projects/PROJECT_NUMBER/sources/SOURCE_ID/findings/FINDING_ID"
      "mute": "UNDEFINED",
      "findingClass": "THREAT",
      "mitreAttack": {
        "primaryTactic": "EXFILTRATION",
        "primaryTechniques": ["EXFILTRATION_OVER_WEB_SERVICE"]
      },
      "database": {
        "displayName": "DATABASE_NAME",
        "userName": "USER_NAME",
        "query": "QUERY",
        "grantees": [GRANTEE],
      },
      "access": {
        "serviceName": "cloudsql.googleapis.com",
        "methodName": "cloudsql.instances.query"
      }
    },
    "resource": {
      "name": "//cloudsql.googleapis.com/projects/PROJECT_ID/instances/INSTANCE_NAME",
      "projectName": "//cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER",
      "projectDisplayName": "PROJECT_ID",
      "parentName": "//cloudsql.googleapis.com/projects/PROJECT_NUMBER",
      "parentDisplayName": "PROJECT_ID",
      "type": "google.cloud.sql.Instance",
      "folders": [{
        "resourceFolder": "//cloudresourcemanager.googleapis.com/folders/FOLDER_NUMBER",
        "resourceFolderDisplayName": "FOLDER_ID"
      }],
      "displayName": "INSTANCE_NAME"
    }
}
```

## 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).