GPO Abuse
Group Policy runs with SYSTEM rights on every computer it applies to and with the user's rights in every session. That is what makes it the best administration tool in AD, and it is why edit rights on a GPO are equivalent to admin rights on every machine the GPO reaches. An attacker who can edit a GPO linked to the Workstations OU can add an "immediate" scheduled task, a startup script or a new local administrator, and within the next refresh cycle (90 minutes plus a random offset of up to 30) it happens on every workstation; linked to the Domain Controllers OU, it happens on every DC. Edit rights end up in surprising places: a former admin who created the GPO and still owns it, a help-desk group granted "Edit settings" for one change years ago, a delegation on the OU that allows linking any GPO. This lesson finds those rights with a graph, then covers detection and the fix.
How GPOs are processed (LSDOU, enforcement, security filtering) is in Group Policy Processing and Security Filtering.
Three ways to control what a GPO does
| Right | Where | Effect |
|---|---|---|
edit the GPO (GenericWrite/GenericAll/WriteDacl on the groupPolicyContainer, plus write access to its SYSVOL folder) |
the GPO object and folder | change the settings of a GPO that is already linked |
link GPOs (write gPLink) |
an OU, the domain, a site | link an existing (or your own) GPO to new targets |
| create GPOs (Group Policy Creator Owners) | the domain | new GPOs; harmless alone, dangerous with link rights |
The creator of a GPO becomes its owner, and owners can always rewrite the DACL. GPOs created by people who have since moved teams are a common source of unexpected edit rights.
Who can run code where
The program builds a graph from a synthetic export: group memberships, rights on GPOs and OUs, GPO links, and which computers sit in which OU. An edge means "can make code run on". Then it asks, for every principal, which computers it can reach through Group Policy, and in particular whether it reaches the domain controllers.
import networkx as nx
g = nx.DiGraph()
def edge(a, b, kind): g.add_edge(a, b, kind=kind)
# memberships
for m, grp in [("helpdesk01", "IT-Helpdesk"), ("carol", "Desktop-Engineering"), ("pkiadmin", "Tier0-Admins")]:
edge(m, grp, "MemberOf")
# rights on GPOs and OUs (from the ACL export)
edge("Tier0-Admins", "GPO:DC-Baseline", "EditSettings")
edge("Desktop-Engineering", "GPO:Workstation-Baseline", "EditSettings")
edge("carol", "GPO:Printer-Mapping", "Owner") # carol created it in 2019
edge("IT-Helpdesk", "OU:Domain Controllers", "WritegPLink") # granted 'temporarily' for a migration
# links and containment
edge("GPO:DC-Baseline", "OU:Domain Controllers", "LinkedTo")
edge("GPO:Workstation-Baseline", "OU:Workstations", "LinkedTo")
edge("GPO:Printer-Mapping", "OU:Workstations", "LinkedTo")
for c in ["WS01", "WS02"]:
edge("OU:Workstations", c, "Contains")
for c in ["DC01", "DC02"]:
edge("OU:Domain Controllers", c, "Contains")
def reach(p):
return sorted(n for n in nx.descendants(g, p) if not n.startswith(("GPO:", "OU:")) and n not in
("IT-Helpdesk", "Desktop-Engineering", "Tier0-Admins"))
for p in ["pkiadmin", "carol", "helpdesk01"]:
r = reach(p)
flag = " <- reaches domain controllers" if {"DC01", "DC02"} & set(r) else ""
print(f"{p:11} can run code on {', '.join(r) or 'nothing'}{flag}")
# the helpdesk can link: any GPO it can edit, or create, becomes code on the DCs
path = nx.shortest_path(g, "helpdesk01", "DC01")
print("helpdesk01 path:", " -> ".join(f"{a} [{g.edges[a, b]['kind']}]" for a, b in zip(path, path[1:])), "-> DC01")pkiadmin can run code on DC01, DC02 <- reaches domain controllers
carol can run code on WS01, WS02
helpdesk01 can run code on DC01, DC02 <- reaches domain controllers
helpdesk01 path: helpdesk01 [MemberOf] -> IT-Helpdesk [WritegPLink] -> OU:Domain Controllers [Contains] -> DC01
pkiadmin reaches the DCs by design: it is in Tier0-Admins, which edits the DC baseline. Carol is expected to manage workstations; her ownership of an old GPO only adds the same reach. The help desk is the finding: WritegPLink on the Domain Controllers OU means any GPO it controls, including one it creates itself if it is in Group Policy Creator Owners, can be linked there and run on every DC. In this graph the help desk has no GPO of its own yet, so the model reaches the DCs only through the OU node; in a real review treat the link right alone as Tier 0 control.
What abuse looks like
Public tools (SharpGPOAbuse, pyGPOAbuse; BloodHound draws the GenericWrite/WriteGPLink edges) automate the same few changes: add an immediate scheduled task under Preferences, add a startup script, add a user to local Administrators through Restricted Groups, or change a security setting. Every one of them leaves traces in the directory, in SYSVOL and on the endpoints.
How it is detected
- Directory: 5136 on the
groupPolicyContainerwhenversionNumberorgPCMachineExtensionNames/gPCUserExtensionNameschange (a new client-side extension such as Scheduled Tasks appearing is particularly telling); 5136 ongPLinkof an OU or the domain, above all the Domain Controllers OU; 5137 for new GPOs. - SYSVOL: 5145 (detailed file share) for writes under
\SYSVOL\<domain>\Policies\{GUID}\…, for example a newScheduledTasks.xmlorscripts.ini; file-integrity monitoring of SYSVOL on one DC. - Endpoints: 4698 (a scheduled task was created) and the Task Scheduler operational log (106) on many machines within one refresh cycle, with the task created by
gpsvccontext; 4688 for the task's command; 4732 additions to local Administrators across many hosts at once. - Baselines: export all GPOs regularly (
Backup-GPO -AllorGet-GPOReport -All -ReportType Xml) and diff them; a change without a change ticket is an alert.
How it is fixed or prevented
- Edit rights on Tier 0 GPOs (linked to the Domain Controllers OU or the domain root, and any GPO applying to Tier 0 servers) only for a Tier 0 group, used from PAWs.
- Remove link rights (
gPLinkwrites) on the Domain Controllers OU, Tier 0 OUs and the domain root from everyone but Tier 0; review delegations on OUs (dsaclsor the ACL audit of Auditing ACLs). - Fix ownership: set the owner of GPOs to a group (Domain Admins or a GPO-admin group) rather than individuals.
- Keep Group Policy Creator Owners empty or small.
- Use a change workflow (GPO backups in version control, a review step, or a third-party GPO change-management tool; Microsoft's own AGPM left support with MDOP in April 2026) if your organisation edits GPOs often, so every change is reviewed and versioned.
- Run the reach analysis above after every reorganisation.
Pitfalls
- Reviewing GPO permissions but not OU link permissions. Linking is half of the attack.
- Assuming filtered GPOs are harmless: whoever can edit the GPO can also change its security filter.
- Forgetting SYSVOL permissions: a GPO object with tight ACLs but a SYSVOL folder writable by a broad group is still editable.
- Deleting a malicious GPO without collecting it first: export it for the investigation, then remove it, then check endpoints, because settings applied by Preferences stay after the GPO is gone.
Practice
1. Remove the help desk's WritegPLink edge in the model. What does it reach now, and is that acceptable?
Nothing: the help desk has no edit right on any GPO. That is acceptable if its job doesn't need Group Policy; if it manages printers, give it edit rights on a printer GPO linked only to the Workstations OU.
2. Overnight, 900 workstations log 4698 for a task named Updater, all within 40 minutes. Where do you look first?
At GPO changes before that window: 5136 on groupPolicyContainer objects with a changed versionNumber, and a new ScheduledTasks.xml in SYSVOL (5145). The GPO, its editor and the time tell you who changed it; the task's command tells you what ran.
3. Why is ownership of a GPO by an individual account a finding even if that person is still an admin?
Owners can always change the DACL, outside any group-based review, and personal accounts are used on more machines (and phished more often) than a dedicated group. Ownership by a group keeps control reviewable.
Test yourself
Why are edit rights on a GPO powerful?
- They allow reading SYSVOL
- Its settings run as SYSTEM on every computer it applies to
- They change DNS
- They reset passwords
Which right lets someone attach an existing GPO to an OU?
- Write on gPLink of the OU
- Read on the GPO
- Apply group policy
- ReadProperty on the domain
Which event on endpoints often reveals GPO abuse with an immediate scheduled task?
- 4625
- 4698
- 4769
- 1644
What does a change of gPCMachineExtensionNames on a GPO indicate?
- Nothing
- A new client-side extension (such as Scheduled Tasks or Scripts) is now used by the GPO
- The GPO was deleted
- The GPO was renamed