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

A leaked service account key was used to authenticate an
action. In this context, a leaked service account key is one that was posted on
the public internet. For example, service account keys are often mistakenly
posted on public GitHub repositories.

[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 `Initial Access: Leaked Service Account Key Used` finding, as directed in [Reviewing findings](https://docs.cloud.google.com/security-command-center/docs/how-to-investigate-threats.md.txt#reviewing_findings).
2. In the finding details, on the **Summary** tab, note the values of
   following fields.

   Under **What was detected**:
   - **Principal email**: the service account used in this action
   - **Service name**: the API name of the Google Cloud service that was accessed by the service account
   - **Method name**: the method name of the action
   - **Service account key name**: the leaked service account key used to authenticate this action
   - **Description**: the description of what was detected, including the location on the public internet where the service account key can be found

   Under **Affected resource**:
   - **Resource display name**: the resource involved in the action

### Step 2: Check logs

1. In the Google Cloud console, go to **Logs Explorer** by clicking the link in **Cloud Logging URI**.
2. On the Google Cloud console toolbar, select your project or organization.
3. On the page that loads, find related logs by using the following filter:

   - `protoPayload.authenticationInfo.principalEmail="PRINCIPAL_EMAIL"`
   - `protoPayload.authenticationInfo.serviceAccountKeyName="SERVICE_ACCOUNT_KEY_NAME"`

   Replace <var translate="no">PRINCIPAL_EMAIL</var> with the value that you noted in the
   **Principal email** field in the finding details.
   Replace <var translate="no">SERVICE_ACCOUNT_KEY_NAME</var> with the value that you noted in
   the **Service account key name** field in the finding details.

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

- Revoke the service account key immediately in the [Service Accounts page](https://console.cloud.google.com/iam-admin/serviceaccounts).
- Take down the web page or GitHub repository where the service account key is posted.
- Consider [deleting the compromised service account](https://docs.cloud.google.com/iam/docs/service-accounts-delete-undelete.md.txt#deleting).
- Rotate and delete all service account access keys for the potentially compromised project. After deletion, applications that use the service account for authentication lose access. Before deleting, your security team should identify all impacted applications and work with application owners to ensure business continuity.
- Work with your security team to identify unfamiliar resources, including Compute Engine instances, snapshots, service accounts, and IAM users. Delete resources not created with authorized accounts.
- Respond to any notifications from Cloud Customer Care.

## Example finding JSON

The following is an example of the finding JSON.

```json
{
 "findings": {
   "access": {
     "principalEmail": "SERVICE_ACCOUNT",
     "callerIp": "IP_ADDRESS",
     "callerIpGeo": {
        "regionCode": "US"
      },
     "serviceName": "SERVICE_NAME",
     "methodName": "METHOD_NAME",
     "serviceAccountKeyName": "LEAKED_SERVICE_ACCOUNT_KEY"
   },
   "assetDisplayName": "ASSET_DISPLAY_NAME",
   "assetId": "organizations/ORGANIZATION_NUMBER/assets/ASSET_ID",
   "canonicalName": "projects/PROJECT_NUMBER/sources/SOURCE_ID/findings/FINDING_ID",
   "category": "Initial Access: Leaked Service Account Key Used",
   "contacts": {
     "security": {
       "contacts": [
         {
           "email": "EMAIL_ADDRESS"
         }
       ]
     },
     "technical": {
       "contacts": [
         {
           "email": "EMAIL_ADDRESS"
         }
       ]
     }
   },
   "createTime": "2023-07-18T10:35:47.381Z",
   "database": {},
   "eventTime": "2023-07-18T10:35:47.270Z",
   "exfiltration": {},
   "findingClass": "THREAT",
   "findingProviderId": "organizations/ORGANIZATION_NUMBER/firstPartyFindingProviders/etd",
   "indicator": {},
   "kernelRootkit": {},
   "kubernetes": {},
   "mitreAttack": {
    "primaryTactic": "INITIAL_ACCESS",
    "primaryTechniques": [
      "VALID_ACCOUNTS",
      "CLOUD_ACCOUNTS"
      ]
   },
   "mute": "UNDEFINED",
   "name": "organizations/ORGANIZATION_NUMBER/sources/SOURCE_ID/findings/FINDING_ID",
   "parent": "organizations/ORGANIZATION_NUMBER/sources/SOURCE_ID",
   "parentDisplayName": "Event Threat Detection",
   "resourceName": "AFFECTED_RESOURCE",
   "severity": "HIGH",
   "sourceDisplayName": "Event Threat Detection",
   "state": "ACTIVE",
   "vulnerability": {},
   "workflowState": "NEW"
 },
 "resource": {
   "name": "RESOURCE_NAME",
   "display_name": "RESOURCE_DISPLAY_NAME",
   "project_name": "//cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER",
   "project_display_name": "PROJECT_ID",
 },
 "sourceProperties": {
   "sourceId": {
     "projectNumber": "PROJECT_NUMBER",
     "customerOrganizationNumber": "ORGANIZATION_NUMBER"
   },
   "detectionCategory": {
     "ruleName": "leaked_sa_key_used"
   },
   "detectionPriority": "HIGH",
   "affectedResources": [
     {
       "gcpResourceName": "GOOGLE_RESOURCE"
     }
   ],
   "evidence": [
     {
       "sourceLogId": {
         "projectId": "PROJECT_ID",
         "resourceContainer": "projects/PROJECT_ID",
         "timestamp": {
           "seconds": "1673519681",
           "nanos": 728289000
         },
         "insertId": "INSERT_ID"
       }
     }
   ],
   "properties": {},
   "findingId": "FINDING_ID",
   "contextUris": {
     "mitreUri": {
       "displayName": "MITRE Link",
       "url": "https://attack.mitre.org/techniques/T1078/004/"
     }
   }
 },
 "description": "A leaked service account key is used, the key is leaked at LEAKED_SOURCE_URL"
}
```

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