Mini Project: An AD Security Review
This project is the course in one assessment, the kind an internal security team or an authorised consultant delivers: take a domain, find the paths to Tier 0, read the logs for signs that someone already walked them, check the configuration that the paths and detections depend on, and turn everything into a prioritised hardening plan that someone else can execute. The domain is synthetic, described below and embedded in the code: nothing here touches a real directory. Work through the steps, run and extend the code, then write the report with the template at the end.
The engagement
| Item | Value |
|---|---|
| Client | the lab organisation, domain corp.lab.test (forest root, single domain), 10.10.0.0/24 |
| Authorization | written, signed by the IT director; read-only review: directory export, configuration exports, 7 days of Security logs from DC01 and DC02 |
| Out of scope | password guessing, ticket requests for roasting, relay or coercion tests, any change to the directory |
| Data | synthetic exports handed over by the client (below); kept encrypted, deleted 30 days after the report |
| Context | the company merged with a smaller firm a year ago; its domain was migrated with SID history; two admins left in the spring |
Even a read-only review needs this table: it decides what you may conclude ("we observed", not "we exploited") and what the client must not be surprised by.
Step 1: the attack-path graph
The client's export, reduced to control edges (memberships, admin rights, sessions seen during the week, ACL rights, delegation, certificate templates). The program finds every user with a path to Domain Admins, the length of the shortest path, and the cheapest cut.
import networkx as nx
E = [
*[(u, "Domain Users", "MemberOf") for u in ["ana", "ben", "chi", "dan", "eve", "fay", "gus", "hal", "ivo"]],
("ben", "Helpdesk", "MemberOf"), ("chi", "Helpdesk", "MemberOf"),
("Helpdesk", "Workstations", "AdminTo"),
("Workstations", "adm-ola", "HasSession"), # a domain admin fixed a laptop last Tuesday
("adm-ola", "Domain Admins", "MemberOf"),
("dan", "Merger-IT", "MemberOf"),
("Merger-IT", "Server-Admins", "GenericAll"), # migrated ACE from the old domain
("Server-Admins", "SQL01", "AdminTo"),
("SQL01", "svc-sql", "HasSession"),
("svc-sql", "Domain Admins", "MemberOf"), # 'temporary' since the migration
("Domain Users", "Template:WebServer-Old", "Enroll"),
("Template:WebServer-Old", "Domain Admins", "ESC1"), # enrollee-supplied subject + client auth
("eve", "PRINT01", "AdminTo"),
("PRINT01", "DC01", "UnconstrainedDelegation+Coercion"),
("DC01", "Domain Admins", "Controls"),
]
STRUCTURAL = {"Controls"}
g = nx.DiGraph()
for a, b, k in E:
g.add_edge(a, b, kind=k, capacity=10**6 if k in STRUCTURAL else (2 if k == "MemberOf" else 1))
users = ["ana", "ben", "chi", "dan", "eve", "fay", "gus", "hal", "ivo"]
exposed = {u: nx.shortest_path(g, u, "Domain Admins") for u in users if nx.has_path(g, u, "Domain Admins")}
print(f"{len(exposed)} of {len(users)} users reach Domain Admins; shortest path lengths:",
{u: len(p) - 1 for u, p in exposed.items()})
h = g.copy()
for u in users:
h.add_edge("SRC", u, capacity=10**6)
cost, (reach, _) = nx.minimum_cut(h, "SRC", "Domain Admins")
cut = sorted((a, b) for a in reach for b in h.successors(a) if b not in reach)
print(f"cheapest cut (cost {cost}):")
for a, b in cut:
print(f" {a} -{g.edges[a, b]['kind']}-> {b}")
g2 = g.copy(); g2.remove_edges_from(cut)
print("after the cut:", sum(nx.has_path(g2, u, "Domain Admins") for u in users), "users reach Domain Admins")9 of 9 users reach Domain Admins; shortest path lengths: {'ana': 3, 'ben': 3, 'chi': 3, 'dan': 3, 'eve': 3, 'fay': 3, 'gus': 3, 'hal': 3, 'ivo': 3}
cheapest cut (cost 4):
PRINT01 -UnconstrainedDelegation+Coercion-> DC01
SQL01 -HasSession-> svc-sql
Template:WebServer-Old -ESC1-> Domain Admins
Workstations -HasSession-> adm-ola
after the cut: 0 users reach Domain Admins
Every user is three hops from Domain Admins, through the old web-server template that Domain Users may enroll in. The cut has four edges, and each becomes a top finding with its lesson: the ESC1 template (AD CS), the domain admin's session on workstations (tiering), the merger path through svc-sql's session on SQL01 (the durable fix is taking svc-sql out of Domain Admins and making it a gMSA: attack paths, LAPS and gMSA) and PRINT01's unconstrained delegation (delegation). Edges not in the cut (the merger GenericAll, the help desk's admin rights) still become findings, with lower priority.
Step 2: what the logs say
Seven days of DC events, normalised as in the detection pipeline. The question for a review is not only "is there an attack?" but "would the client have seen one?": check volumes per event ID too.
import pandas as pd
ev = pd.DataFrame([
("2026-11-09 10:02", 4769, "fay", "10.10.0.31", "svc-sql", "0x17"),
("2026-11-09 10:02", 4769, "fay", "10.10.0.31", "svc-backup", "0x17"),
("2026-11-09 10:03", 4769, "fay", "10.10.0.31", "svc-report", "0x17"),
("2026-11-09 10:03", 4769, "fay", "10.10.0.31", "svc-crm", "0x17"),
("2026-11-10 14:00", 4624, "adm-ola", "10.10.0.44", "WS14", "type=2"),
("2026-11-11 03:12", 4768, "svc-oldftp", "10.10.0.77", "krbtgt", "preauth=0"),
("2026-11-12 09:00", 4765, "dan", "10.10.0.35", "dan", "sid=...-512"),
("2026-11-13 08:30", 4728, "ben", "10.10.0.32", "Server-Admins", "member=chi"),
], columns=["time", "id", "actor", "ip", "target", "detail"])
volume = {4624: 182_340, 4768: 9_120, 4769: 4, 4662: 0, 5136: 0, 4765: 1, 4728: 1}
findings = []
k = ev[ev.id == 4769].groupby(["actor", "ip"]).target.nunique()
findings += [f"Kerberoasting pattern: {a} from {ip} requested {n} user SPNs (RC4)" for (a, ip), n in k.items() if n >= 4]
findings += [f"Tier 0 account {r.actor} interactive logon on workstation {r.target}" for r in ev[(ev.id == 4624) & ev.actor.str.startswith("adm-")].itertuples()]
findings += [f"AS-REP for {r.actor} without pre-authentication from {r.ip} at {r.time[11:]}" for r in ev[(ev.id == 4768) & (ev.detail == "preauth=0")].itertuples()]
findings += [f"SID history added to {r.target} (Domain Admins SID)" for r in ev[ev.id == 4765].itertuples()]
findings += [f"{r.actor} added {r.detail[7:]} to {r.target}" for r in ev[ev.id == 4728].itertuples()]
for f in findings:
print("FINDING", f)
for eid, n in volume.items():
if n == 0:
print(f"GAP no {eid} events in 7 days: auditing or SACL missing")
elif eid == 4769 and n < 100:
print(f"GAP only {n} events of {eid} in 7 days for a domain with ~9,000 TGTs: Kerberos Service Ticket Operations auditing is likely off on most DCs")FINDING Kerberoasting pattern: fay from 10.10.0.31 requested 4 user SPNs (RC4)
FINDING Tier 0 account adm-ola interactive logon on workstation WS14
FINDING AS-REP for svc-oldftp without pre-authentication from 10.10.0.77 at 03:12
FINDING SID history added to dan (Domain Admins SID)
FINDING ben added chi to Server-Admins
GAP only 4 events of 4769 in 7 days for a domain with ~9,000 TGTs: Kerberos Service Ticket Operations auditing is likely off on most DCs
GAP no 4662 events in 7 days: auditing or SACL missing
GAP no 5136 events in 7 days: auditing or SACL missing
Two kinds of output, both for the report. The findings may be an intrusion in progress: the SID-history addition to dan's own account, a year after the migration ended, is an incident by itself and must be escalated to the client now, not in the report (agree this escalation path in the rules of engagement). The gaps explain why the client didn't notice: with no 4662 and 5136 and almost no 4769, DCSync, ACL abuse and most Kerberoasting would be invisible (audit policy).
Step 3: configuration checks
From the client's exports (summarised): SMB signing required on DCs only; LDAP signing not required; LLMNR on; no Windows LAPS on 60% of workstations; 14 user accounts with SPNs, oldest password from 2017; ms-DS-MachineAccountQuota 10; krbtgt password 4 years old; Print Spooler running on both DCs; Protected Users empty; AD Recycle Bin off; last tested restore: never. Map each to its lesson (registry settings, relay, LAPS and gMSA, Protected Users, backup and recovery).
Step 4: prioritise
Score each finding by paths closed (does it remove a cut edge or a whole mechanism?), evidence of use (seen in logs?) and effort. A workable ordering for this domain:
| Priority | Action | Why first |
|---|---|---|
| now | escalate the SID-history event; investigate dan, fay and the svc-oldftp AS-REP source |
possible active intrusion |
| days | fix the cut: disable or fix WebServer-Old; stop Tier 0 logons on workstations (deny-logon GPO); remove svc-sql from Domain Admins; remove unconstrained delegation from PRINT01 |
closes every path found |
| days | enable the missing audit subcategories and SACLs; forward all DC logs | makes the rest detectable |
| weeks | gMSAs for SPN accounts (oldest first); pre-authentication on; LDAP signing and channel binding; SMB signing everywhere; LLMNR/NBT-NS off; Spooler off on DCs; machine account quota 0 | removes whole attack classes |
| weeks | Windows LAPS everywhere; Protected Users for admins; krbtgt double reset |
reduces the value of any stolen credential |
| months | tiering programme with PAWs; NTLM audit and restriction; AD Recycle Bin and a tested forest recovery | structural |
Step 5: the report
Copy this structure and fill it in from your work above.
ACTIVE DIRECTORY SECURITY REVIEW - corp.lab.test
Version 1.0, <date>. Classification: confidential, client and reviewers only.
1. Executive summary (half a page, for management)
- What was reviewed, when, under which authorization; read-only, no exploitation.
- The picture in three sentences: how many users can reach Domain Admins today, whether
an attack would be detected, the one urgent event.
- The three most important actions and their owners.
2. Scope and method
- Data received (exports, log period, DCs covered), tools and versions, limitations
("sessions were observed for 7 days only"; "templates reviewed from export, CA not inspected").
3. Attack paths
- Users with a path to Tier 0, shortest paths (figure), the cut and what it closes.
- Remaining edges, grouped (sessions, ACLs, delegation, AD CS, groups).
4. Findings (one block each, ordered by priority)
ID / title / rating / affected objects
Description: what is wrong, in plain words.
Evidence: export line or event (sanitised: no hashes, no passwords).
Impact: what an attacker could do; which path it belongs to.
Detection: the events and rule that reveal its use; current visibility (gap or ok).
Recommendation: the fix, a quick mitigation if the fix takes time, owner, deadline.
References: course lesson, Microsoft guidance, CVE/KB if any.
5. Detection coverage
Audit policy gaps, event volumes per DC, rules proposed (spray, Kerberoasting, DCSync,
tier violations, honeytokens).
6. Hardening plan
Now / days / weeks / months, with owners and dependencies (e.g. NTLM audit before restriction).
7. Retest plan
For each finding the check that will show it fixed: rerun the graph and cut, rerun the
log rules on a new week, compare audit volumes.
Appendix: data inventory and handling, graph edges, event queries, glossary.Extensions
- Honeytokens: design three decoys for this domain (a honey SPN, a decoy admin, a honey GPP file) and the alert for each (Honeytokens).
- Retest: after "fixing" the cut edges in the graph, add the next most likely paths an attacker would try (for example an RBCD edge from the machine account quota) and recompute.
- Recovery readiness: write the client's forest-recovery checklist for
corp.lab.testwith the backup rules of Backing Up and Recovering AD.
Test yourself
In a read-only AD review, what may the report claim about a path to Domain Admins?
- That it was exploited
- That it exists in the exported configuration, observed but not exercised
- Nothing
- That the client was hacked
Why is a 4765 (SID history added) found during the review escalated immediately?
- It is a low-severity event
- Outside a migration it indicates likely active privilege escalation, which can't wait for the report
- Reports must contain no events
- Because it is a GPO change
What does 'zero 4662 and 5136 events in seven days' tell the reviewer?
- The domain is safe
- Directory access and change auditing (or the SACLs) are missing, so DCSync and ACL abuse would be invisible
- The DCs are offline
- Kerberos is disabled