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