Skip to content

Add hunting query: Entra ID sign-in from pre-revocation IP after sessions were revoked - #15653

Open
Mike Sosa (mikedsosa) wants to merge 2 commits into
Azure:masterfrom
mikedsosa:hunting-signin-after-session-revocation
Open

Mike Sosa (mikedsosa) wants to merge 2 commits into
Azure:masterfrom
mikedsosa:hunting-signin-after-session-revocation

Conversation

@mikedsosa

Copy link
Copy Markdown
Contributor

Change(s):

  • Added a new hunting query: Hunting Queries/MultipleDataSources/SuccessfulSignInAfterSessionRevocation.yaml

Reason for Change(s):

  • Revoking sessions forces re-authentication but does not change the password, so an attacker who still has it can sign straight back in. Existing content lists refresh-token modifications (StsRefreshTokenModification.yaml) but does not check whether the user kept signing in from the same IPs afterwards.
  • The query pairs each successful "Update StsRefreshTokenValidFrom Timestamp" audit event (logged when sessions are revoked; other admin updates to that timestamp can also produce it) with successful interactive or non-interactive sign-ins for the same user that occur more than a 90m grace period later and come from an IP address that user signed in from in the 1 day before the event.
  • Users are correlated on the stable object ID (AuditLogs TargetResources.id and sign-in UserId), the same change reviewers asked for on Add hunting query: Entra ID successful sign-in after account disabled #15555, so renamed users, guest UPN differences and reused UPNs don't cause missed or misattributed results. UPNs are kept for display, and the Account entity also maps AadUserId.
  • It is a companion to Add hunting query: Entra ID successful sign-in after account disabled #15555 (successful sign-in after account disabled) and is adapted from the containment-verification query in my public Entra ID account-compromise runbook: https://github.com/mikedsosa/entra-account-compromise-ir
  • Tables: AuditLogs, SigninLogs, AADNonInteractiveUserSignInLogs (Microsoft Entra ID connector). Lookback 7d, pre-event window 1d and grace period are variables at the top.

Version Updated:

  • N/A (new hunting query, version 1.0.0)

Testing Completed:

  • Offline only: the query passes a parse/bind check with Kusto.Language 12.4.1 against the documented SigninLogs, AADNonInteractiveUserSignInLogs and AuditLogs schemas, and the file is ASCII-only. It has not been run in a live Sentinel workspace.

Checked that the validations are passing and have addressed any issues that are present:

  • The repo's validation checks will run on this PR; I'll address anything they flag.

@v-skharode

Copy link
Copy Markdown
Contributor

Hi Mike Sosa (@mikedsosa), the initial query review looks good. Before approval, could you please provide live Sentinel validation evidence for the revocation correlation, 90-minute grace period, and pre-revocation IP matching? Also, please clarify the expected behavior for multiple revocations within the lookback window.

@v-skharode

Copy link
Copy Markdown
Contributor

Mike Sosa (@mikedsosa) Friendly follow up for the mentioned comment.

@mikedsosa

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the follow-up, Shashank Kharode (@v-skharode), and sorry for the slow reply.

  1. Live validation: I don't have live Sentinel results to share yet. Testing so far was offline parsing only, as noted in the PR description. If live evidence from a test tenant is needed before approval, I can work on that, but it won't be immediate.

  2. Multiple revocations in the lookback window: as written, each revocation is evaluated on its own. Results are grouped by user, IP and RevokedTime, so a sign-in that falls after the grace period of two revocations, from an IP seen in both pre-revocation windows, comes back as one row per revocation, and the same sign-in can appear more than once. If you'd prefer, I can change it so each sign-in is only paired with the most recent revocation before it, which gives one row per user and IP for the latest revocation. Let me know which behavior you'd like.

@v-skharode

Copy link
Copy Markdown
Contributor

Thanks for the clarification, Mike. I recommend correlating each sign-in with the most recent preceding revocation to avoid duplicate results. Please also provide Sentinel execution evidence covering the revocation correlation, 90-minute grace period, and pre-revocation IP matching before approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hunting Hunting specialty review needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants