TExcelTAD
Home › Windows & Active Directory Security › Forests, Domains, OUs and Trusts

Forests, Domains, OUs and Trusts

An organisation splits its directory into a separate domain for its European subsidiary "for security", and gives the subsidiary's IT team Domain Admins there but nothing in the parent domain. A year later an intruder who compromised the subsidiary's domain controller is Enterprise Admin of the whole organisation. Nobody misconfigured anything: inside one forest, a domain is not a security boundary. Knowing where the real boundaries are (the forest, and trusts with SID filtering) is the first architectural fact of AD security.

The containers

Container What it is Security meaning
Forest one or more domains sharing one schema, one configuration partition and one global catalog; the first domain is the forest root the security boundary: every domain controller in the forest is trusted by all the others, and the root holds Enterprise Admins and Schema Admins
Domain a partition of the directory replicated among its DCs, with its own accounts, policies and Domain Admins; named by DNS (corp.lab.test) an administrative and replication boundary, not a security boundary against its own admins
Organizational unit (OU) a container inside a domain for users, computers, groups and other OUs the unit of delegation (who may manage what) and of Group Policy linking
Site a set of well-connected IP subnets controls replication and which DC clients use; GPOs can be linked to sites too

Objects are named by distinguished names (DNs), read right to left: CN=svc-sql,OU=Service Accounts,OU=Tier1,DC=corp,DC=lab,DC=test is the object svc-sql in the OU Service Accounts inside Tier1 in the domain corp.lab.test. Anyone who can create objects or change permissions on an OU controls everything beneath it, which is why OU design is security design: an OU for Tier 0 accounts and servers, separate from the OUs where the help desk has delegated rights (Tiered Administration).

Why the forest, not the domain

Every domain in a forest trusts every other through automatic, two-way, transitive parent-child and tree-root trusts. Within a forest, a Kerberos ticket issued in one domain is accepted with whatever group SIDs it carries, including SIDs of other domains, because DCs trust each other completely. A Domain Admin of a child domain controls a DC of the forest, and with it the material to forge a ticket that carries the Enterprise Admins SID of the root (Golden and Silver Tickets). Microsoft's own guidance states it plainly: the forest is the security boundary.

Trusts between forests and domains

Trust Direction and transitivity Typical use
parent-child, tree-root two-way, transitive, automatic domains of one forest
forest trust one- or two-way, transitive between the two forests' domains two organisations that merged
external trust one- or two-way, non-transitive, to one domain a single partner domain or an old NT4-style domain
shortcut within a forest, to shorten authentication paths performance
realm to a non-Windows Kerberos realm MIT Kerberos interop

Direction is easy to get backwards. "Domain A trusts domain B" means A accepts B's authentications, so users of B can be granted access in A. Access flows against the direction of the trust.

Three settings make cross-forest trusts safe:

  • SID filtering (quarantine), on by default for forest and external trusts: the trusting side removes from incoming tickets any SID that doesn't belong to the trusted forest's domains. A forged Enterprise Admins SID from the other forest is dropped.
  • Selective authentication: users from the trusted forest can authenticate only to computers on which they have been granted "Allowed to authenticate". Without it, any user of the trusted forest can at least authenticate to every machine.
  • No TGT delegation across the trust (the default since 2019 updates): stops unconstrained delegation from leaking TGTs across forests (Delegation).

A trust model

The program models the lab with a child domain and two partners and answers two questions for every pair: may users of X be given access in Y (is there a trust path in which Y trusts X?), and could an admin of X become admin of Y by forging SIDs (is there such a path without SID filtering?).

python · try it yourself
import networkx as nx

forest_of = {"corp.lab.test": "corp", "eu.corp.lab.test": "corp",
             "partner.lab.test": "partner", "legacy.lab.test": "legacy"}
# (trusting, trusted, kind, transitive, sid_filtering)
trusts = [
    ("corp.lab.test", "eu.corp.lab.test", "parent-child", True, False),
    ("eu.corp.lab.test", "corp.lab.test", "parent-child", True, False),
    ("corp.lab.test", "partner.lab.test", "forest", True, True),        # one-way: corp trusts partner
    ("legacy.lab.test", "corp.lab.test", "external", False, False),     # SID filtering turned off!
]
g = nx.DiGraph()
g.add_nodes_from(forest_of)
for trusting, trusted, kind, transitive, filt in trusts:
    # an edge trusted -> trusting means "authentications from trusted are accepted by trusting"
    g.add_edge(trusted, trusting, kind=kind, transitive=transitive, filtering=filt)

