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

Audit logs are examined to detect the addition of IAM
role bindings that might be considered suspicious.

The following are examples of anomalous grants:

- Inviting an external user, such as gmail.com user, as a project owner from the Google Cloud console
- A service account granting sensitive permissions
- A custom role granting sensitive permissions
- A service account added from outside your organization or project

The `IAM Anomalous Grant` finding is unique in that it includes
sub-rules that provide more specific information about each instance
of this finding. The severity classification of this finding depends
on the sub-rule. Each sub-rule might require a different response.

The following list shows all possible sub-rules and their severities:

- `external_service_account_added_to_policy`:
  - `HIGH`, if a highly sensitive role was granted or if a medium-sensitivity role was granted at the organization level. For more information, see [Highly-sensitive roles](https://docs.cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview.md.txt#high-sensitivity-roles).
  - `MEDIUM`, if a medium sensitivity role was granted. For more information, see [Medium-sensitivity roles](https://docs.cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview.md.txt#medium-sensitivity-roles).
- `external_member_invited_to_policy`: `HIGH`
- `external_member_added_to_policy`:
  - `HIGH`, if a highly sensitive role was granted or if a medium-sensitivity role was granted at the organization level. For more information, see [Highly-sensitive roles](https://docs.cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview.md.txt#high-sensitivity-roles).
  - `MEDIUM`, if a medium sensitivity role was granted. For more information, see [Medium-sensitivity roles](https://docs.cloud.google.com/security-command-center/docs/concepts-event-threat-detection-overview.md.txt#medium-sensitivity-roles).
- `custom_role_given_sensitive_permissions`: `MEDIUM`
- `service_account_granted_sensitive_role_to_member`: `HIGH`
- `policy_modified_by_default_compute_service_account`: `HIGH`

[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 a `Persistence: IAM Anomalous Grant` finding as directed in
   [Reviewing findings](https://docs.cloud.google.com/security-command-center/docs/how-to-investigate-threats.md.txt#reviewing_findings). The details panel for the
   finding opens to the **Summary** tab.

2. On the **Summary** tab, review the information in the following sections:

   - **What was detected** , especially the following fields:
     - **Principal email**: email address for the user or service account that assigned the role.
   - **Affected resource**

   - **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.
     - **VirusTotal indicator**: link to the VirusTotal analysis page.
3. Click the **JSON** tab. The complete JSON of the finding is displayed.

4. In the JSON for the finding, note the following fields:

   - `detectionCategory`:
     - `subRuleName`: more specific information about the type of anomalous grant that occurred. The sub-rule determines the severity classification of this finding.
   - `evidence`:
     - `sourceLogId`:
     - `projectId`: the ID of the project that contains the finding.
   - `properties`:
     - `sensitiveRoleGrant`:
       - `bindingDeltas`:
       - `Action`: the action taken by the user.
       - `Role`: the role assigned to the user.
       - `member`: the email address of the user that received the role.

### Step 2: Check logs

1. On the **Summary tab** of the finding details panel, click the **Cloud Logging URI** link to open the **Logs Explorer**.
2. On the page that loads, look for new or updated IAM resources using the following filters:
   - `protoPayload.methodName="SetIamPolicy"`
   - `protoPayload.methodName="google.iam.admin.v1.UpdateRole"`
   - `protoPayload.methodName="google.iam.admin.v1.CreateRole"`

### Step 3: Research attack and response methods

1. Review MITRE ATT\&CK framework entries for this finding type: [Valid Accounts: Cloud Accounts](https://attack.mitre.org/techniques/T1078/004/).
2. Review related findings by clicking the link on the **Related findings** row in the **Summary** tab of the finding details. Related findings are the same finding type and the same instance and network.
3. To develop a response plan, 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.

- Contact the owner of the project with the compromised account.
- [Delete the compromised service account](https://docs.cloud.google.com/iam/docs/service-accounts-delete-undelete.md.txt#deleting) and rotate and delete all service account access keys for the compromised project. After deletion, resources that use the service account for authentication lose access.
- Delete project resources created by unauthorized accounts, like unfamiliar Compute Engine instances, snapshots, service accounts, and IAM users.
- To restrict adding gmail.com users, use the [Organization Policy](https://docs.cloud.google.com/resource-manager/docs/organization-policy/overview).
- To identify and fix overly permissive roles, use [IAM
  Recommender](https://docs.cloud.google.com/iam/docs/recommender-overview).

## Example finding JSON

The following is an example of the finding JSON.

```json
{
  "findings": {
    "access": {
      "principalEmail": "PRINCIPAL_EMAIL",
      "callerIp": "IP_ADDRESS",
      "callerIpGeo": {
        "regionCode": "REGION_CODE"
      },
      "serviceName": "SERVICE_NAME",
      "methodName": "METHOD_NAME",
      "principalSubject": "PRINCIPAL_SUBJECT",
      "serviceAccountKeyName": "SERVICE_ACCOUNT_KEY_NAME"
    },
    "assetDisplayName": "ASSET_DISPLAY_NAME",
    "assetId": "organizations/ORGANIZATION_ID/assets/ASSET_ID",
    "canonicalName": "projects/PROJECT_NUMBER/sources/SOURCE_ID/findings/FINDING_ID",
    "category": "Persistence: IAM Anomalous Grant",
    "cloudDlpInspection": {},
    "contacts": {
      "security": {
        "contacts": [
          {
            "email": "EMAIL_ADDRESS_1"
          },
          {
            "email": "EMAIL_ADDRESS_2"
          }
        ]
      },
      "technical": {
        "contacts": [
          {
            "email": "EMAIL_ADDRESS_3"
          },
          {
            "email": "EMAIL_ADDRESS_4"
          }
        ]
      }
    },
    "createTime": "CREATE_TIMESTAMP",
    "database": {},
    "eventTime": "EVENT_TIMESTAMP",
    "exfiltration": {},
    "findingClass": "THREAT",
    "findingProviderId": "organizations/ORGANIZATION_ID/firstPartyFindingProviders/etd",
    "iamBindings": [
      {
        "action": "ADD",
        "role": "IAM_ROLE",
        "member": "serviceAccount:ACCOUNT_NAME"
      }
    ],
    "indicator": {},
    "kernelRootkit": {},
    "kubernetes": {},
    "mitreAttack": {
      "primaryTactic": "INITIAL_ACCESS",
      "primaryTechniques": [
        "VALID_ACCOUNTS",
        "CLOUD_ACCOUNTS"
      ]
    },
    "mute": "UNDEFINED",
    "name": "organizations/ORGANIZATION_ID/sources/SOURCE_ID/findings/FINDING_ID",
    "parent": "organizations/ORGANIZATION_ID/sources/SOURCE_ID",
    "parentDisplayName": "Event Threat Detection",
    "resourceName": "RESOURCE_FULL_NAME",
    "severity": "SEVERITY_CLASSIFICATION",
    "state": "ACTIVE",
    "vulnerability": {},
    "workflowState": "NEW"
  },
  "resource": {
    "name": "RESOURCE_FULL_NAME",
    "display_name": "RESOURCE_DISPLAY_NAME",
    "project_name": "//RESOURCE/projects/PROJECT_NUMBER",
    "project_display_name": "PROJECT_ID",
    "parent_name": "RESOURCE_PARENT_NAME",
    "parent_display_name": "PARENT_DISPLAY_NAME",
    "type": "RESOURCE_TYPE",
    "folders": [
      {
        "resourceFolderDisplayName": "RESOURCE_FOLDER_DISPLAY_NAME",
        "resourceFolder": "RESOURCE_FOLDER_ID"
      }
    ]
  },
  "sourceProperties": {
    "sourceId": {
      "projectNumber": "PROJECT_NUMBER",
      "customerOrganizationNumber": "ORGANIZATION_ID"
    },
    "detectionCategory": {
      "technique": "persistence",
      "indicator": "audit_log",
      "ruleName": "iam_anomalous_grant",
      "subRuleName": "TYPE_OF_ANOMALOUS_GRANT"
    },
    "detectionPriority": "HIGH",
    "affectedResources": [
      {
        "gcpResourceName": "GOOGLE_CLOUD_RESOURCE_NAME"
      }
    ],
    "evidence": [
      {
        "sourceLogId": {
          "projectId": "PROJECT_ID",
          "resourceContainer": "projects/PROJECT_ID",
          "timestamp": {
            "seconds": "1678897327",
            "nanos": 26483000
          },
          "insertId": "INSERT_ID"
        }
      }
    ],
    "properties": {
      "sensitiveRoleGrant": {
        "principalEmail": "PRINCIPAL_EMAIL",
        "bindingDeltas": [
          {
            "action": "ADD",
            "role": "roles/GRANTED_ROLE",
            "member": "serviceAccount:SERVICE_ACCOUNT_NAME",
          }
        ],
        "members": [
          "serviceAccount:SERVICE_ACCOUNT_NAME"
        ]
      }
    },
    "findingId": "FINDING_ID",
    "contextUris": {
      "mitreUri": {
        "displayName": "MITRE Link",
        "url": "https://attack.mitre.org/techniques/T1078/004/"
      },
      "cloudLoggingQueryUri": [
        {
          "displayName": "Cloud Logging Query Link",
          "url": "LINK_TO_LOG_QUERY"
        }
      ],
      "relatedFindingUri": {
        "displayName": "Related Anomalous Grant Findings",
        "url": "LINK_TO_RELATED_FINDING"
      }
    }
  }
}
```

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