Microsoft Entra ID (Azure AD) Security
What Is Microsoft Entra ID?
Microsoft Entra ID (formerly Azure Active Directory / Azure AD) is Microsoft’s cloud-based identity and access management (IAM) service. It was rebranded from “Azure AD” to “Microsoft Entra ID” in July 2023 as part of the broader Microsoft Entra product family.
Entra ID provides:
- Authentication and authorization for cloud and on-premises apps
- Single Sign-On (SSO) for thousands of SaaS applications
- Multi-Factor Authentication (MFA)
- Conditional Access policies
- Privileged Identity Management (PIM)
- Integration with on-premises Active Directory via Azure AD Connect
Core Concepts
Tenants
An Entra ID tenant is a dedicated instance of the directory service, representing a single organization. Each tenant has a globally unique domain (e.g., contoso.onmicrosoft.com) and can have custom domains.
Users and Groups
- Member users: Full organizational accounts.
- Guest users (B2B): External identities from other organizations or identity providers.
- Groups: Security groups (for access control) and Microsoft 365 groups.
- Managed Identities: System-assigned or user-assigned identities for Azure resources.
Applications and Service Principals
- App Registrations: Define an application in Entra ID (OAuth2 client).
- Service Principals: Instance of an app registration in a specific tenant (like a role binding).
- Enterprise Applications: Pre-integrated SaaS apps.
Roles
- Built-in roles: Global Administrator, Security Administrator, User Administrator, etc.
- Custom roles: Fine-grained permissions defined by the organization.
- Azure RBAC vs Entra ID roles: Entra ID roles control directory permissions; Azure RBAC controls resource permissions.
Authentication Flows
Modern Authentication (OAuth2 / OIDC)
Entra ID acts as an OAuth2 authorization server and OpenID Connect provider.
1
2
Client → Authorization Endpoint → User login + Consent → Authorization Code
Client → Token Endpoint → Access Token + ID Token + Refresh Token
Token Types
- Access Tokens: JWT tokens for accessing APIs. Short-lived (1 hour default).
- ID Tokens: OIDC tokens containing user identity claims.
- Refresh Tokens: Long-lived tokens for obtaining new access tokens.
Legacy Authentication
Protocols like Basic Auth, NTLM, and older SMTP/IMAP auth are targets for password spray attacks. Conditional Access should block legacy authentication protocols.
Security Features
Conditional Access
Policy engine that evaluates signals (user, device, location, app, risk) before granting access:
- Require MFA from untrusted locations.
- Block access from non-compliant devices.
- Block legacy authentication.
- Require Privileged Access Workstation (PAW) for admin access.
Privileged Identity Management (PIM)
Just-in-Time (JIT) privileged access:
- Roles are assigned as eligible rather than active.
- Users must activate roles with justification and optional MFA.
- Activations are time-limited and audited.
Identity Protection
Risk-based policies:
- Sign-in risk: Suspicious sign-in properties (unusual location, impossible travel, etc.).
- User risk: Leaked credentials, suspicious activity patterns.
- Policies can require MFA or block access based on risk level.
Attack Vectors and Penetration Testing
1. Password Spray Attacks
Targeting many accounts with a small number of common passwords to avoid lockout:
1
2
3
4
5
# Using MSOLSpray (Python)
python3 MSOLSpray.py --userlist users.txt --password "Winter2024!"
# Using Ruler
ruler --email user@contoso.com spray --users userlist.txt --passwords passwdlist.txt
Defensive note: Monitor for sign-in failures across many accounts in a short window. Enable Smart Lockout.
2. Phishing for OAuth Tokens (Consent Phishing)
Attackers register a malicious app and trick users into granting it permissions:
- Register an app with delegated permissions (Mail.Read, Files.ReadWrite, etc.).
- Send phishing link to OAuth consent page.
- Once user consents, attacker has long-lived access via refresh token.
Detection: Review enterprise app consent grants; monitor for new app registrations with high-privilege permissions.
3. Token Theft and Replay
If an attacker compromises an access token or refresh token (via XSS, malware, MITM), they can replay it:
1
2
# Using TokenTactician or Graph API
curl -H "Authorization: Bearer <stolen_token>" https://graph.microsoft.com/v1.0/me
Mitigation: Continuous Access Evaluation (CAE), token binding.
4. Service Principal Credential Abuse
Applications often have client secrets or certificates. If these are leaked:
1
2
3
# Connect to Microsoft Graph using stolen client credentials
az login --service-principal -u <app-id> -p <client-secret> --tenant <tenant-id>
az ad sp list --all
5. Entra ID Enumeration
Before attacking, enumerate tenants, users, and apps:
1
2
3
4
5
6
# Using AADInternals
Import-Module AADInternals
Invoke-AADIntReconAsOutsider -DomainName contoso.com
# Get tenant info
Get-AADIntTenantID -Domain contoso.com
6. Lateral Movement via Managed Identities
Azure resources with Managed Identity can request tokens from IMDS:
1
2
# From a compromised Azure VM
curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/' -H Metadata:true
If the managed identity has excessive permissions, this can lead to privilege escalation across Azure resources.
Assessment Checklist
- Legacy authentication protocols blocked via Conditional Access
- MFA enforced for all users, especially admins
- PIM configured for privileged roles (no permanent admin assignments)
- App registrations reviewed for excessive permissions
- Third-party OAuth app consent reviewed and restricted
- External user (B2B guest) access reviewed
- Identity Protection risk policies configured
- Audit logs monitored (Sign-in logs, Audit logs, Risky sign-ins)
- Emergency access accounts (break-glass) properly secured
Microsoft Entra ID란?
Microsoft Entra ID(구 Azure Active Directory / Azure AD)는 Microsoft의 클라우드 기반 ID 및 접근 관리(IAM) 서비스입니다. “Azure AD”에서 “Microsoft Entra ID”로의 리브랜딩은 2023년 7월 더 넓은 Microsoft Entra 제품 패밀리의 일환으로 이루어졌습니다.
Entra ID는 다음을 제공합니다:
- 클라우드 및 온프레미스 앱에 대한 인증 및 권한 부여
- 수천 개의 SaaS 애플리케이션에 대한 SSO(Single Sign-On)
- 다중 요소 인증(MFA)
- 조건부 액세스 정책
- PIM(Privileged Identity Management)
핵심 개념
테넌트
Entra ID 테넌트는 단일 조직을 나타내는 디렉터리 서비스의 전용 인스턴스입니다.
사용자 및 그룹
- 멤버 사용자: 전체 조직 계정
- 게스트 사용자(B2B): 다른 조직의 외부 ID
- 그룹: 보안 그룹(접근 제어용) 및 Microsoft 365 그룹
- 관리 ID: Azure 리소스를 위한 시스템 할당 또는 사용자 할당 ID
애플리케이션 및 서비스 주체
- 앱 등록: Entra ID에서 애플리케이션 정의(OAuth2 클라이언트)
- 서비스 주체: 특정 테넌트에서의 앱 등록 인스턴스
- 엔터프라이즈 애플리케이션: 미리 통합된 SaaS 앱
공격 벡터 및 침투 테스트
1. 패스워드 스프레이 공격
계정 잠금을 피하기 위해 많은 계정에 소수의 일반 비밀번호로 공격하는 방법입니다.
방어: 짧은 시간 내 여러 계정의 로그인 실패 모니터링 및 Smart Lockout 활성화.
2. OAuth 토큰 피싱 (동의 피싱)
공격자가 악성 앱을 등록하고 사용자를 속여 권한을 부여하게 합니다. 사용자가 동의하면 공격자는 리프레시 토큰을 통해 장기적인 접근권을 얻습니다.
탐지: 엔터프라이즈 앱 동의 부여 검토 및 높은 권한 앱 등록 모니터링.
3. 토큰 도용 및 재사용
접근 토큰이나 리프레시 토큰이 침해되면(XSS, 멀웨어, MITM 등) 재사용될 수 있습니다.
완화: 지속적인 접근 평가(CAE), 토큰 바인딩.
4. 서비스 주체 자격 증명 남용
애플리케이션은 클라이언트 비밀이나 인증서를 가집니다. 이것들이 노출되면 공격자가 Azure 리소스에 접근할 수 있습니다.
5. 관리 ID를 통한 횡적 이동
관리 ID가 있는 Azure 리소스는 IMDS에서 토큰을 요청할 수 있습니다. 관리 ID에 과도한 권한이 있으면 Azure 리소스 전반에 걸쳐 권한 상승으로 이어질 수 있습니다.
평가 체크리스트
- 조건부 액세스를 통한 레거시 인증 프로토콜 차단
- 모든 사용자, 특히 관리자에게 MFA 적용
- 권한 있는 역할에 대한 PIM 구성 (영구 관리자 할당 없음)
- 과도한 권한에 대한 앱 등록 검토
- 타사 OAuth 앱 동의 검토 및 제한
- 외부 사용자(B2B 게스트) 접근 검토
- ID 보호 위험 정책 구성
- 감사 로그 모니터링 (로그인 로그, 감사 로그, 위험 로그인)
- 비상 접근 계정(break-glass)의 적절한 보안