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.
In this repository273 other files it gives its agents.
- ad-attack-path-analysisSkill
- adcs-security-reviewSkill
- ad-privileged-access-reviewSkill
- dcsync-detectionSkill
- gpo-security-reviewSkill
- kerberos-attack-detectionSkill
- agent-tool-permission-reviewSkill
- ai-incident-responseSkill
- llm-gateway-controlsSkill
- llm-security-evaluationSkill
- mcp-server-security-reviewSkill
- model-artifact-securitySkill
- prompt-injection-reviewSkill
- rag-security-reviewSkill
- api-abuse-detectionSkill
- api-authorization-testingSkill
- api-inventorySkill
- api-schema-securitySkill
- dast-baselineSkill
- sast-triageSkill
- sca-dependency-riskSkill
- secure-code-reviewSkill
- security-requirementsSkill
- threat-modelingSkill
- asset-criticality-tieringSkill
- asset-inventory-reconciliationSkill
- external-attack-surface-reviewSkill
- shadow-it-discoverySkill
- aws-credential-compromiseSkill
- aws-iam-reviewSkill
- aws-org-guardrailsSkill
- cloudtrail-investigationSkill
- guardduty-triageSkill
- s3-exposure-reviewSkill
- azure-activity-investigationSkill
- azure-rbac-reviewSkill
- conditional-access-reviewSkill
- entra-audit-investigationSkill
- backup-assuranceSkill
- critical-service-mappingSkill
- ransomware-recoverySkill
- recovery-exerciseSkill
- cloud-exposure-reviewSkill
- cloud-incident-responseSkill
- cloud-logging-baselineSkill
- cloud-posture-assessmentSkill
- audit-evidence-packageSkill
- continuous-control-monitoringSkill
- control-mappingSkill
- control-testing-samplingSkill
- container-incidentSkill
- dockerfile-hardeningSkill
- image-scanningSkill
- runtime-detection-falcoSkill
- db-audit-loggingSkill
- db-exfiltration-investigationSkill
- db-hardeningSkill
- db-privilege-reviewSkill
- data-classificationSkill
- data-discoverySkill
- The first 60 shown.
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
- Very specific: line 47
When you only have an export (portal download as JSON, Graph auditLogs/signIns, or a Log Analytics query result saved as JSON/JSON lines):
≈ “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.
Files
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
SessionIdfrom 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 likepython-requests,axios,Go-http-client. ResultType 0following many50126(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.jsonThe 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
- Sign-in logs schema: https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/signinlogs
- AADSTS error codes: https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes
- Identity Protection risk detections: https://learn.microsoft.com/en-us/entra/id-protection/concept-identity-protection-risks
- Microsoft token theft playbook: https://learn.microsoft.com/en-us/security/operations/token-theft-playbook
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
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.

