First Time Seen Google Workspace OAuth Login from Third-Party Application
Detects the first time a user authorizes a third-party Google OAuth application that requests identity or sign-in scopes. Adversaries may abuse compromised credentials or phishing-linked consent flows to register novel OAuth clients, obtain refresh tokens, and authenticate as valid users while evading password-only detections.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/03/30"
3integration = ["google_workspace"]
4maturity = "production"
5updated_date = "2026/09/18"
6
7[rule]
8author = ["Elastic"]
9description = """
10Detects the first time a user authorizes a third-party Google OAuth application that requests identity or sign-in
11scopes. Adversaries may abuse compromised credentials or phishing-linked consent flows to register novel OAuth clients,
12obtain refresh tokens, and authenticate as valid users while evading password-only detections.
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 = ["logs-google_workspace.token-*"]
22interval = "10m"
23language = "kuery"
24license = "Elastic License v2"
25name = "First Time Seen Google Workspace OAuth Login from Third-Party Application"
26note = """## Triage and analysis
27
28### Investigating First Time Seen Google Workspace OAuth Login from Third-Party Application
29
30Threat actors may trick users into authorizing adversary-controlled OAuth applications after credential theft, AiTM
31relay, or spearphishing. A successful `authorize` grant issues tokens the application can reuse to act on behalf of the
32user. Novel third-party client IDs are a strong signal as malicious consent often appears as a first-time application in the tenant.
33
34This rule uses `new_terms` to flag the first appearance of a `google_workspace.token.client.id` when
35a user grants at least one identity or sign-in scope in `google_workspace.token.scope.value` (for example `openid`,
36`userinfo.email`, `userinfo.profile`, or `OAuthLogin`).
37
38### Possible investigation steps
39
40- Identify the user who authorized the application by reviewing `user.email` or `user.name`, and note `source.ip` and `event.ingested` if present in the alert.
41- Identify the application by reviewing `google_workspace.token.app_name` and `google_workspace.token.client.id`.
42- Review granted scopes in `google_workspace.token.scope.value` to determine whether the app received identity-only access or additional permissions (for example calendar, drive, or mail scopes on the same grant).
43- Determine whether the authorization is expected and authorized:
44 - If `source.ip` or timing is unusual for the user, treat the alert as higher priority until proven benign.'
45
46- Search Kibana for related activity:
47 - Find prior authorizations for the same client in the org:
48 ```
49 data_stream.dataset: "google_workspace.token" and event.action: "authorize" and google_workspace.token.client.id: "<CLIENT_ID>"
50 ```
51 - Correlate with sign-in anomalies for the same user:
52 ```
53 data_stream.dataset: "google_workspace.login" and user.email: "<USER_EMAIL>"
54 ```
55 - Scope for other OAuth or admin changes from the same `user.email` within the last 48 hours.
56
57### False positive analysis
58
59- Internal development or QA OAuth clients may appear as new `client.id` values during testing; coordinate with engineering teams and exclude known test clients if needed.
60- Some vendors rotate OAuth client IDs during major upgrades, which can look like a new application, confirm with the vendor or IT owner before closing as benign.
61
62### Response and remediation
63
64- Initiate the incident response process based on triage findings.
65- If the authorization is not clearly authorized, revoke the application's access for the affected user under Security > Access and data control > API controls (or remove the user token via admin OAuth reports).
66- If the user account is suspected compromised, reset credentials, revoke active sessions, and review all OAuth grants for that user.
67- Review activity performed with the new token (Drive, Gmail, Calendar, or other services implied by `google_workspace.token.scope.value`).
68- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
69 - Identify the account role in the cloud environment.
70 - Assess the criticality of affected services and servers.
71 - Work with your IT team to identify and minimize the impact on users.
72 - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
73 - Identify any regulatory or legal ramifications related to this activity.
74- 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.
75- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
76- Implement security best practices [outlined](https://support.google.com/a/answer/7587183) by Google.
77- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
78- 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).
79
80## Setup
81
82The Google Workspace Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.
83
84### Important Information Regarding Google Workspace Event Lag Times
85- 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.
86- This rule is configured to run every 10 minutes with a lookback time of 130 minutes.
87- By default, `var.interval` is set to 2 hours (2h). Consider changing this interval to a lower value, such as 10 minutes (10m).
88- See the following references for further information:
89 - https://support.google.com/a/answer/7061566"""
90references = [
91 "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-one",
92 "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-two",
93 "https://developers.google.com/apps-script/guides/bound",
94 "https://developers.google.com/identity/protocols/oauth2",
95]
96risk_score = 47
97rule_id = "21bafdf0-cf17-11ed-bd57-f661ea17fbcc"
98severity = "medium"
99tags = [
100 "Domain: Cloud",
101 "Data Source: Google Workspace",
102 "Tactic: Defense Evasion",
103 "Tactic: Initial Access",
104 "Tactic: Persistence",
105 "Resources: Investigation Guide",
106 "Noise: Medium",
107 "Performance: Fast",
108 "Rule Type: New Terms",
109 "Platform: Google Workspace",
110 "Domain: SaaS",
111]
112timestamp_override = "event.ingested"
113type = "new_terms"
114
115query = '''
116data_stream.dataset: "google_workspace.token"
117 and event.action: "authorize"
118 and google_workspace.token.scope.value: (*openid* or *userinfo.email* or *userinfo.profile* or *Login*)
119 and google_workspace.token.client.id: *apps.googleusercontent.com
120'''
121
122
123[[rule.threat]]
124framework = "MITRE ATT&CK"
125[[rule.threat.technique]]
126id = "T1550"
127name = "Use Alternate Authentication Material"
128reference = "https://attack.mitre.org/techniques/T1550/"
129[[rule.threat.technique.subtechnique]]
130id = "T1550.001"
131name = "Application Access Token"
132reference = "https://attack.mitre.org/techniques/T1550/001/"
133
134
135
136[rule.threat.tactic]
137id = "TA0005"
138name = "Defense Evasion"
139reference = "https://attack.mitre.org/tactics/TA0005/"
140[[rule.threat]]
141framework = "MITRE ATT&CK"
142[[rule.threat.technique]]
143id = "T1078"
144name = "Valid Accounts"
145reference = "https://attack.mitre.org/techniques/T1078/"
146[[rule.threat.technique.subtechnique]]
147id = "T1078.004"
148name = "Cloud Accounts"
149reference = "https://attack.mitre.org/techniques/T1078/004/"
150
151
152
153[rule.threat.tactic]
154id = "TA0001"
155name = "Initial Access"
156reference = "https://attack.mitre.org/tactics/TA0001/"
157[[rule.threat]]
158framework = "MITRE ATT&CK"
159[[rule.threat.technique]]
160id = "T1078"
161name = "Valid Accounts"
162reference = "https://attack.mitre.org/techniques/T1078/"
163[[rule.threat.technique.subtechnique]]
164id = "T1078.004"
165name = "Cloud Accounts"
166reference = "https://attack.mitre.org/techniques/T1078/004/"
167
168
169
170[rule.threat.tactic]
171id = "TA0003"
172name = "Persistence"
173reference = "https://attack.mitre.org/tactics/TA0003/"
174
175[rule.investigation_fields]
176field_names = [
177 "user.name",
178 "user.email",
179 "source.ip",
180 "user.domain",
181 "event.action",
182 "google_workspace.token.app_name",
183 "google_workspace.token.client.type",
184 "google_workspace.token.client.id",
185 "google_workspace.token.scope.value",
186]
187
188[rule.new_terms]
189field = "new_terms_fields"
190value = ["google_workspace.token.client.id"]
191[[rule.new_terms.history_window_start]]
192field = "history_window_start"
193value = "now-15d"
Triage and analysis
Investigating First Time Seen Google Workspace OAuth Login from Third-Party Application
Threat actors may trick users into authorizing adversary-controlled OAuth applications after credential theft, AiTM
relay, or spearphishing. A successful authorize grant issues tokens the application can reuse to act on behalf of the
user. Novel third-party client IDs are a strong signal as malicious consent often appears as a first-time application in the tenant.
This rule uses new_terms to flag the first appearance of a google_workspace.token.client.id when
a user grants at least one identity or sign-in scope in google_workspace.token.scope.value (for example openid,
userinfo.email, userinfo.profile, or OAuthLogin).
Possible investigation steps
-
Identify the user who authorized the application by reviewing
user.emailoruser.name, and notesource.ipandevent.ingestedif present in the alert. -
Identify the application by reviewing
google_workspace.token.app_nameandgoogle_workspace.token.client.id. -
Review granted scopes in
google_workspace.token.scope.valueto determine whether the app received identity-only access or additional permissions (for example calendar, drive, or mail scopes on the same grant). -
Determine whether the authorization is expected and authorized:
- If
source.ipor timing is unusual for the user, treat the alert as higher priority until proven benign.'
- If
-
Search Kibana for related activity:
- Find prior authorizations for the same client in the org:
1data_stream.dataset: "google_workspace.token" and event.action: "authorize" and google_workspace.token.client.id: "<CLIENT_ID>" - Correlate with sign-in anomalies for the same user:
1data_stream.dataset: "google_workspace.login" and user.email: "<USER_EMAIL>" - Scope for other OAuth or admin changes from the same
user.emailwithin the last 48 hours.
- Find prior authorizations for the same client in the org:
False positive analysis
- Internal development or QA OAuth clients may appear as new
client.idvalues during testing; coordinate with engineering teams and exclude known test clients if needed. - Some vendors rotate OAuth client IDs during major upgrades, which can look like a new application, confirm with the vendor or IT owner before closing as benign.
Response and remediation
- Initiate the incident response process based on triage findings.
- If the authorization is not clearly authorized, revoke the application's access for the affected user under Security > Access and data control > API controls (or remove the user token via admin OAuth reports).
- If the user account is suspected compromised, reset credentials, revoke active sessions, and review all OAuth grants for that user.
- Review activity performed with the new token (Drive, Gmail, Calendar, or other services implied by
google_workspace.token.scope.value). - 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.
- This rule is configured to run every 10 minutes with a lookback time of 130 minutes.
- By default,
var.intervalis 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
- Google Workspace User Sign-in from Atypical Device Type
- Google Workspace Suspended User Account Renewed
- Entra ID Service Principal Federated Credential Authentication by Unusual Client
- External User Added to Google Workspace Group
- GitHub Actions Unusual Bot Push to Repository