Google Workspace Object Copied from External Drive with App Consent

Detects when a Workspace user copies a document, spreadsheet, form, or script from an external Drive into their My Drive and, within minutes from the same IP, authorizes a custom web OAuth client that requests an Apps Script scope. script.container is the container sidebar or dialog. The check also matches any other script.* scope, a *.currentonly scope, or a scope containing scripts or container. Adversaries send spearphishing links with a /copy URI parameter so the victim replicates a malicious object locally. Google names that replica with a "Copy of " prefix. The copy is performed by a domain user rather than a collaborator account, and the consent is not a known Google first-party client.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/03/07"
  3integration = ["google_workspace"]
  4maturity = "production"
  5min_stack_comments = "Changing min stack to 9.3.0, the latest minimum supported version for 9.X releases."
  6min_stack_version = "9.4.0"
  7updated_date = "2026/11/03"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Detects when a Workspace user copies a document, spreadsheet, form, or script from an external Drive into their My Drive
 13and, within minutes from the same IP, authorizes a custom web OAuth client that requests an Apps Script scope.
 14`script.container` is the container sidebar or dialog. The check also matches any other `script.*` scope, a
 15`*.currentonly` scope, or a scope containing `scripts` or `container`. Adversaries send spearphishing links with a /copy
 16URI parameter so the victim replicates a malicious object locally. Google names that replica with a "Copy of " prefix.
 17The copy is performed by a domain user rather than a collaborator account, and the consent is not a known Google
 18first-party client.
 19"""
 20false_positives = [
 21    """
 22    A user may copy a public template that uses a container-bound script and consent to that add-on within three minutes
 23    from the same IP. Confirm the OAuth client with the template owner before treating the grant as malicious.
 24    """,
 25    """
 26    The copied-title check looks for the English text "Copy of ". Workspace locales that translate that prefix will not
 27    match.
 28    """,
 29]
 30from = "now-130m"
 31index = ["logs-google_workspace.*"]
 32interval = "10m"
 33language = "eql"
 34license = "Elastic License v2"
 35name = "Google Workspace Object Copied from External Drive with App Consent"
 36note = """## Triage and analysis
 37
 38### Investigating Google Workspace Object Copied from External Drive with App Consent
 39
 40A `/copy` link replicates a document, spreadsheet, form, or script into the recipient's Drive with a `Copy of` title, and a container-bound Apps Script can then prompt for consent when the object is opened. This rule correlates that external My Drive copy (`copy_type: external`, `actor_is_collaborator_account: false`, `owner_is_team_drive: false`) with a custom web OAuth grant (`client.type: WEB`, client id ending in `apps.googleusercontent.com`) for the same `source.user.email` and `source.ip` within `maxspan=3m`. The grant must include an Apps Script scope: `script.container` (the container sidebar or dialog), any other `script.*` scope, a `*.currentonly` scope, or a scope containing `scripts` or `container`. Known Google first-party clients and Cloud project `857627895310` are excluded. Compare `google_workspace.token.app_name` with `file.name` and review `google_workspace.token.scope.value`. Broader scopes such as `spreadsheets`, `drive`, or `gmail` do not match on their own, and visibility is not filtered.
 41
 42### Possible investigation steps
 43
 44- Identify the affected user from `source.user.email` or `user.email`. Note `source.ip` and compare `@timestamp`
 45  (event time) on the copy and the authorize event.
 46- Drive copy event (`google_workspace.drive`):
 47  - Review `file.name` and `google_workspace.drive.file.type` to identify what was copied. Confirm the title contains
 48    `Copy of`.
 49  - For deeper review, pivot on `google_workspace.drive.file.id` or `file.name` in Drive audit logs and Admin console
 50    Drive investigation.
 51- OAuth authorize event (`google_workspace.token`):
 52  - Review `google_workspace.token.app_name` and `google_workspace.token.client.id` to identify the application.
 53    Check whether the app name appears in the copied title.
 54  - Review granted scopes in `google_workspace.token.scope.value` to determine which services the token can access
 55    (for example Drive, Gmail, or Calendar scopes beyond the current file).
 56  - Confirm `google_workspace.token.client.type` is `WEB` and that the client is not a known Google first-party client.
 57- Determine whether the activity is expected:
 58  - Contact the user to confirm they intentionally copied an external template and authorized the application.
 59  - If timing or `source.ip` is unusual for the user, treat as higher priority until validated.
 60- Search Kibana for related activity:
 61  - Determine whether other users copied the same external object:
 62    ```
 63    data_stream.dataset: "google_workspace.drive" and event.action: "copy" and google_workspace.drive.copy_type: "external" and file.name: "<FILE_NAME>"
 64    ```
 65  - Correlate with sign-in activity around the same window:
 66    ```
 67    data_stream.dataset: "google_workspace.login" and user.email: "<USER_EMAIL>"
 68    ```
 69  - Scope for other OAuth grants to the same client across the tenant:
 70    ```
 71    data_stream.dataset: "google_workspace.token" and event.action: "authorize" and google_workspace.token.client.id: "<CLIENT_ID>"
 72    ```
 73- If a container-bound script is suspected, locate the copied object in the user's Drive and review Apps Script code
 74  for exfiltration, token harvesting, or persistence logic. Remove the object from affected users' Drives.
 75
 76### False positive analysis
 77
 78- Users may legitimately copy public templates (spreadsheets, forms, or documents) from external drives and consent to
 79  a container-bound add-on within three minutes from the same IP. Compare `google_workspace.token.app_name` with
 80  `file.name` and review `google_workspace.token.scope.value` before closing the alert. Grants that do not include an
 81  Apps Script scope (`script.container` or another `script.*` scope, `*.currentonly`, `scripts`, or `container`) do not match.
 82- OAuth consent does not always follow the copy immediately. Opening the object later can separate the two actions
 83  beyond 180 seconds, which will not match even when the activity is related.
 84- Non-English Workspace locales translate the `Copy of ` prefix, so those replicas will not match.
 85
 86### Response and remediation
 87
 88- Initiate the incident response process based on triage findings.
 89- If the copy or OAuth grant is not clearly authorized, revoke the application's access for the affected user under
 90  Security > Access and data control > API controls (or remove the user token via admin OAuth reports).
 91- Remove malicious copied objects from affected users' Drives and report abusive OAuth clients to Google if appropriate.
 92- If the user account is suspected compromised, reset credentials, revoke active sessions, and review all OAuth grants
 93  for that user.
 94- Review activity performed with the authorized token based on scopes in `google_workspace.token.scope.value`.
 95- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
 96    - Identify the account role in the cloud environment.
 97    - Assess the criticality of affected services and servers.
 98    - Work with your IT team to identify and minimize the impact on users.
 99    - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
