Domain Controllers, Replication and FSMO Roles
A domain controller is three things at once: the database of every account (NTDS.dit), the authentication service (the Kerberos KDC and NTLM pass-through), and a replication partner that accepts changes from every other DC. That last property is easy to forget and central to AD security. A change written on any DC (a password, a group membership, an ACL) reaches all the others within seconds to minutes, and every DC believes the others without question. So every DC is Tier 0, a backup of a DC is Tier 0, and anything that can pretend to be a DC, or ask for replication data like one, is Tier 0 too.
Multi-master replication
AD has no single primary: every writable DC accepts changes. To merge them it keeps, per attribute of every object, metadata:
| Field | Meaning |
|---|---|
| USN (update sequence number) | a counter local to each DC, increased for every change it writes; partners remember the highest USN they have seen from each DC (the high-watermark and the up-to-dateness vector) and ask only for newer changes |
| version | per attribute, increased by one on every originating change |
| originating time and originating DC (its invocation ID) | when and where the change was first written |
When two DCs change the same attribute before they replicate, every DC resolves the conflict the same way: higher version wins; if equal, later originating time wins; if equal, the higher originating DC GUID wins. The program applies that rule to a conflict in the lab.
from dataclasses import dataclass
@dataclass(frozen=True)
class Stamp:
version: int
time: str # originating time, ISO format compares correctly as text
dc_guid: str # originating DC invocation ID (made up)
def winner(a, b):
ka = (a[1].version, a[1].time, a[1].dc_guid)
kb = (b[1].version, b[1].time, b[1].dc_guid)
return a if ka > kb else b
DC01, DC02 = "4f1d...a1", "9c2e...07"
base = ("Sales-Team", Stamp(3, "2026-01-15T09:00:00", DC01))
# both admins edit 'description' of the same group before replication
on_dc01 = ("Sales (EMEA)", Stamp(4, "2026-01-15T10:00:05", DC01))
on_dc02 = ("Sales EMEA team", Stamp(4, "2026-01-15T10:00:09", DC02))
print("conflict, equal versions:", winner(on_dc01, on_dc02))
# a DC01 admin edits twice before replication: version 5 beats DC02's later edit
on_dc01_again = ("Sales EMEA", Stamp(5, "2026-01-15T10:00:07", DC01))
print("higher version wins: ", winner(on_dc01_again, on_dc02))
# whoever can write replication metadata decides the outcome
rogue = ("Domain Admins member: mallory", Stamp(999, "2026-01-15T10:00:01", "fake-dc"))
print("forged high version: ", winner(rogue, on_dc02)[0])conflict, equal versions: ('Sales EMEA team', Stamp(version=4, time='2026-01-15T10:00:09', dc_guid='9c2e...07'))
higher version wins: ('Sales EMEA', Stamp(version=5, time='2026-01-15T10:00:07', dc_guid='4f1d...a1'))
forged high version: Domain Admins member: mallory
The last line is the reason a fake DC is dangerous. Replication trusts the metadata a partner sends; a machine registered as a DC can push a change with any version, and it "wins" everywhere without passing through the normal LDAP write path, so it doesn't produce the usual 5136 directory-change event on a real DC. This technique is known as DCShadow (shown in 2018 by researchers and implemented in Mimikatz). Its counterpart, asking a DC for replication data instead of pushing it, is DCSync, the topic of DCSync and Replication Rights.
FSMO roles
Some operations can't be multi-master. Five flexible single master operation roles are each held by one DC:
| Role | Scope | Does | Security note |
|---|---|---|---|
| Schema master | forest | the only DC that writes schema changes | schema changes are permanent; Schema Admins should be empty except during a change |
| Domain naming master | forest | adds and removes domains | rarely used |
| RID master | domain | hands each DC blocks of RIDs (500 at a time) for new SIDs | RID pool exhaustion or a sudden rise in RID issuance is a signal of mass object creation |
| PDC emulator | domain | time source of the domain, urgent password replication, account lockout processing, default GPO editing target | the clock of Kerberos; lockout counts are checked here, so password-spraying detection often looks at the PDC |
| Infrastructure master | domain | updates references to objects in other domains | irrelevant when every DC is a global catalog |
netdom query fsmo lists the holders. Losing a FSMO holder isn't a security event, but seizing a role is a strong change that should appear only in a recovery.
Read-only domain controllers
An RODC holds a read-only copy and, by default, no passwords. Its Password Replication Policy lists who may have their secrets cached on it (the "Allowed RODC Password Replication Group" and explicit additions), and every RODC has its own krbtgt_NNNNN account: writable DCs recognise tickets made with that key and honour them only for accounts the RODC was allowed to cache, so a stolen RODC can't forge tickets for admins. Branch offices with weak physical security should get RODCs, and the "allowed" list should contain only local users, never admins.
Ports and protocols of a DC
| Port | Service |
|---|---|
| 53 | DNS |
| 88, 464 | Kerberos, Kerberos password change |
| 135 + dynamic RPC | RPC endpoint mapper, replication (DRSUAPI), Netlogon, SAMR |
| 389 / 636, 3268 / 3269 | LDAP / LDAPS, global catalog |
| 445 | SMB: SYSVOL, NETLOGON, named pipes |
| 9389 | AD Web Services (the AD PowerShell module) |
Workstations need to reach DCs on most of these; DCs need to replicate only with other DCs over DRSUAPI, which is what makes the detections below possible.
How misuse is detected
- Replication from a non-DC address. Network sensors (Zeek's DCE/RPC analyser, Microsoft Defender for Identity) see DRSUAPI
DRSGetNCChanges(pull) orDRSReplicaAddrequests; from an IP that isn't a DC it is DCSync or a rogue DC. - A new DC appearing. DCShadow briefly registers an
nTDSDSAobject underCN=Sites,CN=Configurationand adds DC-style SPNs (theGC/…and replication SPNE3514235-4B06-11D1-AB04-00C04FC2DCD2/…) to a normal computer. With directory auditing, 5137 (object created) under Sites and 4742 (computer account changed) with new SPNs on a non-DC are alerts. - Replication health and metadata.
repadmin /showobjmetashows each attribute's version, time and originating DC; an originating DC that isn't in your DC list is evidence of a rogue push. Directory Service events about lingering objects or USN rollback (2095) after a restore point to recovery mistakes. - FSMO changes outside a planned window.
How it is hardened
- Treat DCs, their hypervisors, their backups and their management agents as Tier 0; no other software on DCs.
- Restrict who can add computers or modify the Configuration partition; keep Enterprise Admins empty in daily use.
- Firewall DC-to-DC replication: DRSUAPI only between DC addresses where your network design allows it.
- Deploy RODCs where physical security is weak, with minimal password replication policies.
- Use a sensor that understands AD protocols (Defender for Identity or open-source Zeek scripts) on DC traffic.
Pitfalls
- Restoring a DC from a VM snapshot without the VM-GenerationID support of the hypervisor causes USN rollback: the DC reuses USNs, partners ignore its changes, and the directory silently diverges.
- Believing a change "took effect" when written on one DC. Others may still serve the old value for minutes; detections and incident steps must account for replication delay.
- Forgetting RODC
krbtgt_NNNNNaccounts in krbtgt rotation plans and inventories.
Practice
1. Two admins change the same group's description on different DCs. Both changes have version 4; one at 10:00:05, one at 10:00:09. Which wins?
The one at 10:00:09: equal versions, later originating time wins. The program prints Sales EMEA team.
2. Why doesn't a DCShadow change produce the usual 5136 on the real DCs?
It arrives as inbound replication, not as an LDAP write. 5136 is generated by the DC that performs the originating write; here the originating "DC" is the rogue one, whose logs the attacker controls.
3. Which FSMO holder should a password-spraying detection look at first, and why?
The PDC emulator: failed authentications with a wrong password are forwarded to it for a second check, so it sees the domain-wide failure pattern and processes lockouts.
Test yourself
How does AD resolve two conflicting changes to the same attribute?
- The first one to arrive wins
- Higher version, then later originating time, then higher originating DC GUID
- The PDC emulator decides
- The change is discarded
Which FSMO role is the domain's time source and processes account lockouts?
- Schema master
- RID master
- PDC emulator
- Infrastructure master
What is a strong sign of DCSync or a rogue DC on the network?
- LDAP queries from workstations
- DRSUAPI replication requests from an address that is not a domain controller
- Kerberos traffic on port 88
- DNS queries for _ldap SRV records
Why does each RODC have its own krbtgt_NNNNN account?
- To speed up logons
- So that tickets made with a stolen RODC's key are honoured only for accounts the RODC was allowed to cache
- Because RODCs can't use Kerberos
- To store DNS records