Entra ID Connect Arbitrary Password Overwrite
An attacker with local administrator access to an AADConnect server can inject a malicious DLL into the miiserver.exe process to overwrite a targeted user's NT hash before it is sent to Entra ID. This allows the attacker to authenticate as that user in Entra ID, potentially including a Global Administrator, and maintain access until the service is restarted.
Published on nullg0re.com
I recently published a blog post detailing an attack where we could hijack AADConnect’s DCSync dataset to steal credentials and crack the credentials offline. The foundational knowledge here is as follows:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Entra ID Connect (formerly AADConnect) is the Microsoft tool that synchronises an on-premises Active Directory with Entra ID. Part of its job is to collect on-premises users' credentials: it performs DCSync operations against the domain, encrypts each NT hash 1,000 times, and ships the resulting encrypted credential dataset to Entra ID for processing. Entra ID treats what it receives as the hash of record for the corresponding Azure account.
This write-up builds on an earlier post about hijacking AADConnect's DCSync dataset to steal and crack credentials offline. The same mechanism, taken one step further, allows an attacker to overwrite a chosen user's NT hash with a value they control before it is encrypted and sent to Entra ID.

Setup
The attack requires Local Administrator access on the AADConnect server. Microsoft classifies these servers as Tier 0 devices, and its documentation states that they must have the highest security because they can be severely abused or exploited.
The technique reuses the same components as the earlier DCSync hijacking work:
- the Microsoft.Online.PasswordSynchronization.dll DLL;
- the PasswordUtility class;
- the DecryptNtOwfPwdWithIndex method.
The earlier post established the foundational behaviour:
- AADConnect performs DCSync operations to collect on-premises users' credentials.
- Each NT hash is encrypted 1,000 times.
- The resulting encrypted credential dataset is sent off to Entra ID for processing.
By injecting a malicious DLL into the miiserver.exe process, the DCSync dataset could be siphoned to a file on disk for later exfiltration and cracking, performing DCSync without triggering traditional alerts.
Finding it
The insight is that the same hook point used to copy the dataset can instead modify it. Because the DLL sits inside the process that prepares the credentials for Entra ID, it can replace a user's NT hash with an attacker-controlled value before the 1,000-fold encryption and the upload take place. Entra ID considers the overwritten hash the hash of record for that Azure account.
Exploitation
The proof of concept from the previous post is reused, but instead of writing the credentials to disk, it targets a specific user and overwrites that user's NT hash.
Step 1: Gain Local Administrator on the AADConnect server
The attacker first obtains Local Administrator access to the AADConnect server. This is the precondition for injecting code into miiserver.exe.
Step 2: Build a malicious DLL targeting a Global Administrator
The DLL is built to target a Global Administrator account. In the example, the targeted account is victimuser2.
Step 3: Inject the DLL into miiserver.exe
The malicious DLL is injected into the miiserver.exe process, placing the attacker's code inside the component that handles credential synchronisation.
Step 4: AADConnect initiates DCSync
AADConnect starts its normal DCSync operation to collect on-premises credentials.
Step 5: Overwrite the target's NT hash during encryption
AADConnect begins encrypting each NT hash 1,000 times. When DecryptNtOwfPwdWithIndex reaches the victimuser2 credential information, the injected code converts the MD4 hash of TacoTacoTaco123!! into the correct .NET format (e9-f8-c7-40-etc-etc) and assigns the result variable with the overwritten NT hash.

