Persistence (TA0003)(external, opens in a new tab or window)
text code block:FROM logs-azure.signinlogs-* | WHERE azure.signinlogs.category == "SignInLogs" AND azure.signinlogs.properties.authentication_details IS NOT NULL AND azure.tenant_id IS NOT NULL // filter for Passkey or FIDO2 security key sign-ins | EVAL ad = TO_STRING(azure.signinlogs.properties.authentication_details) | WHERE ad LIKE "*Passkey (*" OR ad LIKE "*FIDO2 security key*" // Pair each authentication method with its own success flag; event.outcome is sign-in level and is not tied to the passkey step | GROK ad """"authentication_method":%{DATA:method_raw},"authentication_""" | GROK ad """"succeeded":%{DATA:succeeded_raw}}""" | EVAL Esql.auth_methods = SPLIT(REPLACE(method_raw, """[\[\]"]""", ""), ","), Esql.auth_method_succeeded = SPLIT(REPLACE(succeeded_raw, """[\[\]"]""", ""), ",") | EVAL Esql.method_outcome_pairs = MV_CONCAT(MV_ZIP(Esql.auth_methods, Esql.auth_method_succeeded, "~"), " || ") // Require the passkey or FIDO2 step itself to have succeeded | WHERE Esql.method_outcome_pairs LIKE "*Passkey (synced)~true*" OR Esql.method_outcome_pairs LIKE "*Passkey (device-bound)~true*" OR Esql.method_outcome_pairs LIKE "*FIDO2 security key~true*" // extract AAGUID from authentication method detail // a sign-in can carry several auth steps, so expand multi-valued details and evaluate each one | EVAL ad_detail = FIELD_EXTRACT(azure.signinlogs.properties.authentication_details, "authentication_method_detail") | MV_EXPAND ad_detail // find a well-formed 8-4-4-4-12 hex AAGUID anywhere in the value, independent of provider text or separator // the lookarounds reject longer hex/dash runs so a malformed value is not partially matched | GROK ad_detail """(?<![0-9A-Fa-f-])(?<aaguid_raw>[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12})(?![0-9A-Fa-f-])""" // lowercase to normalize case; ignore missing or zeroed AAGUIDs, which carry no authenticator model | EVAL aaguid_raw = TO_LOWER(aaguid_raw) | WHERE aaguid_raw IS NOT NULL AND aaguid_raw != "00000000-0000-0000-0000-000000000000" // aggregate sign-in statistics by tenant and AAGUID | STATS Esql.first_ingested = MIN(event.ingested), Esql.first_time_seen = MIN(@timestamp), Esql.last_time_seen = MAX(@timestamp), Esql.signin_count = COUNT(*), Esql.user_count = COUNT_DISTINCT(azure.signinlogs.properties.user_id), Esql.provider_values = VALUES(ad_detail), Esql.user_values = VALUES(azure.signinlogs.properties.user_principal_name), Esql.app_values = VALUES(azure.signinlogs.properties.app_display_name), Esql.app_id_values = VALUES(azure.signinlogs.properties.app_id), Esql.resource_values = VALUES(azure.signinlogs.properties.resource_display_name), Esql.client_app_used_values = VALUES(azure.signinlogs.properties.client_app_used), Esql.incoming_token_type_values = VALUES(azure.signinlogs.properties.incoming_token_type), Esql.source_ip_values = VALUES(source.ip), Esql.source_as_number_values = VALUES(source.`as`.number), Esql.user_agent_values = VALUES(user_agent.original), Esql.device_trust_type_values = VALUES(azure.signinlogs.properties.device_detail.trust_type), Esql.device_is_managed_values = VALUES(azure.signinlogs.properties.device_detail.is_managed), Esql.device_is_compliant_values = VALUES(azure.signinlogs.properties.device_detail.is_compliant), Esql.conditional_access_status_values = VALUES(azure.signinlogs.properties.conditional_access_status), Esql.auth_requirement_values = VALUES(azure.signinlogs.properties.authentication_requirement), Esql.risk_state_values = VALUES(azure.signinlogs.properties.risk_state), Esql.risk_level_during_signin_values = VALUES(azure.signinlogs.properties.risk_level_during_signin), Esql.result_signature_values = VALUES(azure.signinlogs.result_signature), Esql.correlation_id_values = VALUES(azure.signinlogs.properties.correlation_id), Esql.session_id_values = VALUES(azure.signinlogs.properties.session_id), Esql.unique_token_identifier_values = VALUES(azure.signinlogs.properties.unique_token_identifier) BY azure.tenant_id, Esql.passkey_aaguid = aaguid_raw // first ingested within the last 10 minutes; ingestion time keeps delayed sign-in logs from aging out of the gate | EVAL Esql.recent_minutes = DATE_DIFF("minute", Esql.first_ingested, NOW()) | WHERE Esql.recent_minutes <= 10 | KEEP Esql.*, azure.tenant_id
Install detection rules in Elastic Security
Detect Entra ID Passkey Sign-In with Unusual Authenticator AAGUID in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).