Detection rules › YARA-L

AWS Successful API From Tor Exit Node

Severity
high
Type
Alert
Time window
5m
Match by
ip
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects successful API executions from a Tor exit node.

MITRE ATT&CK coverage

TacticTechniques
ExecutionT1204 User Execution

Rule body yaral

/*
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

rule aws_successful_api_from_tor_exit_node {

  meta:
    author = "Google Cloud Security"
    description = "Detects successful API executions from a Tor exit node."
    rule_id = "mr_17232c2a-188e-4d6e-85b6-836cdc779655"
    rule_name = "AWS Successful API From Tor Exit Node"
    mitre_attack_tactic = "Execution"
    mitre_attack_technique = "User Execution"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1204/"
    mitre_attack_version = "v13.1"
    type = "Alert"
    data_source = "AWS CloudTrail"
    platform = "AWS"
    severity = "High"
    priority = "High"

  events:
    $api.metadata.vendor_name = "AMAZON"
    $api.metadata.product_name = "AWS CloudTrail"
    $api.security_result.action = "ALLOW"
    $api.principal.ip = $ip

    // Tor IP listing provided by GCTI Feed
    $gcti_feed.graph.entity.artifact.ip = $ip
    $gcti_feed.graph.metadata.entity_type = "IP_ADDRESS"
    $gcti_feed.graph.metadata.threat.threat_feed_name = "Tor Exit Nodes"
    $gcti_feed.graph.metadata.product_name = "GCTI Feed"
    $gcti_feed.graph.metadata.source_type = "GLOBAL_CONTEXT"

  match:
    $ip over 5m

  outcome:
    $risk_score = max(
        //Baseline
        35 +
        // Unauthorized geographies
        if($api.principal.ip_geo_artifact.location.country_or_region = "Cuba", 40) +
        if($api.principal.ip_geo_artifact.location.country_or_region = "Iran", 40) +
        if($api.principal.ip_geo_artifact.location.country_or_region = "North Korea" , 40) +
        if($api.principal.ip_geo_artifact.location.country_or_region = "Russia", 40) +
        if($api.principal.ip_geo_artifact.location.country_or_region = "Syria", 40)
    )
    $mitre_attack_tactic = "Execution"
    $mitre_attack_technique = "User Execution"
    $mitre_attack_technique_id = "T1204"
    $event_count = count_distinct($api.metadata.id)
    $network_http_user_agent = array_distinct($api.network.http.user_agent)
    $principal_ip = array_distinct($api.principal.ip)
    $principal_ip_country = array_distinct($api.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($api.principal.ip_geo_artifact.location.state)
    $principal_user_display_name = array_distinct($api.principal.user.user_display_name)
    $dc_principal_user_display_name = count_distinct($api.principal.user.user_display_name)
    $is_mfa_used = array_distinct($api.extensions.auth.auth_details)
    $target_resource_name = array_distinct($api.target.resource.name)
    $target_resource_product_object_id = array_distinct($api.target.resource.product_object_id)

  condition:
    $api and $gcti_feed
}

Detection logic

Fires when at least one $api event in the 5m window and $gcti_feed matches entity context.

Events

$api

  • security_result.action = "ALLOW"

$gcti_feed entity context (IP_ADDRESS)

  • graph.metadata.entity_type = "IP_ADDRESS"
  • graph.metadata.threat.threat_feed_name = "Tor Exit Nodes"
  • graph.metadata.product_name = "GCTI Feed"
  • graph.metadata.source_type = "GLOBAL_CONTEXT"

Correlation

Match key
$ip (principal.ip)
Within
5m

Outcome

Fields the detection emits on a match. $risk_score drives alerting; Chronicle surfaces the rest on the detection.

FieldExpression
risk_scoremax( 35 + if($api.principal.ip_geo_artifact.location.country_or_region = "Cuba", 40) + if($api.principal.ip_geo_artifact.location.country_or_region = "Iran", 40) + if($api.principal.ip_geo_artifact.location.country_or_region = "North Korea" , 40) + if($api.principal.ip_geo_artifact.location.country_or_region = "Russia", 40) + if($api.principal.ip_geo_artifact.location.country_or_region = "Syria", 40) )
event_countcount_distinct($api.metadata.id)
network_http_user_agentarray_distinct($api.network.http.user_agent)
principal_iparray_distinct($api.principal.ip)
principal_ip_countryarray_distinct($api.principal.ip_geo_artifact.location.country_or_region)
principal_ip_statearray_distinct($api.principal.ip_geo_artifact.location.state)
principal_user_display_namearray_distinct($api.principal.user.user_display_name)
dc_principal_user_display_namecount_distinct($api.principal.user.user_display_name)
is_mfa_usedarray_distinct($api.extensions.auth.auth_details)
target_resource_namearray_distinct($api.target.resource.name)
target_resource_product_object_idarray_distinct($api.target.resource.product_object_id)