Step 6: The overwritten hash is encrypted and shipped
AADConnect encrypts the overwritten hash 1,000 times and continues its operations, then ships the encrypted hashes to Entra ID.
Step 7: Entra ID processes the hashes
Entra ID receives the NT hashes and processes them, considering the overwritten hash the hash of record for the user's Azure account.
Step 8: Pivot to Entra ID
The attacker pivots from on-premises to Entra ID, taking the Global Administrator account with it. They collect Access Tokens, Refresh Tokens and Primary Refresh Tokens, and set up backdoor accounts, all before restarting the miiserver.exe service and without triggering any alerts.
The on-premises account's NT hash is now out of sync with the Entra ID NT hash. As long as the miiserver.exe process is not restarted, the attacker can log into the user's Azure account indefinitely.
Attack path summary
- Attacker gains access to the AADConnect Server as Local Administrator.
- Attacker builds malicious DLL that targets a Global Administrator.
- Attacker injects malicious DLL into the miiserver.exe process.
- AADConnect initiates DCSync to collect on-premises credentials.
- AADConnect begins the process of encrypting each NT hash 1,000 times. When the AADConnect function reaches the targeted Global Administrator account, the DLL code overwrites the Global Admins NT Hash with a value the attacker controls.
- AADConnect proceeds to encrypt the overwritten hash and continues operations.
- AADConnect ships the encrypted hashes to Entra ID.
- Entra ID receives the NT hashes and processes them.
- Attacker pivots from on-premises to Entra ID, taking the Global Administrator account with it.
- Attacker collects Access Tokens, Refresh Tokens, and Primary Refresh Tokens, sets up backdoor accounts, etc… all before restarting the miiserver.exe service without triggering any alerts.
Root cause
The DecryptNtOwfPwdWithIndex method iterates through the DCSync results and encrypts each NT hash before packaging it for Entra ID, . Code running in the same process can therefore substitute the value assigned to the result variable, and the encrypted dataset that Entra ID receives carries the attacker's hash as the hash of record.
The report notes that the earlier DCSync hijack allowed DCSync operations without triggering traditional alerts.
Impact
An attacker with Local Administrator access on an AADConnect server can overwrite a user's NT hash, including a Global Administrator, with a value they control. They can then authenticate to Entra ID as that user, pivot from on-premises to the cloud, collect Access Tokens, Refresh Tokens and Primary Refresh Tokens, and set up backdoor accounts. The access persists as long as miiserver.exe is not restarted, and the activity does not trigger traditional alerts.
Fix
If an adversary has performed this attack, the compromised user's credential can be reset to its original value by restarting the miiserver.exe process and then performing a full sync between on-premises and Entra ID. This resets the password in Azure's records to the value stored on-premises.
Microsoft's position is that the attack requires Local Admin privileges on an AADConnect server, which are considered Tier 0 devices. Microsoft's documentation states that these devices must have the highest security because they can be severely abused or exploited.
Variants to test
What happened, in plain words
Imagine a company has two copies of its staff directory. One copy sits on the company's own computers (the "on-premises" copy), and the other sits in Microsoft's cloud service, Entra ID. A Microsoft tool called Entra ID Connect, formerly known as AADConnect, runs on a company server and keeps the two copies in step. Among other things, it copies each user's password information from the local directory up to the cloud, so that people can sign in to cloud services with the same password they use at the office.
This write-up describes a way to abuse that tool. If an attacker can already get administrator rights on the server where Entra ID Connect runs, they can slip their own code into the program that does the copying. That code waits until the tool is about to send a particular user's password information to the cloud, and quietly swaps it for a value the attacker chose. The cloud service accepts the attacker's value as the hash of record for that account. The attacker can then sign in to the cloud as that user, even a Global Administrator, the most powerful kind of account in the organisation.
The trick builds on an earlier piece of research by the same author, which showed how to copy the password data on its way out and crack it offline. This time the data is not copied but altered.

The background you need first
Before the attack makes sense, a few pieces of the picture need explaining.
What Entra ID Connect (AADConnect) is
Most organisations run their own user directory on their own servers. Microsoft's version of that directory is called Active Directory, and the server that holds it is called a domain controller. Many of the same organisations also use Microsoft's cloud service, Entra ID (formerly Azure Active Directory), for email, file storage and sign-in to cloud apps.
Entra ID Connect is the bridge between the two. It is a program that runs on a Windows server inside the company and periodically copies user accounts, groups and password information from the local Active Directory up to Entra ID. Without it, a user would have two separate passwords, one for the office network and one for the cloud.
What a password hash is
A directory never stores passwords as plain text. Instead it stores a hash: the result of running the password through a mathematical function that always produces the same output for the same input, but from which you cannot easily work backwards to the password. Windows directories use a particular kind of hash called an NT hash, produced by an algorithm called MD4. When you type your password, the system hashes what you typed and compares the result with the stored hash. If they match, you are let in.
This matters because if an attacker can replace the stored hash with the hash of a password they know, they can sign in with that password. They never need to know the original.
What DCSync is
DCSync is a feature of Active Directory that lets one domain controller ask another for a copy of user credential data. It exists so that domain controllers can stay in sync with each other. Entra ID Connect uses DCSync to pull the password hashes it needs to send to the cloud.
What happens to the hashes on the way out
Entra ID Connect does not send the raw NT hashes to Microsoft. Instead, for each hash, it applies an encryption step 1,000 times in a row. The result is a scrambled value that only Entra ID can make sense of. The cloud service then treats that scrambled value as the authoritative record of the user's password, which security people call the hash of record.
The earlier research established three facts that everything here rests on:
- AADConnect performs DCSync operations to collect on-premises users' credentials.
- Each NT hash is encrypted 1,000 times.
- The resulting encrypted credential dataset is sent off to Entra ID for processing.
What a DLL and process injection are
A DLL (dynamic link library) is a file full of code that a Windows program can load and run. Many programs are built from a main executable plus a set of DLLs that provide specific functions.
Process injection is a technique where an attacker makes a running program load a DLL of the attacker's choosing. Once loaded, the attacker's code runs inside that program, with the same access and privileges. It is a bit like slipping your own page into someone else's recipe book: the cook follows the recipe as normal, but your page is now part of it.
In the earlier research, the author injected a malicious DLL into miiserver.exe, the Entra ID Connect process that handles credential synchronisation. That let the attacker copy the DCSync dataset to a file on disk for later exfiltration and cracking, performing DCSync without triggering traditional alerts.
The three components reused here
The new attack reuses the same building blocks as the earlier work:
- the Microsoft.Online.PasswordSynchronization.dll DLL, the Microsoft library that handles password synchronisation;
- the PasswordUtility class, a named grouping of code inside that library;
- the DecryptNtOwfPwdWithIndex method, a specific function inside that class that processes each user's password data in turn.
Because the attacker's DLL runs inside the same process, it can call or replace these functions and see the data they handle.
The idea in one sentence
The earlier attack copied the credential data on its way past. This one changes it. Because the malicious DLL sits inside the process that prepares the credentials for Entra ID, it can replace a user's NT hash with an attacker-controlled value before the 1,000-fold encryption and the upload take place. Entra ID has no way to tell that the hash it receives is not the one stored on-premises, so it records the attacker's value as the hash of record for that Azure account.
The attack, step by step
Step 1: Gain Local Administrator on the AADConnect server
The attacker first obtains Local Administrator access to the AADConnect server. Local Administrator means an account with full control over that one machine: it can install software, change settings and inject code into running programs. This is the precondition for injecting code into miiserver.exe. Without it, none of the rest is possible.
Step 2: Build a malicious DLL targeting a Global Administrator
The DLL is built to target a Global Administrator account. A Global Administrator is the highest level of administrative account in Entra ID: it can change any setting, create or delete accounts, and grant permissions to others. In the example, the targeted account is victimuser2.
Step 3: Inject the DLL into miiserver.exe
The malicious DLL is injected into the miiserver.exe process, placing the attacker's code inside the component that handles credential synchronisation.
Step 4: AADConnect initiates DCSync
AADConnect starts its normal DCSync operation to collect on-premises credentials.
Step 5: Overwrite the target's NT hash during encryption
AADConnect begins encrypting each NT hash 1,000 times. When DecryptNtOwfPwdWithIndex reaches the victimuser2 credential information, the injected code converts the MD4 hash of TacoTacoTaco123!! into the correct .NET format (e9-f8-c7-40-etc-etc) and assigns the result variable with the overwritten NT hash.
In plain words: the attacker picks a password they know, here TacoTacoTaco123!!. They compute its MD4 hash, which is the same kind of value Active Directory stores. They then arrange for the function that processes each user's credentials to hand back that value instead of the real one, by writing it into the variable the function uses to return its answer. The .NET format is simply how Microsoft's programming framework represents a hash internally; the value is the same bytes, written in the notation the code expects.

