Suspicious Microsoft Entra ID Concurrent Sign-Ins via DeviceCode

Identifies concurrent Entra ID sign-in events for the same user and session from multiple sources, and where one of the authentication event has some suspicious properties often associated to DeviceCode and OAuth phishing. Adversaries may steal Refresh Tokens (RTs) via phishing to bypass multi-factor authentication (MFA) and gain unauthorized access to Azure resources.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2025/12/02"
  3integration = ["azure"]
  4maturity = "production"
  5updated_date = "2025/12/02"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies concurrent Entra ID sign-in events for the same user and session from multiple sources, and where one of the
 11authentication event has some suspicious properties often associated to DeviceCode and OAuth phishing. Adversaries may
 12steal Refresh Tokens (RTs) via phishing to bypass multi-factor authentication (MFA) and gain unauthorized access to
 13Azure resources.
 14"""
 15false_positives = [
 16    """
 17    Users authenticating from multiple devices and using the deviceCode protocol or the Visual Studio Code client.
 18    """,
 19]
 20from = "now-9m"
 21language = "esql"
 22license = "Elastic License v2"
 23name = "Suspicious Microsoft Entra ID Concurrent Sign-Ins via DeviceCode"
 24note = """## Triage and analysis
 25
 26### Investigating Suspicious Microsoft Entra ID Concurrent Sign-Ins via DeviceCode
 27
 28### Possible investigation steps
 29
 30- Review the sign-in logs to assess the context and reputation of the source.ip address.
 31- Investigate the user account associated with the successful sign-in to determine if the activity aligns with expected behavior or if it appears suspicious.
 32- Check for any recent changes or anomalies in the user's account settings or permissions that could indicate compromise.
 33- Review the history of sign-ins for the user to identify any patterns or unusual access times that could suggest unauthorized access.
 34- Assess the device from which the sign-in was attempted to ensure it is a recognized and authorized device for the user.
 35
 36### Response and remediation
 37
 38- Immediately revoke the compromised Primary Refresh Tokens (PRTs) to prevent further unauthorized access. This can be done through the Azure portal by navigating to the user's account and invalidating all active sessions.
 39- Enforce a password reset for the affected user accounts to ensure that any credentials potentially compromised during the attack are no longer valid.
 40- Implement additional Conditional Access policies that require device compliance checks and restrict access to trusted locations or devices only, to mitigate the risk of future PRT abuse.
 41- Conduct a thorough review of the affected accounts' recent activity logs to identify any unauthorized actions or data access that may have occurred during the compromise.
 42- Escalate the incident to the security operations team for further investigation and to determine if there are any broader implications or additional compromised accounts.
 43- Enhance monitoring by configuring alerts for unusual sign-in patterns or device code authentication attempts from unexpected locations or devices, to improve early detection of similar threats.
 44- Coordinate with the incident response team to perform a post-incident analysis and update the incident response plan with lessons learned from this event."""
 45references = [
 46    "https://learn.microsoft.com/en-us/entra/identity/",
 47    "https://learn.microsoft.com/en-us/entra/identity/monitoring-health/concept-sign-ins",
 48    "https://docs.microsoft.com/en-us/azure/active-directory/reports-monitoring/reference-azure-monitor-sign-ins-log-schema",
 49    "https://www.volexity.com/blog/2025/04/22/phishing-for-codes-russian-threat-actors-target-microsoft-365-oauth-workflows/",
 50    "https://www.wiz.io/blog/recent-oauth-attacks-detection-strategies"
 51]
 52risk_score = 73
 53rule_id = "3db029b3-fbb7-4697-ad07-33cbfd5bd080"
 54setup = """#### Required Azure Entra Sign-In Logs
 55This rule requires the Azure logs integration be enabled and configured to collect all logs, including sign-in logs from Entra. In Entra, sign-in logs must be enabled and streaming to the Event Hub used for the Azure logs integration.
 56"""
 57severity = "high"
 58tags = [
 59    "Domain: Cloud",
 60    "Domain: Identity",
 61    "Data Source: Azure",
 62    "Data Source: Entra ID",
 63    "Data Source: Entra ID Sign-in",
 64    "Use Case: Identity and Access Audit",
 65    "Use Case: Threat Detection",
 66    "Tactic: Credential Access",
 67    "Resources: Investigation Guide",
 68]
 69timestamp_override = "event.ingested"
 70type = "esql"
 71
 72query = '''
 73from logs-azure.signinlogs-* metadata _id, _version, _index
 74
 75| where event.category == "authentication" and event.dataset == "azure.signinlogs" and
 76        azure.signinlogs.properties.original_transfer_method == "deviceCodeFlow"
 77
 78| Eval Esql.interactive_logon = CASE(azure.signinlogs.category == "SignInLogs", source.ip, null),
 79       Esql.non_interactive_logon = CASE(azure.signinlogs.category ==  "NonInteractiveUserSignInLogs", source.ip, null)
 80
 81| stats Esql.count_logon = count(*),
 82        Esql.timestamp_values = values(@timestamp),
 83        Esql.source_ip_count_distinct = count_distinct(source.ip),
 84        Esql.is_interactive = count(Esql.interactive_logon),
 85        Esql.is_non_interactive = count(Esql.non_interactive_logon),
 86        Esql.user_agent_count_distinct = COUNT_DISTINCT(user_agent.original),
 87        Esql.user_agent_values = VALUES(user_agent.original),
 88        Esql.azure_signinlogs_properties_client_app_values = values(azure.signinlogs.properties.app_display_name),
 89        Esql.azure_signinlogs_properties_client_app_values = values(azure.signinlogs.properties.app_id),
 90        Esql.azure_signinlogs_properties_resource_display_name_values = values(azure.signinlogs.properties.resource_display_name),
 91        Esql.azure_signinlogs_properties_auth_requirement_values = values(azure.signinlogs.properties.authentication_requirement),
 92        Esql.azure_signinlogs_properties_tenant_id = values(azure.tenant_id),
 93        Esql.azure_signinlogs_properties_status_error_code_values = values(azure.signinlogs.properties.status.error_code),
 94        Esql.message_values = values(message),
 95        Esql.azure_signinlogs_properties_resource_id_values = values(azure.signinlogs.properties.resource_id),
 96        Esql.source_ip_values = VALUES(source.ip) by azure.signinlogs.properties.session_id, azure.signinlogs.identity
 97
 98| where Esql.is_interactive >= 2 and Esql.is_non_interactive >= 1 and (Esql.source_ip_count_distinct >= 2 or Esql.user_agent_count_distinct >= 2)
 99| keep
100       Esql.*,
101       azure.signinlogs.properties.session_id,
102       azure.signinlogs.identity
103'''
104
105
106[[rule.threat]]
107framework = "MITRE ATT&CK"
108[[rule.threat.technique]]
109id = "T1528"
110name = "Steal Application Access Token"
111reference = "https://attack.mitre.org/techniques/T1528/"
112
113
114[rule.threat.tactic]
115id = "TA0006"
116name = "Credential Access"
117reference = "https://attack.mitre.org/tactics/TA0006/"
118[[rule.threat]]
119framework = "MITRE ATT&CK"
120[[rule.threat.technique]]
121id = "T1566"
122name = "Phishing"
123reference = "https://attack.mitre.org/techniques/T1566/"
124[[rule.threat.technique.subtechnique]]
125id = "T1566.002"
126name = "Spearphishing Link"
127reference = "https://attack.mitre.org/techniques/T1566/002/"
128
129
130[rule.threat.tactic]
131id = "TA0001"
132name = "Initial Access"
133reference = "https://attack.mitre.org/tactics/TA0001/"

Triage and analysis

Investigating Suspicious Microsoft Entra ID Concurrent Sign-Ins via DeviceCode

Possible investigation steps

  • Review the sign-in logs to assess the context and reputation of the source.ip address.
  • Investigate the user account associated with the successful sign-in to determine if the activity aligns with expected behavior or if it appears suspicious.
  • Check for any recent changes or anomalies in the user's account settings or permissions that could indicate compromise.
  • Review the history of sign-ins for the user to identify any patterns or unusual access times that could suggest unauthorized access.
  • Assess the device from which the sign-in was attempted to ensure it is a recognized and authorized device for the user.

Response and remediation

  • Immediately revoke the compromised Primary Refresh Tokens (PRTs) to prevent further unauthorized access. This can be done through the Azure portal by navigating to the user's account and invalidating all active sessions.
  • Enforce a password reset for the affected user accounts to ensure that any credentials potentially compromised during the attack are no longer valid.
  • Implement additional Conditional Access policies that require device compliance checks and restrict access to trusted locations or devices only, to mitigate the risk of future PRT abuse.
  • Conduct a thorough review of the affected accounts' recent activity logs to identify any unauthorized actions or data access that may have occurred during the compromise.
  • Escalate the incident to the security operations team for further investigation and to determine if there are any broader implications or additional compromised accounts.
  • Enhance monitoring by configuring alerts for unusual sign-in patterns or device code authentication attempts from unexpected locations or devices, to improve early detection of similar threats.
  • Coordinate with the incident response team to perform a post-incident analysis and update the incident response plan with lessons learned from this event.

References

Related rules

to-top