First Time Seen Google Workspace OAuth Login from Third-Party Application

Detects the first time a third-party application logs in and authenticated with OAuth. OAuth is used to grant permissions to specific resources and services in Google Workspace. Compromised credentials or service accounts could allow an adversary to authenticate to Google Workspace as a valid user and inherit their privileges.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2023/03/30"
 3integration = ["google_workspace"]
 4maturity = "production"
 5min_stack_comments = "Breaking changes for Google Workspace integration."
 6min_stack_version = "8.4.0"
 7updated_date = "2023/06/22"
 8
 9[rule]
10author = ["Elastic"]
11description = """
12Detects the first time a third-party application logs in and authenticated with OAuth. OAuth is used to grant permissions to specific resources and services in Google Workspace. Compromised credentials or service accounts could allow an adversary to authenticate to Google Workspace as a valid user and inherit their privileges.
13"""
14false_positives = [
15    """
16    Developers may leverage third-party applications for legitimate purposes in Google Workspace such as for administrative tasks.
17    """,
18]
19from = "now-130m"
20index = ["filebeat-*", "logs-google_workspace*"]
21interval = "10m"
22language = "kuery"
23license = "Elastic License v2"
24name = "First Time Seen Google Workspace OAuth Login from Third-Party Application"
25note = """## Setup
26The Google Workspace Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.
27### Important Information Regarding Google Workspace Event Lag Times
28- 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.
29- This rule is configured to run every 10 minutes with a lookback time of 130 minutes.
30- 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.
31- By default, `var.interval` is set to 2 hours (2h). Consider changing this interval to a lower value, such as 10 minutes (10m).
32- See the following references for further information:
33  - https://support.google.com/a/answer/7061566
34  - https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-google_workspace.html"""
35references = [
36    "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-one",
37    "https://developers.google.com/apps-script/guides/bound",
38    "https://developers.google.com/identity/protocols/oauth2",
39]
40risk_score = 47
41rule_id = "21bafdf0-cf17-11ed-bd57-f661ea17fbcc"
42severity = "medium"
43tags = ["Domain: Cloud", "Data Source: Google Workspace", "Tactic: Defense Evasion", "Tactic: Initial Access"]
44timestamp_override = "event.ingested"
45type = "new_terms"
46
47query = '''
48event.dataset: "google_workspace.token" and event.action: "authorize" and
49google_workspace.token.scope.data.scope_name: *Login and google_workspace.token.client.id: *apps.googleusercontent.com
50'''
51
52
53[[rule.threat]]
54framework = "MITRE ATT&CK"
55[[rule.threat.technique]]
56id = "T1550"
57name = "Use Alternate Authentication Material"
58reference = "https://attack.mitre.org/techniques/T1550/"
59[[rule.threat.technique.subtechnique]]
60id = "T1550.001"
61name = "Application Access Token"
62reference = "https://attack.mitre.org/techniques/T1550/001/"
63
64
65
66[rule.threat.tactic]
67id = "TA0005"
68name = "Defense Evasion"
69reference = "https://attack.mitre.org/tactics/TA0005/"
70
71[[rule.threat]]
72framework = "MITRE ATT&CK"
73[[rule.threat.technique]]
74id = "T1078"
75name = "Valid Accounts"
76reference = "https://attack.mitre.org/techniques/T1078/"
77[[rule.threat.technique.subtechnique]]
78id = "T1078.004"
79name = "Cloud Accounts"
80reference = "https://attack.mitre.org/techniques/T1078/004/"
81
82
83
84[rule.threat.tactic]
85id = "TA0001"
86name = "Initial Access"
87reference = "https://attack.mitre.org/tactics/TA0001/"
88
89[rule.new_terms]
90field = "new_terms_fields"
91value = ["google_workspace.token.client.id"]
92
93[[rule.new_terms.history_window_start]]
94field = "history_window_start"
95value = "now-15d"```

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.
  • This rule is configured to run every 10 minutes with a lookback time of 130 minutes.
  • 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