Step 6: The overwritten hash is encrypted and shipped
AADConnect encrypts the overwritten hash 1,000 times and continues its operations, then ships the encrypted hashes to Entra ID.
Step 7: Entra ID processes the hashes
Entra ID receives the NT hashes and processes them, considering the overwritten hash the hash of record for the user's Azure account. From this moment, the cloud believes the user's password is the one the attacker chose.
Step 8: Pivot to Entra ID
The attacker pivots from on-premises to Entra ID, taking the Global Administrator account with it. They collect Access Tokens, Refresh Tokens and Primary Refresh Tokens, and set up backdoor accounts, all before restarting the miiserver.exe service and without triggering any alerts.
A token here is a small piece of data that a service issues after a successful sign-in, and that the client presents on later requests instead of the password. An Access Token is short-lived and grants access to a specific resource. A Refresh Token is longer-lived and lets the client obtain new Access Tokens without signing in again. A Primary Refresh Token is the equivalent used by Windows devices to keep a user signed in across Microsoft cloud services. Collecting them lets the attacker keep access while miiserver.exe is not restarted.
A backdoor account is an account the attacker creates or takes over so they can return later, ideally one that looks ordinary and is unlikely to be noticed.
The on-premises account's NT hash is now out of sync with the Entra ID NT hash. As long as the miiserver.exe process is not restarted, the attacker can log into the user's Azure account indefinitely.
The attack path as a numbered list
- Attacker gains access to the AADConnect Server as Local Administrator.
- Attacker builds malicious DLL that targets a Global Administrator.
- Attacker injects malicious DLL into the miiserver.exe process.
- AADConnect initiates DCSync to collect on-premises credentials.
- AADConnect begins the process of encrypting each NT hash 1,000 times. When the AADConnect function reaches the targeted Global Administrator account, the DLL code overwrites the Global Admins NT Hash with a value the attacker controls.
- AADConnect proceeds to encrypt the overwritten hash and continues operations.
- AADConnect ships the encrypted hashes to Entra ID.
- Entra ID receives the NT hashes and processes them.
- Attacker pivots from on-premises to Entra ID, taking the Global Administrator account with it.
- Attacker collects Access Tokens, Refresh Tokens, and Primary Refresh Tokens, sets up backdoor accounts, etc… all before restarting the miiserver.exe service without triggering any alerts.
Why it works
The DecryptNtOwfPwdWithIndex method iterates through the DCSync results and encrypts each NT hash before packaging it for Entra ID, . Code running in the same process can therefore substitute the value assigned to the result variable, and the encrypted dataset that Entra ID receives carries the attacker's hash as the hash of record.
The report notes that the earlier DCSync hijack allowed DCSync operations without triggering traditional alerts.
A Tier 0 device is Microsoft's term for the most sensitive machines in an environment, the ones whose compromise would let an attacker control everything else. Microsoft's documentation states that these devices must have the highest security because they can be severely abused or exploited.
What the attacker gets
An attacker with Local Administrator access on an AADConnect server can overwrite a user's NT hash, including a Global Administrator, with a value they control. They can then authenticate to Entra ID as that user, pivot from on-premises to the cloud, collect Access Tokens, Refresh Tokens and Primary Refresh Tokens, and set up backdoor accounts. The access persists as long as miiserver.exe is not restarted, and the activity does not trigger traditional alerts.
How to undo it
If an adversary has performed this attack, the compromised user's credential can be reset to its original value by restarting the miiserver.exe process and then performing a full sync between on-premises and Entra ID. This resets the password in Azure's records to the value stored on-premises.
In plain words: restarting the process and performing a full sync resets the password in Azure's records to the value stored on-premises.
Microsoft's position is that the attack requires Local Admin privileges on an AADConnect server, which are considered Tier 0 devices.
Things worth testing next
Glossary
- Access Token: a short-lived piece of data issued after sign-in that a client presents to a service to prove who it is, instead of sending the password again.
- Active Directory: Microsoft's directory service that stores users, computers and groups on an organisation's own servers.
- AADConnect / Entra ID Connect: Microsoft's tool that copies user accounts and password information from an on-premises Active Directory to Entra ID.
- Backdoor account: an account an attacker creates or takes over so they can return later without being noticed.
- Class: in programming, a named grouping of related code and data inside a library.
- DCSync: an Active Directory feature that lets one domain controller request a copy of user credential data from another; also used by Entra ID Connect to collect hashes.
- DLL (dynamic link library): a file containing code that a Windows program can load and run.
- Domain controller: a server that holds and manages an Active Directory domain.
- Entra ID (formerly Azure Active Directory): Microsoft's cloud identity service, used for signing in to Microsoft and third-party cloud apps.
- Exfiltration: copying data out of an environment without authorisation.
- Global Administrator: the highest level of administrative account in Entra ID, able to change any setting and grant permissions to others.
- Hash: the output of a mathematical function applied to data, always the same for the same input and hard to reverse; used to store passwords without keeping them in plain text.
- Hash of record: the value a service treats as the authoritative password hash for an account.
- Local Administrator: an account with full control over a single machine.
- MD4: the hashing algorithm used to produce NT hashes.
- Method: in programming, a specific function inside a class.
- miiserver.exe: the Entra ID Connect process that handles credential synchronisation.
- NT hash: the password hash format used by Windows Active Directory, produced with MD4.
- On-premises: running on the organisation's own servers rather than in a cloud service.
- Pivot: moving from one compromised system or environment to another to reach further.
- Primary Refresh Token: a longer-lived token used by Windows devices to keep a user signed in across Microsoft cloud services.
- Process injection: making a running program load and execute code of the attacker's choosing.
- Refresh Token: a longer-lived token that lets a client obtain new Access Tokens without signing in again.
- Tier 0 device: Microsoft's term for the most sensitive machines in an environment, whose compromise would let an attacker control everything else.
- Token: a piece of data issued after sign-in that a client presents on later requests instead of the password.
- Variable: in programming, a named slot in memory that holds a value while a program runs.