Skip to content

[Rule Tuning] Entra ID OAuth User Impersonation to Microsoft Graph: row filter added in #5864 drops every row, rule never fires #7273

Backlog

Description

@ahmed-aoc

Link to Rule

https://github.com/elastic/detection-rules/blob/main/rules/integrations/azure/initial_access_entra_id_graph_single_session_from_multiple_addresses.toml

Rule Tuning Type

False Negatives - Enhancing detection of true threats that were previously missed.

Description

Since the tuning in #5863 / #5864, this rule can no longer produce any results.

The query builds two columns per row:

Esql.signin_source_asn = case(data_stream.dataset == "azure.signinlogs", source.`as`.organization.name),
Esql.graph_source_asn = case(data_stream.dataset == "azure.graphactivitylogs", source.`as`.organization.name)

Each row is either a sign-in or a Graph call, so on every row one of these is null. The row filter added in the last commit of #5864 ("make sure sign in sources are not null") then requires both on the same row:

) and Esql.signin_source_asn IS NOT NULL and Esql.graph_source_asn IS NOT NULL

That is never true, so every row is dropped before STATS and the rule cannot alert.

Repro with one sign-in and one Graph event that share session, user and app (see example data): 2 rows go in, 0 rows survive that WHERE. Changing and to or lets both rows through, and the rule then alerts on the intended pattern (sign-in from one ASN, Graph access from a different ASN 10 minutes later) while staying quiet when both come from the same ASN.

Suggested fix:

) and (Esql.signin_source_asn IS NOT NULL or Esql.graph_source_asn IS NOT NULL)

The later checks still require both event types (Esql.event_type_case_count_distinct > 1) and non-overlapping sign-in and Graph ASNs, so the noise reduction from #5864 is kept.

Possible follow-up: with the fix applied, the only historical matches in our environment were Graph calls made by Microsoft's own backend on behalf of the user (for example SharePoint Online, user agent SPOFD/...). GeoIP labels that network Microsoft Corporation, which the rule does not exclude (it only excludes MICROSOFT-CORP-MSN-AS-BLOCK). Adding Microsoft Corporation to that exclusion removed them.

Example Data

[
  {
    "@timestamp": "2026-11-28T10:00:00Z",
    "data_stream.dataset": "azure.signinlogs",
    "azure.signinlogs.properties.session_id": "11111111-aaaa-bbbb-cccc-000000000001",
    "azure.signinlogs.properties.user_id": "22222222-aaaa-bbbb-cccc-000000000002",
    "azure.signinlogs.properties.app_id": "d3590ed6-52b3-4102-aeff-aad2292ab01c",
    "source.ip": "198.51.100.20",
    "source.as.organization.name": "Example Residential ISP"
  },
  {
    "@timestamp": "2026-11-28T10:10:00Z",
    "data_stream.dataset": "azure.graphactivitylogs",
    "azure.graphactivitylogs.properties.c_sid": "11111111-aaaa-bbbb-cccc-000000000001",
    "azure.graphactivitylogs.properties.user_principal_object_id": "22222222-aaaa-bbbb-cccc-000000000002",
    "azure.graphactivitylogs.properties.app_id": "d3590ed6-52b3-4102-aeff-aad2292ab01c",
    "source.ip": "203.0.113.77",
    "source.as.organization.name": "Example Hosting Provider",
    "url.original": "https://graph.microsoft.com/v1.0/me/messages"
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions