← Back to SOC feed Coverage →

AddedCredentialFromContryXAndSigninFromCountryY

kql MEDIUM Azure-Sentinel
CloudAppEvents
credential-thefthuntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-23T23:00:00Z · Confidence: medium

Hunt Hypothesis

Adversaries may be using credentials added from Country X to access systems while signing in from Country Y, indicating potential credential theft or multi-factor bypass. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify and mitigate potential lateral movement or persistent access attempts.

KQL Query

let timewindow = 1d;
let addedApps = (
CloudAppEvents
| where Application == "Office 365"
| where ActionType in ("Add service principal credentials.", "Update application - Certificates and secrets management ")
| project AddedTimestamp = Timestamp , AppName = tostring(RawEventData.Target[3].ID), CountryCode );
EntraIdSpnSignInEvents
| join addedApps on $left.ServicePrincipalName == $right.AppName
| where CountryCode != Country and AddedTimestamp + timewindow > Timestamp

Analytic Rule Definition

id: 9644e2ae-07a2-4086-a85a-6ee2bca45f4e
name: AddedCredentialFromContryXAndSigninFromCountryY
description: |
  Added credential from country X and Signed-In from country Y in a pecific time window:
  This query tries to find all applications that credentials were added to them from country X while the application's identity Signed-In from country Y in a specific time window.
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - CloudAppEvents
  - EntraIdSpnSignInEvents
tactics:
- Persistence
query: |
  let timewindow = 1d;
  let addedApps = (
  CloudAppEvents
  | where Application == "Office 365"
  | where ActionType in ("Add service principal credentials.", "Update application - Certificates and secrets management ")
  | project AddedTimestamp = Timestamp , AppName = tostring(RawEventData.Target[3].ID), CountryCode );
  EntraIdSpnSignInEvents
  | join addedApps on $left.ServicePrincipalName == $right.AppName
  | where CountryCode != Country and AddedTimestamp + timewindow > Timestamp

Required Data Sources

Sentinel TableNotes
CloudAppEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Persistence/AddedCredentialFromContryXAndSigninFromCountryY.yaml