100    - Identify any regulatory or legal ramifications related to this activity.
101- 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.
102- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
103- Implement security best practices [outlined](https://support.google.com/a/answer/7587183) by Google.
104- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
105- 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).
106
107## Setup
108
109The Google Workspace Fleet integration or similarly structured data is required to be compatible with this rule.
110
111### Important Information Regarding Google Workspace Event Lag Times
112- 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.
113- This rule is configured to run every 10 minutes with a lookback time of 130 minutes and uses `timestamp_override: event.ingested` so delayed ingest does not drop events from the execution window. Sequence correlation and `maxspan` still use `@timestamp` event time.
114- Drive and token audit events may arrive on different schedules; the token integration polls Google's API on a longer default interval. To reduce false negatives, consider reducing the poll interval for both Drive and token data sources.
115- By default, `var.interval` is set to 2 hours (2h). Consider changing this interval to a lower value, such as 10 minutes (10m).
116"""
117references = [
118    "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-one",
119    "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-two",
120    "https://developers.google.com/apps-script/guides/bound",
121    "https://developers.google.com/identity/protocols/oauth2",
122    "https://support.google.com/a/users/answer/13004165#share_make_a_copy_links",
123]
124risk_score = 73
125rule_id = "f33e68a4-bd19-11ed-b02f-f661ea17fbcc"
126severity = "high"
127tags = [
128    "Domain: Cloud",
129    "Data Source: Google Workspace",
130    "Data Source: Google Workspace Audit Logs",
131    "Tactic: Initial Access",
132    "Tactic: Execution",
133    "Tactic: Persistence",
134    "Resources: Investigation Guide",
135    "Noise: Low",
136    "Performance: Fast",
137    "Profile: Recommended",
138    "Threat: OAuth App Consent",
139    "Rule Type: Event Correlation (EQL)",
140    "Platform: Google Workspace",
141    "Domain: SaaS",
142]
143timestamp_override = "event.ingested"
144type = "eql"
145
146query = '''
147sequence by source.user.email, source.ip with maxspan=3m
148[file where data_stream.dataset == "google_workspace.drive" and event.action == "copy" and
149
150    /* External My Drive replica by a domain user, not a collaborator account or shared drive */
151    google_workspace.drive.owner_is_team_drive == false and
152    google_workspace.drive.actor_is_collaborator_account == false and
153    google_workspace.drive.primary_event == true and
154    google_workspace.drive.copy_type == "external" and
155
156    /* Google Script, Forms, Sheets, and Documents can carry container-bound scripts */
157    google_workspace.drive.file.type : ("script", "form", "spreadsheet", "document") and
158
159    /* /copy links name the replica with this English prefix */
160    file.name : "Copy of*"]
161
162[any where data_stream.dataset == "google_workspace.token" and event.action == "authorize" and
163
164    /* Custom web OAuth client, not a numeric GCP service-account client */
165    google_workspace.token.client.type == "WEB" and
166    google_workspace.token.client.id : "*apps.googleusercontent.com" and
167
168    /* Client IDs are {cloud_project_number}-{oauth_client}.apps.googleusercontent.com. */
169    not google_workspace.token.client.id : (
170        "77185425430*.apps.googleusercontent.com",
171        "32555940559*.apps.googleusercontent.com",
172        "764086051850*.apps.googleusercontent.com",
173        "407408718192*.apps.googleusercontent.com",
174        "857627895310*.apps.googleusercontent.com"
175    ) and
176
177    /* script.container is the sidebar or dialog. Also match other script.* scopes,
178       container-bound *.currentonly, or a scope containing scripts or container */
179    google_workspace.token.scope.value : (
180        "*script.*",
181        "*.currentonly",
182        "*scripts*",
183        "*container*"
184    )]
185'''
186
187
188[[rule.threat]]
189framework = "MITRE ATT&CK"
190[[rule.threat.technique]]
191id = "T1566"
192name = "Phishing"
193reference = "https://attack.mitre.org/techniques/T1566/"
194[[rule.threat.technique.subtechnique]]
195id = "T1566.002"
196name = "Spearphishing Link"
197reference = "https://attack.mitre.org/techniques/T1566/002/"
198
199
200
201[rule.threat.tactic]
202id = "TA0001"
203name = "Initial Access"
204reference = "https://attack.mitre.org/tactics/TA0001/"
205[[rule.threat]]
206framework = "MITRE ATT&CK"
207[[rule.threat.technique]]
208id = "T1204"
209name = "User Execution"
210reference = "https://attack.mitre.org/techniques/T1204/"
211[[rule.threat.technique.subtechnique]]
212id = "T1204.001"
213name = "Malicious Link"
214reference = "https://attack.mitre.org/techniques/T1204/001/"
215
216
217
218[rule.threat.tactic]
219id = "TA0002"
220name = "Execution"
221reference = "https://attack.mitre.org/tactics/TA0002/"
222[[rule.threat]]
223framework = "MITRE ATT&CK"
224[[rule.threat.technique]]
225id = "T1098"
226name = "Account Manipulation"
227reference = "https://attack.mitre.org/techniques/T1098/"
228[[rule.threat.technique.subtechnique]]
229id = "T1098.001"
230name = "Additional Cloud Credentials"
231reference = "https://attack.mitre.org/techniques/T1098/001/"
232
233
234
235[rule.threat.tactic]
236id = "TA0003"
237name = "Persistence"
238reference = "https://attack.mitre.org/tactics/TA0003/"
239
240[rule.investigation_fields]
241field_names = [
242    "user.name",
243    "user.email",
244    "source.ip",
245    "file.name",
246    "google_workspace.drive.file.type",
247    "google_workspace.token.app_name",
248    "google_workspace.token.client.id",
249    "google_workspace.token.client.type",
250    "google_workspace.token.scope.value",
251]

Triage and analysis

A /copy link replicates a document, spreadsheet, form, or script into the recipient's Drive with a Copy of title, and a container-bound Apps Script can then prompt for consent when the object is opened. This rule correlates that external My Drive copy (copy_type: external, actor_is_collaborator_account: false, owner_is_team_drive: false) with a custom web OAuth grant (client.type: WEB, client id ending in apps.googleusercontent.com) for the same source.user.email and source.ip within maxspan=3m. The grant must include an Apps Script scope: script.container (the container sidebar or dialog), any other script.* scope, a *.currentonly scope, or a scope containing scripts or container. Known Google first-party clients and Cloud project 857627895310 are excluded. Compare google_workspace.token.app_name with file.name and review google_workspace.token.scope.value. Broader scopes such as spreadsheets, drive, or gmail do not match on their own, and visibility is not filtered.

Possible investigation steps

  • Identify the affected user from source.user.email or user.email. Note source.ip and compare @timestamp (event time) on the copy and the authorize event.
  • Drive copy event (google_workspace.drive):
    • Review file.name and google_workspace.drive.file.type to identify what was copied. Confirm the title contains Copy of.
    • For deeper review, pivot on google_workspace.drive.file.id or file.name in Drive audit logs and Admin console Drive investigation.
  • OAuth authorize event (google_workspace.token):
    • Review google_workspace.token.app_name and google_workspace.token.client.id to identify the application. Check whether the app name appears in the copied title.
    • Review granted scopes in google_workspace.token.scope.value to determine which services the token can access (for example Drive, Gmail, or Calendar scopes beyond the current file).
    • Confirm google_workspace.token.client.type is WEB and that the client is not a known Google first-party client.
  • Determine whether the activity is expected:
    • Contact the user to confirm they intentionally copied an external template and authorized the application.
    • If timing or source.ip is unusual for the user, treat as higher priority until validated.
  • Search Kibana for related activity:
    • Determine whether other users copied the same external object:
      1data_stream.dataset: "google_workspace.drive" and event.action: "copy" and google_workspace.drive.copy_type: "external" and file.name: "<FILE_NAME>"
      
    • Correlate with sign-in activity around the same window:
      1data_stream.dataset: "google_workspace.login" and user.email: "<USER_EMAIL>"
      
    • Scope for other OAuth grants to the same client across the tenant:
      1data_stream.dataset: "google_workspace.token" and event.action: "authorize" and google_workspace.token.client.id: "<CLIENT_ID>"
      
  • If a container-bound script is suspected, locate the copied object in the user's Drive and review Apps Script code for exfiltration, token harvesting, or persistence logic. Remove the object from affected users' Drives.

False positive analysis

  • Users may legitimately copy public templates (spreadsheets, forms, or documents) from external drives and consent to a container-bound add-on within three minutes from the same IP. Compare google_workspace.token.app_name with file.name and review google_workspace.token.scope.value before closing the alert. Grants that do not include an Apps Script scope (script.container or another script.* scope, *.currentonly, scripts, or container) do not match.
  • OAuth consent does not always follow the copy immediately. Opening the object later can separate the two actions beyond 180 seconds, which will not match even when the activity is related.
  • Non-English Workspace locales translate the Copy of prefix, so those replicas will not match.

Response and remediation

  • Initiate the incident response process based on triage findings.
  • If the copy or OAuth grant 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).
  • Remove malicious copied objects from affected users' Drives and report abusive OAuth clients to Google if appropriate.
  • 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 authorized token based on scopes in 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 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 and uses timestamp_override: event.ingested so delayed ingest does not drop events from the execution window. Sequence correlation and maxspan still use @timestamp event time.
  • Drive and token audit events may arrive on different schedules; the token integration polls Google's API on a longer default interval. To reduce false negatives, consider reducing the poll interval for both Drive and token data sources.
  • By default, var.interval is set to 2 hours (2h). Consider changing this interval to a lower value, such as 10 minutes (10m).

References

Related rules

to-top