Detection rules › YARA-L

YARA-L rules: 2p

AWS GuardDuty Publishing Destination Deleted

#
Severity
high
Type
Alert
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects when a GuardDuty Detector's publishing destination has been deleted which will prevent the exporting of findings.

MITRE ATT&CK Coverage

TacticTechniques
Defense Impairment

Telemetry Coverage

Rule Body

// Copyright 2023 Google LLC. Licensed under Apache-2.0.

rule aws_guardduty_publishing_destination_deleted {

  meta:
    author = "Google Cloud Security"
    description = "Detects when a GuardDuty Detector's publishing destination has been deleted which will prevent the exporting of findings."
    rule_id = "mr_630cd3d0-d22f-4e8a-9065-425bdbe1ab32"
    rule_name = "AWS GuardDuty Publishing Destination Deleted"
    mitre_attack_tactic = "Defense Evasion"
    mitre_attack_technique = "Impair Defenses"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1562/"
    mitre_attack_version = "v13.1"
    type = "Alert"
    data_source = "AWS CloudTrail"
    platform = "AWS"
    severity = "High"
    priority = "High"

  events:
    $cloudtrail.metadata.vendor_name = "AMAZON"
    $cloudtrail.metadata.product_name = "AWS CloudTrail"
    $cloudtrail.metadata.product_event_type = "DeletePublishingDestination"
    $cloudtrail.security_result.action = "ALLOW"

  outcome:
    $risk_score = max(75)
    $mitre_attack_tactic = "Defense Evasion"
    $mitre_attack_technique = "Impair Defenses"
    $mitre_attack_technique_id = "T1562"
    $event_count = count_distinct($cloudtrail.metadata.id)
    $network_http_user_agent = $cloudtrail.network.http.user_agent
    $principal_ip = array_distinct($cloudtrail.principal.ip)
    $principal_ip_country = array_distinct($cloudtrail.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($cloudtrail.principal.ip_geo_artifact.location.state)
    $principal_user_display_name = $cloudtrail.principal.user.user_display_name
    $recipient_aws_account_id = $cloudtrail.additional.fields["recipientAccountId"]
    $aws_region = $cloudtrail.principal.location.name
    $target_resource_name = $cloudtrail.target.resource.name
    $target_resource_product_object_id = $cloudtrail.target.resource.product_object_id

  condition:
    $cloudtrail
}

YARA-L Rule Structure

Condition

Fires when at least one $cloudtrail event.

Events

$cloudtrail

  • metadata.product_event_type = "DeletePublishingDestination"
  • security_result.action = "ALLOW"

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_scoremax(75)
event_countcount_distinct($cloudtrail.metadata.id)
network_http_user_agent$cloudtrail.network.http.user_agent
principal_iparray_distinct($cloudtrail.principal.ip)
principal_ip_countryarray_distinct($cloudtrail.principal.ip_geo_artifact.location.country_or_region)
principal_ip_statearray_distinct($cloudtrail.principal.ip_geo_artifact.location.state)
principal_user_display_name$cloudtrail.principal.user.user_display_name
recipient_aws_account_id$cloudtrail.additional.fields["recipientAccountId"]
aws_region$cloudtrail.principal.location.name
target_resource_name$cloudtrail.target.resource.name
target_resource_product_object_id$cloudtrail.target.resource.product_object_id

VT Relationships File Downloaded From URL

#
Severity
critical
Type
alert
Time window
1m
Match by
userid
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Alert on downloading a known file hash from a known IP with VT Relationships.

Telemetry Coverage

ProviderRecord / event type
SysmonEvent ID 11: FileCreate

Rule Body

// Copyright 2023 Google LLC. Licensed under Apache-2.0.

rule vt_relationships_file_downloaded_from_url {

  meta:
    author = "Google Cloud Security"
    description = "Alert on downloading a known file hash from a known IP with VT Relationships."
    rule_id = "mr_2890216d-6106-4841-b714-177f55ecc837"
    rule_name = "VT Relationships File Downloaded From URL"
    type = "alert"
    tags = "vt"
    data_source = "microsoft login events"
    severity = "Critical"
    priority = "Critical"

  events:
    // NETWORK_HTTP
    $http.metadata.event_type = "NETWORK_HTTP"
    $http.principal.user.userid = $userid
    $http.target.url = $url

    // FILE_CREATION
    $file.metadata.event_type = "FILE_CREATION"
    $file.target.user.userid = $userid
    $file.target.file.sha256 = $file_hash
    //$vtUrl = strings.concat("https://www.virustotal.com/gui/file/", $file.target.file.sha256)

    // Network HTTP event must occur before the file creation event
    $http.metadata.event_timestamp.seconds < $file.metadata.event_timestamp.seconds

    // Uses VirusTotal integration via entity graph, this section maps to target file hash
    $vt.graph.metadata.entity_type = "FILE"
    $vt.graph.metadata.source_type = "GLOBAL_CONTEXT"
    $vt.graph.metadata.vendor_name = "VirusTotal"
    $vt.graph.metadata.product_name = "VirusTotal Relationships"
    $vt.graph.entity.file.sha256 = $file_hash

    // Uses VirusTotal integration via entity graph, this section maps the hash to the url it is downloaded from
    $vt.graph.relations.entity_type = "URL"
    $vt.graph.relations.relationship = "DOWNLOADED_FROM"
    $vt.graph.relations.entity.url = $url

  match:
    $userid over 1m

  outcome:
    $risk_score = 95
    //added to populate alert graph with additional context
    $principal_hostname = array_distinct($http.principal.hostname)
    $target_hostname = array_distinct($file.target.hostname)
    $principal_process_pid = array_distinct($file.principal.process.pid)
    $principal_process_command_line = array_distinct($file.principal.process.command_line)
    $principal_process_file_sha256 = array_distinct($file.principal.process.file.sha256)
    $principal_process_file_full_path = array_distinct($file.principal.process.file.full_path)
    $principal_process_product_specific_process_id = array_distinct($file.principal.process.product_specific_process_id)
    $principal_process_parent_process_product_specific_process_id = array_distinct($file.principal.process.parent_process.product_specific_process_id)
    $target_process_pid = array_distinct($file.target.process.pid)
    $target_process_command_line = array_distinct($file.target.process.command_line)
    $target_process_file_sha256 = array_distinct($file.target.process.file.sha256)
    $target_process_file_full_path = array_distinct($file.target.process.file.full_path)
    $target_process_product_specific_process_id = array_distinct($file.target.process.product_specific_process_id)
    $target_process_parent_process_product_specific_process_id = array_distinct($file.target.process.parent_process.product_specific_process_id)
    $principal_user_userid = array_distinct($file.principal.user.userid)
    // Commented out target.user.userid because it is already represented in graph as match variable. If match changes, can uncomment to add to results
    //$target_user_userid = array_distinct($file.target.user.userid)
    $target_file_sha256 = array_distinct($file.target.file.sha256)
    $target_file_full_path = array_distinct($file.target.file.full_path)
    $target_url = array_distinct($http.target.url)

  condition:
    $http and $file and $vt
}

YARA-L Rule Structure

Condition

Fires when at least one $http event in the 1m window and at least one $file event in the 1m window and $vt matches entity context.

Events

$http NETWORK_HTTP

No field filters (binds the event for correlation only).

$file FILE_CREATION (11)

No field filters (binds the event for correlation only).

$vt entity context (FILE)

  • graph.metadata.entity_type = "FILE"
  • graph.metadata.source_type = "GLOBAL_CONTEXT"
  • graph.metadata.vendor_name = "VirusTotal"
  • graph.metadata.product_name = "VirusTotal Relationships"
  • graph.relations.entity_type = "URL"
  • graph.relations.relationship = "DOWNLOADED_FROM"

Match and Correlation

Order
$http before $file
Match key
$userid (principal.user.userid)
Within
1m

Outcome

Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.

FieldExpression
risk_score95
principal_hostnamearray_distinct($http.principal.hostname)
target_hostnamearray_distinct($file.target.hostname)
principal_process_pidarray_distinct($file.principal.process.pid)
principal_process_command_linearray_distinct($file.principal.process.command_line)
principal_process_file_sha256array_distinct($file.principal.process.file.sha256)
principal_process_file_full_patharray_distinct($file.principal.process.file.full_path)
principal_process_product_specific_process_idarray_distinct($file.principal.process.product_specific_process_id)
principal_process_parent_process_product_specific_process_idarray_distinct($file.principal.process.parent_process.product_specific_process_id)
target_process_pidarray_distinct($file.target.process.pid)
target_process_command_linearray_distinct($file.target.process.command_line)
target_process_file_sha256array_distinct($file.target.process.file.sha256)
target_process_file_full_patharray_distinct($file.target.process.file.full_path)
target_process_product_specific_process_idarray_distinct($file.target.process.product_specific_process_id)
target_process_parent_process_product_specific_process_idarray_distinct($file.target.process.parent_process.product_specific_process_id)
principal_user_useridarray_distinct($file.principal.user.userid)
target_file_sha256array_distinct($file.target.file.sha256)
target_file_full_patharray_distinct($file.target.file.full_path)
target_urlarray_distinct($http.target.url)

Back to all YARA-L rules