Detection rules › YARA-L

YARA-L rules: 2r

AWS EC2 AMI Or Snapshot Shared Publicly

#
Severity
high
Type
Alert
Time window
1h
Match by
user_id
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Detects when an Amazon EC2 AMI or Snapshot is shared publicly.

MITRE ATT&CK Coverage

TacticTechniques
Exfiltration

Telemetry Coverage

Rule Body

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

rule aws_ec2_ami_or_snapshot_shared_publicly {

  meta:
    author = "Google Cloud Security"
    description = "Detects when an Amazon EC2 AMI or Snapshot is shared publicly."
    rule_id = "mr_843a37db-dcd5-40b2-8b55-a00397fd5c0d"
    rule_name = "AWS EC2 AMI Or Snapshot Shared Publicly"
    mitre_attack_tactic = "Exfiltration"
    mitre_attack_technique = "Transfer Data to Cloud Account"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1537/"
    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 = "ModifyImageAttribute" or
        $cloudtrail.metadata.product_event_type = "ModifySnapshotAttribute"
    )
    $cloudtrail.target.resource.attribute.labels["Add Items Group"] = "all"
    $cloudtrail.security_result.action = "ALLOW"
    $cloudtrail.principal.user.userid = $user_id

  match:
    $user_id over 1h

  outcome:
    $risk_score = max(75)
    $mitre_attack_tactic = "Exfiltration"
    $mitre_attack_technique = "Transfer Data to Cloud Account"
    $mitre_attack_technique_id = "T1537"
    $event_count = count_distinct($cloudtrail.metadata.id)
    $network_http_user_agent = array_distinct($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 = array_distinct($cloudtrail.principal.user.user_display_name)
    $recipient_aws_account_id = array_distinct($cloudtrail.additional.fields["recipientAccountId"])
    $aws_region = array_distinct($cloudtrail.principal.location.name)
    $target_resource_name = array_distinct($cloudtrail.target.resource.name)
    $target_resource_product_object_id = array_distinct($cloudtrail.target.resource.product_object_id)

  condition:
    $cloudtrail
}

YARA-L Rule Structure

Condition

Fires when at least one $cloudtrail event in the 1h window.

Events

$cloudtrail

  • metadata.product_event_type is one of:
    • ModifyImageAttribute
    • ModifySnapshotAttribute
  • target.resource.attribute.labels["Add Items Group"] = "all"
  • security_result.action = "ALLOW"

Match and Correlation

