Skip to content

Scope GPOs by the computers they reach, not by link text - #18

Merged
alexlinos merged 1 commit into
mainfrom
scoping
Oct 2, 2026
Merged

alexlinos merged 1 commit into
mainfrom
scoping

Conversation

@alexlinos

Copy link
Copy Markdown
Owner

This is step 2 of round two. It removes the last class of false pass the consultant found, by working out which computers each GPO reaches.

What changes

  • Computers. The scan reads every enabled computer once and keeps a count per container. Domain controllers are found by account type: SERVER_TRUST_ACCOUNT for writable DCs, PARTIAL_SECRETS_ACCOUNT for RODCs. So a DC moved out of the Domain Controllers OU still counts, and OU=Domain Controllers,OU=Lab holds none.

  • Reach. A link reaches a computer when its target is the computer's container or an ancestor of it. Block Inheritance on any container in between stops the link unless it is enforced. OUs with Block Inheritance and no links of their own are now read, using (|(gPLink=*)(gPOptions=*)).

  • Coverage. Each finding now records evidence.coverage = {covered, total, unit}. When Group Policy sets a value on only some of the target machines, the rest get the control's unset meaning:

    • the Windows default, where the catalog documents one;
    • unknown, for direct-write or unknown-when-unset controls;
    • not started otherwise.

    So LmCompatibilityLevel=5 linked only to a lab OU is now fail, 3 of 15 computers. Before, it was pass/enforced.

  • Sites.

    • Site links are read from the forest root's Configuration partition (from rootDomainNamingContext), not CN=Configuration,<base_dn>.
    • If that read fails, it's noted instead of silently swallowed.
    • A site link to another domain's GPO is no longer credited to this domain's copy. The Default Domain and Default DC policies share GUIDs across domains.
    • A site link is assumed to reach every machine, marked with a ponytail: comment. Mapping computers to sites is a later step.
  • Fallback. When computers can't be read, evaluation uses links alone, as before, and the report says so under "Computers scoped".

  • Report.

    • Each card shows "Applies to: N of M computers / domain controllers", in red when short.
    • About this scan shows "Computers scoped" and any scoping notes.
    • The sample report uses a small made-up fleet.

Not in this PR

  • Security filtering (deny Apply ACEs; Read for Authenticated Users or Domain Computers).
  • WMI filters.
  • gPCMachineExtensionNames.
  • Link-order precedence within a container.
  • Resolving the "enforced at root wins" case. It still fails as least-compliant.

Versions and tests

Engine 1.6.0.

1,479 tests pass. New tests:

  • Evaluator:
    • a test-OU link, and a root link;
    • Block Inheritance, with and without an enforced link;
    • a nested "Domain Controllers" OU;
    • a moved DC;
    • an uncovered Windows default;
    • the fallback without data.
  • Scanner: a lab-only link reports its coverage; a block-only OU is read; a foreign site link isn't credited.

A GPO now counts for a control only where it reaches the machines the
control is about, worked out from where the domain's computers sit:

- The scan reads every enabled computer once. Domain controllers are
  found by account type (SERVER_TRUST_ACCOUNT or PARTIAL_SECRETS_ACCOUNT),
  so a DC moved out of the Domain Controllers OU is still a DC, and an OU
  that is merely named "Domain Controllers" holds none.
- A link reaches a computer when its target is the computer's container
  or an ancestor of it. Block Inheritance on any container in between
  stops it unless the link is enforced. OUs with Block Inheritance and no
  links of their own are now read (gPLink or gPOptions).
- Coverage is reported per finding ("covered", "total", "unit"). Where
  Group Policy sets a value on only some of the machines, the rest get
  the control's unset meaning: its Windows default, unknown, or not
  started. So a value linked only to a test OU no longer passes as
  domain-wide enforcement.
- Site links are read from the forest root's Configuration partition,
  and a failure is noted rather than swallowed. A site link to another
  domain's GPO is no longer credited to this domain's copy with the same
  GUID.
- When computers can't be read, evaluation falls back to links alone
  and the report says so under "Computers scoped".

The report shows "Applies to: N of M" on each card. The sample report
uses a small made-up fleet. Engine 1.6.0.
@alexlinos
alexlinos merged commit 09573cc into main Oct 2, 2026
3 checks passed
@alexlinos
alexlinos deleted the scoping branch October 2, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant