Google Workspace API Access Granted via Domain-Wide Delegation

Detects when a domain-wide delegation of authority is granted to a service account. Domain-wide delegation can be configured to grant third-party and internal applications to access the data of Google Workspace users. An adversary may configure domain-wide delegation to maintain access to their target’s data.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/11/12"
  3integration = ["google_workspace"]
  4maturity = "production"
  5updated_date = "2024/09/23"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects when a domain-wide delegation of authority is granted to a service account. Domain-wide delegation can be
 11configured to grant third-party and internal applications to access the data of Google Workspace users. An adversary may
 12configure domain-wide delegation to maintain access to their target’s data.
 13"""
 14false_positives = [
 15    """
 16    Domain-wide delegation of authority may be granted to service accounts by system administrators. Verify that the
 17    configuration change was expected. Exceptions can be added to this rule to filter expected behavior.
 18    """,
 19]
 20from = "now-9m"
 21index = ["filebeat-*", "logs-google_workspace*"]
 22language = "kuery"
 23license = "Elastic License v2"
 24name = "Google Workspace API Access Granted via Domain-Wide Delegation"
 25note = """## Triage and analysis
 26
 27### Investigating Google Workspace API Access Granted via Domain-Wide Delegation
 28
 29Domain-wide delegation is a feature that allows apps to access users' data across an organization's Google Workspace environment. Only super admins can manage domain-wide delegation, and they must specify each API scope that the application can access. Google Workspace services all have APIs that can be interacted with after domain-wide delegation is established with an OAuth2 client ID of the application. Typically, GCP service accounts and applications are created where the Google Workspace APIs are enabled, thus allowing the application to access resources and services in Google Workspace.
 30
 31Applications authorized to interact with Google Workspace resources and services through APIs have a wide range of capabilities depending on the scopes applied. If the principle of least privilege (PoLP) is not practiced when setting API scopes, threat actors could abuse additional privileges if the application is compromised. New applications created and given API access could indicate an attempt by a threat actor to register their malicious application with the Google Workspace domain in an attempt to establish a command and control foothold.
 32
 33This rule identifies when an application is authorized API client access.
 34
 35#### Possible investigation steps
 36
 37- Identify the associated user accounts by reviewing `user.name` or `user.email` fields in the alert.
 38  - Only users with super admin privileges can authorize API client access.
 39- Identify the API client name by reviewing the `google_workspace.admin.api.client.name` field in the alert.
 40  - If GCP audit logs are ingested, pivot to reviewing the last 48 hours of activity related to the service account ID.
 41  - Search for the `google_workspace.admin.api.client.name` value with wildcards in the `gcp.audit.resource_name` field.
 42  - Search for API client name and aggregated results on `event.action` to determine what the service account is being used for in GWS.
 43- After identifying the involved user, verify super administrative privileges to access domain-wide delegation settings.
 44
 45### False positive analysis
 46
 47- Changes to domain-wide delegation require super admin privileges. Check with the user to ensure these changes were expected.
 48- Review scheduled maintenance notes related to expected API access changes.
 49
 50### Response and remediation
 51
 52- Initiate the incident response process based on the outcome of the triage.
 53- Review the scope of the authorized API client access in Google Workspace.
 54- Disable or limit the account during the investigation and response.
 55- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
 56    - Identify the account role in the cloud environment.
 57    - Assess the criticality of affected services and servers.
 58    - Work with your IT team to identify and minimize the impact on users.
 59    - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
 60    - Identify any regulatory or legal ramifications related to this activity.
 61- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
 62- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
 63- Implement security best practices [outlined](https://support.google.com/a/answer/7587183) by Google.
 64- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
 65- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
 66
 67## Setup
 68
 69The Google Workspace Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.
 70
 71### Important Information Regarding Google Workspace Event Lag Times
 72- As per Google's documentation, Google Workspace administrators may observe lag times ranging from minutes up to 3 days between the time of an event's occurrence and the event being visible in the Google Workspace admin/audit logs.
 73- To reduce the risk of false negatives, consider reducing the interval that the Google Workspace (formerly G Suite) Filebeat module polls Google's reporting API for new events.
 74- By default, `var.interval` is set to 2 hours (2h). Consider changing this interval to a lower value, such as 10 minutes (10m).
 75- See the following references for further information:
 76  - https://support.google.com/a/answer/7061566
 77  - https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-google_workspace.html"""
 78references = [
 79    "https://developers.google.com/admin-sdk/directory/v1/guides/delegation",
 80    "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-one",
 81    "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-two"
 82]
 83risk_score = 47
 84rule_id = "acbc8bb9-2486-49a8-8779-45fb5f9a93ee"
 85severity = "medium"
 86tags = [
 87    "Domain: Cloud",
 88    "Data Source: Google Workspace",
 89    "Use Case: Identity and Access Audit",
 90    "Resources: Investigation Guide",
 91    "Tactic: Persistence",
 92]
 93timestamp_override = "event.ingested"
 94type = "query"
 95
 96query = '''
 97event.dataset:google_workspace.admin
 98  and event.provider:admin
 99  and event.category:iam
100  and event.action:AUTHORIZE_API_CLIENT_ACCESS
101  and event.outcome:success
102'''
103
104
105[[rule.threat]]
106framework = "MITRE ATT&CK"
107[[rule.threat.technique]]
108id = "T1098"
109name = "Account Manipulation"
110reference = "https://attack.mitre.org/techniques/T1098/"
111
112
113[rule.threat.tactic]
114id = "TA0003"
115name = "Persistence"
116reference = "https://attack.mitre.org/tactics/TA0003/"

Triage and analysis

Investigating Google Workspace API Access Granted via Domain-Wide Delegation

Domain-wide delegation is a feature that allows apps to access users' data across an organization's Google Workspace environment. Only super admins can manage domain-wide delegation, and they must specify each API scope that the application can access. Google Workspace services all have APIs that can be interacted with after domain-wide delegation is established with an OAuth2 client ID of the application. Typically, GCP service accounts and applications are created where the Google Workspace APIs are enabled, thus allowing the application to access resources and services in Google Workspace.

Applications authorized to interact with Google Workspace resources and services through APIs have a wide range of capabilities depending on the scopes applied. If the principle of least privilege (PoLP) is not practiced when setting API scopes, threat actors could abuse additional privileges if the application is compromised. New applications created and given API access could indicate an attempt by a threat actor to register their malicious application with the Google Workspace domain in an attempt to establish a command and control foothold.

This rule identifies when an application is authorized API client access.

Possible investigation steps

  • Identify the associated user accounts by reviewing user.name or user.email fields in the alert.
    • Only users with super admin privileges can authorize API client access.
  • Identify the API client name by reviewing the google_workspace.admin.api.client.name field in the alert.
    • If GCP audit logs are ingested, pivot to reviewing the last 48 hours of activity related to the service account ID.
    • Search for the google_workspace.admin.api.client.name value with wildcards in the gcp.audit.resource_name field.
    • Search for API client name and aggregated results on event.action to determine what the service account is being used for in GWS.
  • After identifying the involved user, verify super administrative privileges to access domain-wide delegation settings.

False positive analysis

  • Changes to domain-wide delegation require super admin privileges. Check with the user to ensure these changes were expected.
  • Review scheduled maintenance notes related to expected API access changes.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Review the scope of the authorized API client access in Google Workspace.
  • Disable or limit the account during the investigation and response.
  • Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
    • Identify the account role in the cloud environment.
    • Assess the criticality of affected services and servers.
    • Work with your IT team to identify and minimize the impact on users.
    • Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
    • Identify any regulatory or legal ramifications related to this activity.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
  • Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
  • Implement security best practices outlined by Google.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

Setup

The Google Workspace Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.

Important Information Regarding Google Workspace Event Lag Times

  • As per Google's documentation, Google Workspace administrators may observe lag times ranging from minutes up to 3 days between the time of an event's occurrence and the event being visible in the Google Workspace admin/audit logs.
  • To reduce the risk of false negatives, consider reducing the interval that the Google Workspace (formerly G Suite) Filebeat module polls Google's reporting API for new events.
  • By default, var.interval is set to 2 hours (2h). Consider changing this interval to a lower value, such as 10 minutes (10m).
  • See the following references for further information:

References

Related rules

to-top