Match key
$user_id (principal.user.userid)
Within
1h

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_agentarray_distinct($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_namearray_distinct($cloudtrail.principal.user.user_display_name)
recipient_aws_account_idarray_distinct($cloudtrail.additional.fields["recipientAccountId"])
aws_regionarray_distinct($cloudtrail.principal.location.name)
target_resource_namearray_distinct($cloudtrail.target.resource.name)
target_resource_product_object_idarray_distinct($cloudtrail.target.resource.product_object_id)

GitHub SSO Configuration Modified

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

Detects when changes are made to a GitHub enterprise or organization's Single Sign-On (SSO) configuration.

MITRE ATT&CK Coverage

TacticTechniques
Defense Impairment

References

Telemetry Coverage

Rules Detecting the Same Action

These rules filter on the same operation.

Rule Body

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

rule github_sso_configuration_modified {

  meta:
    author = "Google Cloud Security"
    description = "Detects when changes are made to a GitHub enterprise or organization's Single Sign-On (SSO) configuration."
    rule_id = "mr_65a0f413-7f77-4039-a241-383c13e96dc2"
    rule_name = "GitHub SSO Configuration Modified"
    assumption = "Your GitHub enterprise audit log settings are configured to log the source IP address for events. Reference: https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/displaying-ip-addresses-in-the-audit-log-for-your-organization"
    type = "alert"
    severity = "High"
    priority = "High"
    platform = "GitHub"
    data_source = "github"
    mitre_attack_tactic = "Defense Evasion"
    mitre_attack_technique = "Impair Defenses: Disable or Modify Tools"
    mitre_attack_url = "https://attack.mitre.org/versions/v14/techniques/T1562/001/"
    mitre_attack_version = "v14"
    reference = "https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise"

  events:
    $github.metadata.vendor_name = "GITHUB" nocase
    $github.metadata.product_name = "GITHUB"
    (
        // Configuration changes for a GitHub enterprise
        $github.metadata.product_event_type = "business.disable_saml" or
        $github.metadata.product_event_type = "business.update_saml_provider_settings" or
        $github.metadata.product_event_type = "business.disable_oidc" or

        // Configuration changes for a GitHub organization
        $github.metadata.product_event_type = "org_credential_authorization.deauthorize" or
        $github.metadata.product_event_type = "org_credential_authorization.grant" or
        $github.metadata.product_event_type = "org_credential_authorization.revoke" or
        $github.metadata.product_event_type = "org.disable_saml" or
        $github.metadata.product_event_type = "org.update_saml_provider_settings" or
        $github.metadata.product_event_type = "sso_redirect.disable"
    )

  outcome:
    $risk_score = max(85)
    $mitre_attack_tactic = "Defense Evasion"
    $mitre_attack_technique = "Impair Defenses: Disable or Modify Tools"
    $mitre_attack_technique_id = "T1562.001"
    $principal_ip = array_distinct($github.principal.ip)
    $principal_user_userid = array_distinct($github.principal.user.userid)
    $principal_ip_country = array_distinct($github.principal.ip_geo_artifact.location.country_or_region)
    $principal_ip_state = array_distinct($github.principal.ip_geo_artifact.location.state)
    $principal_ip_city = array_distinct($github.principal.location.city)
    $security_result_summary = array_distinct($github.security_result.summary)

  condition:
    $github
}

YARA-L Rule Structure

Condition

Fires when at least one $github event.

Events

$github

  • metadata.product_event_type is one of:
    • business.disable_saml
    • business.update_saml_provider_settings
    • business.disable_oidc
    • org_credential_authorization.deauthorize
    • org_credential_authorization.grant
    • org_credential_authorization.revoke
    • org.disable_saml
    • org.update_saml_provider_settings
    • sso_redirect.disable

Outcome

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

FieldExpression
risk_scoremax(85)
principal_iparray_distinct($github.principal.ip)
principal_user_useridarray_distinct($github.principal.user.userid)
principal_ip_countryarray_distinct($github.principal.ip_geo_artifact.location.country_or_region)
principal_ip_statearray_distinct($github.principal.ip_geo_artifact.location.state)
principal_ip_cityarray_distinct($github.principal.location.city)
security_result_summaryarray_distinct($github.security_result.summary)

Suspicious Unusual Location LNK File

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

Detects creation and movement of .lnk files to specific folders

Telemetry Coverage

Rule Body

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

rule suspicious_unusual_location_lnk_file {

  meta:
    author = "Google Cloud Security"
    description = "Detects creation and movement of .lnk files to specific folders"
    rule_id = "mr_efb341aa-57c5-47b6-bde5-b409b4395c8f"
    rule_name = "Suspicious Unusual Location LNK File"
    type = "alert"
    data_source = "microsoft sysmon"
    platform = "Windows"
    severity = "Low"
    priority = "Low"

  events:
    (
      $file.metadata.event_type = "FILE_CREATION" or
      $file.metadata.event_type = "FILE_MODIFICATION" or
      $file.metadata.event_type = "FILE_COPY" or
      $file.metadata.event_type = "FILE_MOVE"
    )
    //and is optional, implied when broken out by line
    and
    $file.target.file.full_path = /\.lnk$/ nocase and
    //Looking in the desktop, documents and start menu folders, can be modified to look in different folders
    $file.target.file.full_path = /\\(Desktop|Documents|Start Menu)\\.*/ nocase

  outcome:
    $risk_score = 35
    //added to populate alert graph with additional context
    $principal_hostname = $file.principal.hostname
    $target_hostname = $file.target.hostname
    $src_hostname = $file.src.hostname
    $principal_process_pid = $file.principal.process.pid
    $principal_process_command_line = $file.principal.process.command_line
    $principal_process_file_sha256 = $file.principal.process.file.sha256
    $principal_process_file_full_path = $file.principal.process.file.full_path
    $principal_process_product_specific_process_id = $file.principal.process.product_specific_process_id
    $principal_process_parent_process_product_specific_process_id = $file.principal.process.parent_process.product_specific_process_id
    $principal_user_userid = $file.principal.user.userid
    $src_user_userid = $file.principal.user.userid
    $target_file_sha256 = $file.target.file.sha256
    $target_file_full_path = $file.target.file.full_path
    $src_file_sha256 = $file.src.file.sha256
    $src_file_full_path = $file.src.file.full_path

  condition:
    $file
}

YARA-L Rule Structure

Condition

Fires when at least one $file event.

Events

$file FILE_CREATION (2, 11, 23)

  • target.file.full_path matches "\.lnk$"
  • target.file.full_path matches "\\(Desktop|Documents|Start Menu)\\.*"

Outcome

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

FieldExpression
risk_score35
principal_hostname$file.principal.hostname
target_hostname$file.target.hostname
src_hostname$file.src.hostname
principal_process_pid$file.principal.process.pid
principal_process_command_line$file.principal.process.command_line
principal_process_file_sha256$file.principal.process.file.sha256
principal_process_file_full_path$file.principal.process.file.full_path
principal_process_product_specific_process_id$file.principal.process.product_specific_process_id
principal_process_parent_process_product_specific_process_id$file.principal.process.parent_process.product_specific_process_id
principal_user_userid$file.principal.user.userid
src_user_userid$file.principal.user.userid
target_file_sha256$file.target.file.sha256
target_file_full_path$file.target.file.full_path
src_file_sha256$file.src.file.sha256
src_file_full_path$file.src.file.full_path

Back to all YARA-L rules