From d6f277e3795f0e52fe166f3761d92696ea2c0d05 Mon Sep 17 00:00:00 2001 From: Terrance DeJesus <99630311+terrancedejesus@users.noreply.github.com> Date: Wed, 12 Apr 2023 09:40:31 -0400 Subject: [PATCH] [New Rule] Google Workspace New OAuth Login from Third-Party Application (#2677) * adding new rule 'Google Workspace New OAuth Login from Custom Application' * changed name and 'custom' to 'third-party' * Update rules/integrations/google_workspace/defense_evasion_google_workspace_new_oauth_login_from_third_party_application.toml * Update rules/integrations/google_workspace/defense_evasion_google_workspace_new_oauth_login_from_third_party_application.toml * updated non-ecs --- detection_rules/etc/non-ecs-schema.json | 3 +- ...th_login_from_third_party_application.toml | 95 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 rules/integrations/google_workspace/defense_evasion_google_workspace_new_oauth_login_from_third_party_application.toml diff --git a/detection_rules/etc/non-ecs-schema.json b/detection_rules/etc/non-ecs-schema.json index b734865f8..629766b6b 100644 --- a/detection_rules/etc/non-ecs-schema.json +++ b/detection_rules/etc/non-ecs-schema.json @@ -119,6 +119,7 @@ "google_workspace.drive.copy_type": "keyword", "google_workspace.drive.file.type": "keyword", "google_workspace.drive.visibility": "keyword", - "google_workspace.token.client.id": "keyword" + "google_workspace.token.client.id": "keyword", + "google_workspace.token.scope.data.scope_name": "keyword" } } diff --git a/rules/integrations/google_workspace/defense_evasion_google_workspace_new_oauth_login_from_third_party_application.toml b/rules/integrations/google_workspace/defense_evasion_google_workspace_new_oauth_login_from_third_party_application.toml new file mode 100644 index 000000000..0e1bf5aed --- /dev/null +++ b/rules/integrations/google_workspace/defense_evasion_google_workspace_new_oauth_login_from_third_party_application.toml @@ -0,0 +1,95 @@ +[metadata] +creation_date = "2023/03/30" +integration = ["google_workspace"] +maturity = "production" +min_stack_comments = "Breaking changes for Google Workspace integration. New Terms rule type note available until 8.4" +min_stack_version = "8.4.0" +updated_date = "2023/03/30" + +[rule] +author = ["Elastic"] +description = """ +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. +""" +false_positives = [ + """ + Developers may leverage third-party applications for legitimate purposes in Google Workspace such as for administrative tasks. + """, +] +from = "now-130m" +index = ["filebeat-*", "logs-google_workspace*"] +interval = "10m" +language = "kuery" +license = "Elastic License v2" +name = "First Time Seen Google Workspace OAuth Login from Third-Party Application" +note = """## 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: + - https://support.google.com/a/answer/7061566 + - https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-google_workspace.html""" +references = [ + "https://www.elastic.co/security-labs/google-workspace-attack-surface-part-one", + "https://developers.google.com/apps-script/guides/bound", + "https://developers.google.com/identity/protocols/oauth2", +] +risk_score = 47 +rule_id = "21bafdf0-cf17-11ed-bd57-f661ea17fbcc" +severity = "medium" +tags = ["Elastic", "Cloud", "Google Workspace", "Continuous Monitoring", "SecOps", "Defense Evasion", "Initial Access"] +timestamp_override = "event.ingested" +type = "new_terms" + +query = ''' +event.dataset: "google_workspace.token" and event.action: "authorize" and +google_workspace.token.scope.data.scope_name: *Login and google_workspace.token.client.id: *apps.googleusercontent.com +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1550" +name = "Use Alternate Authentication Material" +reference = "https://attack.mitre.org/techniques/T1550/" +[[rule.threat.technique.subtechnique]] +id = "T1550.001" +name = "Application Access Token" +reference = "https://attack.mitre.org/techniques/T1550/001/" + + + +[rule.threat.tactic] +id = "TA0005" +name = "Defense Evasion" +reference = "https://attack.mitre.org/tactics/TA0005/" + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1078" +name = "Valid Accounts" +reference = "https://attack.mitre.org/techniques/T1078/" +[[rule.threat.technique.subtechnique]] +id = "T1078.004" +name = "Cloud Accounts" +reference = "https://attack.mitre.org/techniques/T1078/004/" + + + +[rule.threat.tactic] +id = "TA0001" +name = "Initial Access" +reference = "https://attack.mitre.org/tactics/TA0001/" + +[rule.new_terms] +field = "new_terms_fields" +value = ["google_workspace.token.client.id"] + +[[rule.new_terms.history_window_start]] +field = "history_window_start" +value = "now-15d" \ No newline at end of file