agentleFS
kaandgnshkaandgnsh/Claude-Blue/skills/azure-security/entra-signin-investigation/SKILL.md

entra-signin-investigation

Skill0 starsChanged 16 days agoMITView on GitHub

Investigate Microsoft Entra ID sign-ins — interactive and non-interactive logs, ResultType error codes, Conditional Access results, authentication details (MFA method), device and location, token-replay and AiTM indicators, risky sign-ins (Identity Protection) — with KQL and Graph. Use when a user account may be compromised, a risky sign-in alert fires, or sign-in anomalies need explaining.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When you only have an export (portal download as JSON, Graph auditLogs/signIns, or a Log Analytics query result saved as JSON/JSON lines):

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Entra ID Sign-in Investigation

Data

SigninLogs (interactive), AADNonInteractiveUserSignInLogs (token refresh, SSO — attackers with stolen refresh tokens appear here), AADServicePrincipalSignInLogs, AADManagedIdentitySignInLogs; AADUserRiskEvents / AADRiskyUsers (Identity Protection). Portal retention is limited — rely on Log Analytics/SIEM export.

Core query

let upn = "alice@contoso.com";
union SigninLogs, AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(14d) and UserPrincipalName =~ upn
| extend Country = tostring(LocationDetails.countryOrRegion), City = tostring(LocationDetails.city),
         DeviceId = tostring(DeviceDetail.deviceId), Compliant = tostring(DeviceDetail.isCompliant),
         OS = tostring(DeviceDetail.operatingSystem), Browser = tostring(DeviceDetail.browser)
| project TimeGenerated, Type, IPAddress, Country, City, AppDisplayName, ResourceDisplayName, ResultType, ResultDescription,
          ConditionalAccessStatus, AuthenticationRequirement, MfaDetail, DeviceId, Compliant, OS, Browser, UserAgent,
          UniqueTokenIdentifier, SessionId, RiskLevelDuringSignIn
| order by TimeGenerated asc

(Some columns are dynamic in one table and string in the other; use tostring(parse_json(...)) when unioning.)

ResultType codes (common)

0 success; 50126 invalid username/password; 50053 locked/smart lockout; 50074/50076 MFA required (strong auth); 500121 MFA failed/denied; 53003 blocked by Conditional Access; 50072 user must enroll in MFA (watch for attacker-registered methods). The grouped reference with investigation notes (credential failures, MFA outcomes, policy blocks, token and session revocation codes) is in references/aadsts-codes.md.

Compromise indicators

  • Success from an IP/ASN/country never seen for the user, especially hosting/VPS providers, with a different device ID or no device ID.
  • AiTM phishing: successful sign-in with MFA satisfied from attacker infrastructure seconds after the user's own sign-in to a phishing domain; followed by new inbox rules or MFA method registration.
  • Token replay: non-interactive sign-ins with the same SessionId from a new IP/country while the device ID is absent; Identity Protection "Anomalous token" / "Token issuer anomaly".
  • Sign-ins to unusual resources (Azure PowerShell, Graph Explorer, Microsoft Azure CLI) by non-admin users; user agents like python-requests, axios, Go-http-client.
  • ResultType 0 following many 50126 (spray success — password-spray-detection).

Offline review of an export

When you only have an export (portal download as JSON, Graph auditLogs/signIns, or a Log Analytics query result saved as JSON/JSON lines):

az rest --url "https://graph.microsoft.com/v1.0/auditLogs/signIns?\$filter=userPrincipalName eq 'alice@contoso.com'" > alice.json
python3 scripts/signin_review.py alice.json --max-kmh 900 --fail-count 10 > signin_findings.json

The script normalizes Graph (camelCase) and Log Analytics (PascalCase, LocationDetails as string or object) records and flags impossible-travel, spray-then-success (50126 burst then success), mfa-denied-burst (500121), legacy-auth-success, scripted-client (scripting user agents or admin tooling apps) and session-new-country. VPN egress and mobile carriers cause travel false positives; check the ASN and the device ID before acting.

Next steps

Correlate with AuditLogs (MFA method changes, app consents, role changes — entra-audit-investigation), OfficeActivity/CloudAppEvents for post-auth actions, and respond via account-compromise-investigation.

Related skills

entra-audit-investigation, token-theft-investigation, account-compromise-investigation, conditional-access-review, sentinel-kql-investigation

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.