def accepted_by(src):
    """Domains that accept src's users -> True if some hop on the way filters SIDs."""
    result = {}
    for nbr in g.successors(src):                 # direct trusts, transitive or not
        result[nbr] = g.edges[src, nbr]["filtering"]
    frontier = [n for n in result if g.edges[src, n]["transitive"]]
    while frontier:                               # extend only along transitive trusts
        node = frontier.pop()
        for nxt in g.successors(node):
            e = g.edges[node, nxt]
            if nxt != src and nxt not in result and e["transitive"]:
                result[nxt] = result[node] or e["filtering"]
                frontier.append(nxt)
    return result

for src in forest_of:
    for dst, filtered in sorted(accepted_by(src).items()):
        risk = "SIDs filtered" if filtered else "NO SID filtering: admin of source can forge admin SIDs here"
        print(f"users of {src:17} -> resources in {dst:17} {risk}")
users of corp.lab.test     -> resources in eu.corp.lab.test  NO SID filtering: admin of source can forge admin SIDs here
users of corp.lab.test     -> resources in legacy.lab.test   NO SID filtering: admin of source can forge admin SIDs here
users of eu.corp.lab.test  -> resources in corp.lab.test     NO SID filtering: admin of source can forge admin SIDs here
users of partner.lab.test  -> resources in corp.lab.test     SIDs filtered
users of partner.lab.test  -> resources in eu.corp.lab.test  SIDs filtered

The two parent-child lines are the "domain is not a boundary" fact in code. The forest trust lets partner.lab.test users be granted access in both domains of the corp forest (forest trusts are transitive into the other forest's domains), but with SIDs filtered. The corp.lab.test -> legacy.lab.test line is the dangerous one: someone disabled SID filtering on the external trust from legacy.lab.test (a common workaround during migrations, because sIDHistory only works across a trust without filtering), so whoever controls corp could forge their way into legacy.

How it is detected

  • Trust changes: 4706 (a new trust was created), 4707 (removed), 4716 (trusted domain information modified, which includes SID filtering and selective-authentication attributes) on DCs. Any of them outside a change ticket is an incident.
  • Cross-trust authentication: 4769 on the trusting side with a client from another forest; on DCs, Kerberos events showing inter-realm referral tickets. Baseline which accounts normally cross each trust.
  • SID history in use: 4765 when SID history is added, and tickets whose PAC carries extra SIDs of another domain (SIDs and tokens).
  • Inventory: Get-ADTrust -Filter * or nltest /domain_trusts regularly, compared with the documented list (direction, type, SIDFilteringQuarantined, SelectiveAuthentication).

How it is fixed or prevented

  • Design with the forest as the boundary: if a business unit must not be able to compromise the rest, it gets its own forest, not a domain.
  • Prefer one domain per forest when possible; extra domains add DCs (more Tier 0 assets) without adding isolation.
  • Keep SID filtering on for every forest and external trust; turn it off only for the duration of a migration, then clear sIDHistory and turn it back on.
  • Use selective authentication on trusts to partners; remove trusts nobody uses.
  • Treat DCs of every domain in the forest as Tier 0 of the whole forest.

Pitfalls

  • Reading trust direction backwards when granting access or assessing risk. Write it as "A trusts B: B's users may access A".
  • Forgotten external trusts to domains that were decommissioned on paper but still have a running DC.
  • Assuming a separate domain contains a breach of a subsidiary or a lab. Only a separate forest does.
  • Trust passwords: the trust account's shared key is stored in both domains and rotates automatically every 30 days; restoring a DC from an old backup can break a trust, a reason to test recovery (Backup and Recovery).

Practice

1. "partner.lab.test trusts corp.lab.test" (one-way). Whose users can be granted access where?

corp.lab.test users can be granted access to resources in partner.lab.test. Not the other way round.

2. Change the model so that SID filtering is on for the legacy trust. What changes in the output?

Set the last tuple's sid_filtering to True: the line for corp.lab.test -> legacy.lab.test reads "SIDs filtered". The eu line to legacy is not printed at all, because the external trust is non-transitive.

3. Why doesn't the model print a line from eu.corp.lab.test to legacy.lab.test?

The external trust is non-transitive: legacy.lab.test accepts authentications only from corp.lab.test itself, not from domains that corp.lab.test trusts.

Test yourself

What is the security boundary in Active Directory?

  1. The OU
  2. The domain
  3. The forest
  4. The site

Domain A trusts domain B. Which statement is true?

  1. A's users can access B
  2. B's users can be granted access to A's resources
  3. Neither
  4. Both, always

What does SID filtering on a forest trust do?

  1. Encrypts tickets
  2. Removes SIDs from incoming tickets that don't belong to the trusted forest, so forged admin SIDs are dropped
  3. Blocks all users
  4. Disables Kerberos

Which event ID records a change to a trusted domain's information, such as its SID filtering setting?

  1. 4706
  2. 4716
  3. 4624
  4. 5145