Detection rules › YARA-L

Hunt for Expired Tokens Attempting to sign-in to Entra ID

Severity
low
Type
Hunt
Time window
15m
Match by
userid
Author
Google Cloud Security
Source
github.com/chronicle/detection-rules

Identify Entra ID OAuth refresh tokens are attempted to be used but have expired. This could be because the token hasn't been used for 90 days or it has been revoked

MITRE ATT&CK coverage

Rule body yaral

/*
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

rule entra_id_expired_refresh_token_use {

  meta:
    author = "Google Cloud Security"
    description = "Identify Entra ID OAuth refresh tokens are attempted to be used but have expired. This could be because the token hasn't been used for 90 days or it has been revoked"
    rule_id = "mr_88826f0a-e964-4d11-8765-8732ae83b1f1"
    rule_name = "Hunt for Expired Tokens Attempting to sign-in to Entra ID"
    tactic = "TA0008"
    technique = "T1550.001"
    type = "Hunt"
    data_source = "Azure Activity"
    platform = "Azure"
    severity = "Low"
    priority = "Low"

  events:
    $login.metadata.event_type = "USER_LOGIN"
    $login.metadata.product_name = "Azure Activity"
    $login.metadata.product_event_type = "Sign-in activity"
    $login.metadata.vendor_name = "Microsoft"
    $login.security_result.action = "BLOCK"
    //$login.metadata.description = "Fresh auth token is needed. Have the user re-sign using fresh credentials."
    $login.security_result.action_details = "50173"
    $login.principal.user.userid = $userid

  match:
    $userid over 15m

  outcome:
    $risk_score = 15
    $event_count = count_distinct($login.metadata.id)
    $principal_ip = array_distinct($login.principal.ip)
    $user_agent = array_distinct($login.network.http.user_agent)
    $target_application = array_distinct($login.target.application)

  condition:
    $login
}

Detection logic

Fires when at least one $login event in the 15m window.

Events

$login USER_LOGIN

  • metadata.product_event_type = "Sign-in activity"
  • security_result.action = "BLOCK"
  • security_result.action_details = "50173"

Correlation

Match key
$userid (principal.user.userid)
Within
15m

Outcome

Fields the detection emits on a match. $risk_score drives alerting; Chronicle surfaces the rest on the detection.

FieldExpression
risk_score15
event_countcount_distinct($login.metadata.id)
principal_iparray_distinct($login.principal.ip)
user_agentarray_distinct($login.network.http.user_agent)
target_applicationarray_distinct($login.target.application)