---
title: "Entra Connect Attacker Tradecraft: Part 2"
author: Daniel Heinsen (hotnops)
date: 2025-01-22
url: https://blog.hotnops.dev/posts/entra-connect-attacker-tradecraft-part-2/
tags: [entra-id, entra-connect, red-team]
graph: https://blog.hotnops.dev/graph.json
---

# Entra Connect Attacker Tradecraft: Part 2

## Agent brief

The post asks whether a compromised Entra Connect sync account in one Active Directory domain can add credentials to a user in a different domain synced to the same Entra tenant. It walks through Entra Connect sync rules (provisioning, scoping filters, join rules, transformations) and shows that cloudFiltered accounts such as MSOL_, krbtgt_, and AAD_ are only blocked from outbound provisioning, leaving partially synced objects in the metaverse. An attacker who creates an Entra user with a matching sourceAnchor completes the inbound join, then adds a Windows Hello for Business key that syncs down to msDS-KeyCredentialLink and yields a Kerberos TGT for the target. The post closes with prevention and detection guidance backed by PowerShell cmdlets in the author's ECUtilities module.

### Key findings
- In Entra Connect Sync, cloudFiltered objects such as MSOL_, krbtgt_, and AAD_ accounts are still projected into the metaverse; outbound filtering only blocks them from being provisioned into the Entra connector space.
- The 'In from AAD - User Join' sync rule links an Entra user to a metaverse object whose sourceAnchor matches, so an attacker who creates an Entra user with a target's sourceAnchor completes the join to a partially synced on-premises account.
- A compromised Entra Connect sync (ADSync) account in Domain A can use the provisioning API via AADInternals to create an Entra user with an arbitrary sourceAnchor that hijacks an account in Domain B of the same tenant.
- The sourceAnchor is derived from ms-DS-ConsistencyGuid and falls back to objectGUID; the author's uuid_to_sourceAnchor.py converts a target objectGUID into the sourceAnchor blob needed for the join.
- The MSOL_ AD DS connector account created at Entra Connect install has DCSync privileges and write-all over users in the Users OU, so the attack affects any user that inherits its DACLs from the Users OU and whose msDS-KeyCredentialLink the MSOL account can write.
- Users in protected groups (adminCount=1) automatically have inheritance disabled by AdminSDHolder/SDProp, so the MSOL account cannot write to them and they are not affected by this attack.
- Detection signal: any user in the Entra connector space whose metaverse projection has cloudFiltered set to 'true' indicates something is wrong; an ECUtilities cmdlet enumerates such users.

### Attack path: Cross-domain account takeover via sourceAnchor join hijack
Prerequisites: Compromised Entra Connect sync (ADSync) account in Domain A (federated.hotnops.com); Unprivileged Beacon in the target domain (hybrid.hotnops.com); A target account in the target domain that is cloud filtered / partially synced and whose msDS-KeyCredentialLink is writable by the MSOL account
1. Enumerate users in the target domain to find a partially synced, cloudFiltered account and record its ObjectId.
2. Derive the target's sourceAnchor from its ObjectId.
3. Use the compromised sync account's token to create a new Entra user carrying the target's sourceAnchor.
4. Wait for the target domain's next Entra Connect sync cycle (up to 30 minutes) to join the new Entra user to the on-premises target object.
5. Register a Windows Hello for Business key on the created Entra user so it syncs down into the target's msDS-KeyCredentialLink.
6. Convert the registered key to a certificate and request a Kerberos TGT for the target account from the target-domain Beacon.
Outcome: A Kerberos TGT and credentials for a (potentially privileged) account in a separate on-premises domain of the same Entra tenant.
MITRE ATT&CK: T1098 (inferred), T1556 (inferred), T1558 (inferred)

### Detections
- Flag any user in the Entra connector space whose metaverse projection has the cloudFiltered attribute set to 'true'; the ECUtilities cmdlet enumerates these (does not catch all hijackable objects but covers the obvious cloudFiltered case).

