entra_id_devicecode_phishing_attack


Description

Detects strong indicators of a successful device code phishing attack.

Query · yara_l

events:
    $email.network.email.to = $user
    $email.metadata.vendor_name = "Google Workspace"
    $email.metadata.product_name = "gmail" nocase
    $email.about.url = /microsoft.com\/devicelogin/ or
    $email.about.url = /oauth2\/deviceauth/
    //user clicks the device code phish URL.
    $email.about.labels.value = /71|9/

    $entra.metadata.vendor_name = "Microsoft"
    $entra.metadata.product_name = "Azure AD"
    //Entra error code 50199: The user was asked to confirm that this app is the application they intended to sign into.
    $entra.security_result.rule_id = /^(0|50199)$/

    //join
    $email.network.email.to = $entra.target.user.userid

  match:
    //Time window based on the fact that the device code expires within 15 minutes. Added an extra 60 seconds.
    $user over 16m

  outcome:
    $mitre_attack_tactic = array_distinct("Initial Access")
    $mitre_attack_technique = array_distinct("Phishing")
    $mitre_attack_technique_id = array_distinct("T1566")
    $target_user_distinct_count = count_distinct($user)
    $target_user_count = count($user)
    $principal_ip = array_distinct($email.principal.ip)
    $sender_from = array_distinct($email.principal.network.email.from)
    $recipient = array_distinct($email.network.email.to)

  condition:
    $email and $entra
Raw source entra_id_devicecode_phishing_attack · YARA-L
Esc
Published by chronicle/detection-rules ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
rule entra_id_devicecode_phishing_attack {

  meta:
    author = "Bastradamus"
    description = "Detects strong indicators of a successful device code phishing attack."
    severity = "High"
    priority = "High"
    rule_id = "mr_8b29e3d1-5c42-4f91-9aef-b673ad89f0e4"
    rule_name = "Microsoft Entra ID Device code phishing attack"
    type = "alert"
    data_source = "Workspace Activity, azure ad"
    reference = "https://systemweakness.com/detecting-device-code-phishing-in-google-security-operations-9bf1c282cff0"
    mitre_attack_tactic = "Initial Access"
    mitre_attack_technique = "Phishing"
    mitre_attack_url = "https://attack.mitre.org/techniques/T1566/"

  events:
    $email.network.email.to = $user
    $email.metadata.vendor_name = "Google Workspace"
    $email.metadata.product_name = "gmail" nocase
    $email.about.url = /microsoft.com\/devicelogin/ or
    $email.about.url = /oauth2\/deviceauth/
    //user clicks the device code phish URL.
    $email.about.labels.value = /71|9/

    $entra.metadata.vendor_name = "Microsoft"
    $entra.metadata.product_name = "Azure AD"
    //Entra error code 50199: The user was asked to confirm that this app is the application they intended to sign into.
    $entra.security_result.rule_id = /^(0|50199)$/

    //join
    $email.network.email.to = $entra.target.user.userid

  match:
    //Time window based on the fact that the device code expires within 15 minutes. Added an extra 60 seconds.
    $user over 16m

  outcome:
    $mitre_attack_tactic = array_distinct("Initial Access")
    $mitre_attack_technique = array_distinct("Phishing")
    $mitre_attack_technique_id = array_distinct("T1566")
    $target_user_distinct_count = count_distinct($user)
    $target_user_count = count($user)
    $principal_ip = array_distinct($email.principal.ip)
    $sender_from = array_distinct($email.principal.network.email.from)
    $recipient = array_distinct($email.network.email.to)

  condition:
    $email and $entra
}

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.