### Mitigations
- Identify all partially synced users (object in the on-prem connector space and metaverse but not in the Entra connector space) using the ECUtilities script.
- Identify all privileged users inheriting permissions from the Users OU, which the MSOL account can write to, using the provided ECUtilities cmdlet.
- Accounts with inheritance disabled (including protected adminCount=1 accounts handled by AdminSDHolder) cannot be written by the MSOL account and are not affected.

### Resources
- [ECUtilities (uuid_to_sourceAnchor.py and detection/prevention cmdlets)](https://github.com/hotnops/ECUtilities)
- [AADInternals](https://github.com/Gerenios/AADInternals)
- [Entra Connect sync rules reference gist (CloudFiltered rule, In from AAD - User Join)](https://gist.github.com/hotnops/e450688fb4792845c047d336277f3d2c)
- [Walkthrough video](https://medium.com/media/c660b5db95016d2c1ab9ef61bd362c51/href)
- [Shadow Credentials: Abusing Key Trust Account Mapping for Account Takeover](https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab)
- [Microsoft Entra Connect Sync: Configure filtering](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sync-configure-filtering)
- [AdminSDHolder, Protected Groups and Security Descriptor Propagator](https://learn.microsoft.com/en-us/archive/technet-wiki/22331.adminsdholder-protected-groups-and-security-descriptor-propagator)
- [DEF CON 32 - Abusing Windows Hello Without a Severed Hand](https://www.youtube.com/watch?v=mFJ-NUnFBac)
- [Introducing ROADtools Token eXchange (roadtx)](https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/)
- [Attacking Azure AD by abusing Synchronisation API (AADInternals talk)](https://aadinternals.com/talks/Attacking%20Azure%20AD%20by%20abusing%20Synchronisation%20API.pdf)

---

## Full text

Now that we know how to add credentials to an on-premises user, lets pose a question:

**_“Given access to a sync account in Domain A, can we add credentials to a user in another domain within the same Entra tenant?”_**

This is a bit of a tall order assuming we have very few privileges in Entra itself. Remember from [Part 1](https://posts.specterops.io/attacking-entra-metaverse-part-1-c9cf8c4fb4ee) that the only thing we can sync down, by default, is the msDS-KeyCredentialLink property. In order to understand how to take advantage of this, we need to learn some more fundamentals of the Entra sync engine and how the rules work:

### Rule Intro

We have yet to look at a concrete rule, so let’s look at the first rule defined in the Rules Editor.

[figure]

Note that the direction is not shown here, but I am showing the inbound rules in the sync rules editor. The direction is in the XML definition. The “Connected System” is the connector space that the source object is coming from (in this case, _hybrid.hotnops.com_). Since the AD object is a user, the connector space object is “user” and the user representation in the metaverse is called a “person”. The link type of “Provision” is saying “create a metaverse object if one does not exist yet”. In sum, this rule is telling the sync engine to create a metaverse object for any user in the connector space. Remember the connector is responsible for enumerating LDAP and populating all AD users into the connector space.

[figure]

Next, the scoping filter sets which objects are to be provisioned. We can see here that if the connector space object has a property of **isCriticalSystemObjec**t not set to “true” AND **adminDescription** doesn’t start with “User\_”, then the object will be provisioned. Remember that the object still exists in connector space, even though it won’t be projected into the metaverse.

[figure]

Next, we get to the “join” rules which are critical to understand. The join rules are the logic that creates the links between the metaverse objects, and the connector space objects, resulting in concrete MSSQL relationships. In this case, the rule is saying that the ms-DS-ConsistencyGuid on the connector space object needs to match the sourceAnchorBinary on the metaverse object. If the ms-DS-ConsistencyGuid property doesn’t exist, the objectGUID is used. It’s also important to remember that joins happen for both inbound (from a connector space into the metaverse) and outbound (from the metaverse into the connector space) attribute flows.

[figure]

Lastly, the transformations list which target object properties need to be mutated. Note that the language for these transformations is effectively VBA. In this case, two properties will be set on the metaverse person:

1.  **cloudFiltered** — This will be important later. This is a rather large rule that describes a list of string patterns, such as if the sAMAccountName starts with “krbtgt\_” or “AAD\_”, etc. If “true”, then a property called cloudFiltered will be set to “true” on the metaverse object.
2.  **sourceAnchorBinary** — Remember this from the join rule? In this rule, the sourceAnchorBinary is set on the metaverse object to match either the ms-DS-ConsistencyGuid or the objectId.

We have now walked through a full provisioning rule but note that most rules do not provision anything; rather, they are joined to existing objects and certain transformations are projected into the metaverse.

So far, we have described the flow **_into_** the metaverse, so how does a property flow **_out_**? Let’s take a look at the two rules we care about. First, let’s look at how users are provisioned in Entra:

[figure]

The “Link Type” is “Provision”, meaning that a new object will be created in the Entra connector space. The Entra connector (Sync Agent), will use that object creation to trigger a new user creation in Entra.

**This part is really important.** If we look at the filter, objects are only provisioned to the Entra connector space if all of these conditions are met. Remember that some of our privileged accounts, such as the “MSOL” account, “krbtgt”, and “AAD\_” account names are set to be cloud filtered. That means that they are projected into the metaverse, but the Entra user _provisioning_ is simply being blocked by the sync engine.

[figure]

Last rule, I promise. Let’s look at how Entra users are joined to on-premises users:

[figure]

[figure]

This is saying that if an Entra user with a source anchor matches a metaverse object with the same source anchor, they will be tied together.

**_Do you see it?_**

[figure]

There are partially linked objects in the metaverse, and we can trigger a link by creating a new user with the matching sourceAnchor.

In simple terms, **CloudFiltered objects are prevented from being provisioned only!** **AKA** [**Outbound Filtering**](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sync-configure-filtering#outbound-filtering). If we can provision the Entra user ourselves, we can complete the inbound join rule and take over the user account in another domain, as long as the MSOL account can write their msDS-KeyCredentialLink property.

And chaining this together, because we can control the user password and creation from the compromised sync account in Domain A, we can then add the WHFB credentials discussed in the part one of this blog series and add credentials to a potentially privileged user.

Before we continue, this attack has some important caveats:

The MSOL account used for attribute flows has write permissions at the “Users” OU level by default. If a user account has inheritance disabled, then MSOL will not be able to write to it and this attack will not affect the account.

[figure]

### Walkthough

Enough talking; let’s do a walkthrough. In this scenario, we have a tenant (_hotnops.com)_ with two on-premises domains: **_federated.hotnops.com_** and **_hybrid.hotnops.com_**. As an attacker, we have fully compromised **_federated.honops.com_** and have an unprivileged Beacon in **_hybrid.hotnops.com_**. We will take advantage of the compromised Entra Connect Sync account in **_federated.honops.com_** to take over **_hybrid.hotnops.com_**.

If you want a full walkthrough with all the command line minutae, the video is here:

<a href="https://medium.com/media/c660b5db95016d2c1ab9ef61bd362c51/href">https://medium.com/media/c660b5db95016d2c1ab9ef61bd362c51/href</a>

### Step 1

[figure]

From the Beacon in **_hybrid.hotnops.com_**, we need to identify an account we’d like to take over and identify the sourceAnchor that we need.

To do this, we want to find partially synced metaverse objects. For the sake of this walkthrough, we can run dsquery:

#> dsquery \* "CN=Users,DC=hybrid,DC=hotnops,DC=com" -attr \*

With those results, we want to look for any account that matches our “CloudFiltered” rule, which is defined [here](https://gist.github.com/hotnops/e450688fb4792845c047d336277f3d2c#file-gistfile1-txt-L5723).  
In our case, there is an account named “AAD\_cb48101f-7fc5–4d40-ac6c-09b22d42a3ed”. These are older connector accounts installed with AAD Connect Sync. If you identify an account that may be cloud filtered, you will need the corresponding ObjectID associated with the account that is in the dsquery results. In our case, the object ID is

0A08E28B-5D21–4960-A25A-F724F1E96155

Since the ObjectId is used as the sourceAnchor, we want to create a new Entra user with that sourceAnchor so it will link to our targeted “AAD\_” account. In order to convert the UUID to a sourceAnchor, we simply need to convert the UUID to a binary blob where each section is little endian. I have a script to do it [here](https://github.com/hotnops/ECUtilities/blob/main/uuid_to_sourceAnchor.py), but there are probably easier ways.

./uuid\_to\_sourceAnchor.py 0A08E28B-5D21–4960-A25A-F724F1E96155

We now want to use our Sync Account in **_federated.hotnops.com_** to create a new user with that sourceAnchor so that it will create a link to our target user in **_hybrid.hotnops.com_**. We can do that by obtaining credentials for the ADSync account and using the provisioning API. You’ll need to obtain an access token for the ADSync account, which I demonstrate in the video linked above. Once you have your token, you’ll need to use [AADInternals](https://github.com/Gerenios/AADInternals) to create the account.

#> Set-AADIntAzureADObject -AccessToken $token -SourceAnchor $sourceAnchor -userPrincipalName <upnOfTarget> -accountEnabled $true

At this point, we have achieved Step 1. We have a new user in Entra with a matching sourceAnchor, and now we need to wait up to 30 minutes (by default) for the target domain to run an Entra Connect sync, at which time the Entra user and the on-premises target “AAD\_cb48101f-7fc5–4d40-ac6c-09b22d42a3ed” link together.

### Step 2

Once the user is created, add an msDS-KeyCredentialLink to the newly created Entra user as documented in the [first blog post in this series](https://posts.specterops.io/attacking-entra-metaverse-part-1-c9cf8c4fb4ee).

[figure]

### Step 3: Profit

Once the Entra Connect sync agent on **_hybrid.hotnops.com_** runs the next sync, it will use the join rule “[In from AAD — User Join](https://gist.github.com/hotnops/e450688fb4792845c047d336277f3d2c#file-gistfile1-txt-L2)” to link the Entra user to the metaverse object associated with the on-premises “AAD\_cb48101f-7fc5–4d40-ac6c-09b22d42a3ed” account.

[figure]

From here, we will use our Beacon in **_hybrid.hotnops.com_** and methods documented in the [Shadow Credentials blog](https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab) to elevate privileges.

As a result of registering a Windows Hello For Business (WHFB) key on your created Entra user, you will have a key called “winhello.key”. In order to use it with Rubeus, we need to format it as a PFX file. The steps are below:

openssl req -new -key ./winhello.key -out ./winhello\_cert\_req.csr  
openssl x509 -req -days 365 -in ./winhello\_cert\_req.csr -signkey ./winhello.key -out ./winhello\_cert.pem  
openssl pkcs12 -export -out aad.pfx -inkey ./winhello.key -in ./winhello\_cert.pem

Now, we need to go to our Beacon on **_hybrid.hotnops.com_** and upload the PFX:

beacon> upload aad.pfx

Now, run the Rubeus command:

beacon> rubeus asktgt /user:AAD\_cb48101f-7fc5–4d40-ac6c-09b22d42a3ed /certificate:C:\\Path\\To\\aad.pfx /password:"certPassword" /domain:hybrid.hotnops.com /dc:DC1-HYBRID.hotnops.com /getcredentials /ptt

Congratulations! Your Beacon process now has a token for your targeted account.

### Prevention

#### Identify All Partially Synced Users

For our purposes, a partially synced user is one that has an object in the on-premises connector space, a projection in the metaverse, but not an object in the Entra connector space. The reason why these exist, as mentioned earlier, is due to outbound filtering. In order to determine which users are partially synced, we can query all the objects in the metaverse and connector spaces and see which ones don’t have an object in the Entra connector space. The script to do that is [here](https://github.com/hotnops/ECUtilities/blob/10d2a04401a6f38070d39928a957d25d86711e69/ECUtilities.psm1#L57) and here is an example output:

[figure]

#### Identify All Privileged Users Inheriting Permissions From the Users OU

When Entra Connect is installed, an Active Directory Domain Services (AD DS) Connector account is created in the naming scheme of “MSOL\_<random garbage>”. This account is responsible for syncing hashes (yes, it has DCSync privileges) and reading/writing properties on users to support the attribute flows. As a result of this, the MSOL account is given write all over all users in the “Users” OU.

[figure]

That means this attack can affect any user that inherits their discretionary access control lists (DACLs) from the Users OU (which is pretty much all users). This is generally true of any Sync attack; however, something I learned during this research is that users added to sensitive privileged groups such as Domain Administrators will **automatically have their inheritance disabled**. Even when I re-enable it, some script comes along and disables it again. This led me to [this technet article](https://learn.microsoft.com/en-us/archive/technet-wiki/22331.adminsdholder-protected-groups-and-security-descriptor-propagator) which claims that any AD group marked “protected” will routinely get a template DACL applied to them located at CN=AdminSDHolder,CN=System,DC=hybrid,DC=hotnops,DC=com.

So which users are “protected”?

Any user that has the adminCount property set to “1”. (_Edit: Thanks to_ [_Clément Notin (@cnotin)_](https://x.com/cnotin?lang=en) _for pointing out that the adminCount is the result of AD evaluating such criteria, not the source. More details_ [_here_](https://learn.microsoft.com/en-us/archive/blogs/askds/five-common-questions-about-adminsdholder-and-sdprop)_)_ Ultimately, as long as the target’s msDS-KeyCredentialLink attribute is writable by the MSOL account AND it is partially synced, then it is susceptible to this attack. I [provided a powershell cmdlet](https://github.com/hotnops/ECUtilities/blob/10d2a04401a6f38070d39928a957d25d86711e69/ECUtilities.psm1#L3) to list all users that inherit their DACLs from the Users OU:

[figure]

### Detection

Detection of this misconfiguration/attack may be difficult but there are some solid signals that something is off. If any users in the Entra connector space have a metaverse projection with a “cloudFiltered” attribute set to “true”, then something is wrong. You can use the powershell cmdlet [here](https://github.com/hotnops/ECUtilities/blob/10d2a04401a6f38070d39928a957d25d86711e69/ECUtilities.psm1#L96) to check for those users. While this doesn’t detect all hijackable metaverse objects, it does cover the most obvious case of cloudFiltered users.

[figure]

### References

[Microsoft Entra Connect Sync: Configure filtering - Microsoft Entra ID](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sync-configure-filtering)

[Shadow Credentials: Abusing Key Trust Account Mapping for Account Takeover | by Elad Shamir | Posts By SpecterOps Team Members](https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab)

[Gerenios/AADInternals: AADInternals PowerShell module for administering Azure AD and Office 365](https://github.com/Gerenios/AADInternals)

[DEF CON 32 — Abusing Windows Hello Without a Severed Hand — Ceri Coburn, Dirk jan Mollema](https://www.youtube.com/watch?v=mFJ-NUnFBac)

[Introducing ROADtools Token eXchange (roadtx) — Automating Azure AD authentication, Primary Refresh Token (ab)use and device registration — dirkjanm.io](https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/)

[aadinternals.com/talks/Attacking Azure AD by abusing Synchronisation API.pdf](https://aadinternals.com/talks/Attacking%20Azure%20AD%20by%20abusing%20Synchronisation%20API.pdf)

* * *

[Entra Connect Attacker Tradecraft: Part 2](https://medium.com/specter-ops-posts/entra-connect-attacker-tradecraft-part-2-672df0147abc) was originally published in [Posts By SpecterOps Team Members](https://medium.com/specter-ops-posts) on Medium, where people are continuing the conversation by highlighting and responding to this story.
