diff --git a/README.md b/README.md index 67d4e02d4..0cf7c394c 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ documents for different readers. at all. Every pinned digest is also scanned weekly for fixable HIGH and CRITICAL CVEs, and each image with findings has an open issue until a scan finds it clean. -- **Documented decisions and runbooks.** 135 ADRs covering what was chosen +- **Documented decisions and runbooks.** 137 ADRs covering what was chosen and what was rejected — including the costs accepted knowingly; 57 runbooks for the operations that are easy to get wrong at 1am, one of which is the handover page a successor reads first. Every critical alert links to @@ -236,7 +236,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology │ ├── architecture.md network.md hardware.md │ ├── observability.md security.md roadmap.md changelog.md │ ├── diagrams/ # the network diagram (SVG) and its predecessors -│ ├── adr/ # 135 ADRs — architecture decision records +│ ├── adr/ # 137 ADRs — architecture decision records │ ├── exercises/ # purple-team exercise records — see its README │ └── runbooks/ # 57 runbooks; successor-handover.md is the front door └── Makefile # make help diff --git a/ansible/README.md b/ansible/README.md index 97081f174..a71527226 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -82,7 +82,9 @@ covered in the runbook's [*Run it from `phoenix`*][run] section. group, and the members placed in `Servers`/`Workstations` (#448). - `gpos`: the GPOs, ensured on `bahamut` compare-first, so a second run writes nothing. - - *Deny Tier 0 Logon on Members*, as #414 built it by hand. + - *Deny Tier 0 Logon on Members*, as #414 built it by hand, and since + ADR-0136 refusing Domain and Enterprise Admins the console and RDP on + members too, never network logon. - *Lab - Audit File Share*: the member servers' audit policy, the Windows default set plus File Share (#1077). - *Lab - Audit Domain Controllers*: the DCs' 17 subcategories plus diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml index a67526709..5fb538303 100644 --- a/ansible/roles/base/tasks/main.yml +++ b/ansible/roles/base/tasks/main.yml @@ -127,6 +127,31 @@ ansible.windows.win_timezone: timezone: UTC +# C: takes the whole disk tofu gave the clone. The server template's disk is 60 +# GiB (packer/windows.pkr.hcl) and tofu grows titan and ramuh to 80, so those +# two start with 20 GiB unallocated after their last partition; the DCs and the +# endpoints get their template's size and have none. Templates built before +# this change have Setup's +# recovery partition AFTER C:, which pins C: where it is: on those clones +# SizeMax equals Size and this changes nothing (titan on 2026-11-25: C: 58.96 +# GB on an 80 GB disk, with the 0.77 GB recovery partition behind it). Templates +# built since put the recovery partition before C: (autounattend.xml.pkrtpl), +# so the next rebuild grows C: here. Moving a live recovery partition is not +# done: that is disk surgery on a running guest, for space nobody is short of. +- name: "Grow C: into the space behind it" + ansible.windows.win_powershell: + script: | + [CmdletBinding(SupportsShouldProcess)] + param() + $Ansible.Changed = $false + $p = Get-Partition -DriveLetter C + $max = (Get-PartitionSupportedSize -DriveLetter C).SizeMax + # 100 MB of slack, so alignment rounding never reads as a change. + if ($max - $p.Size -gt 100MB) { + $Ansible.Changed = $true + if (-not $Ansible.CheckMode) { Resize-Partition -DriveLetter C -Size $max } + } + # The template's build password stays valid until this runs (ADR-0074). A DC # has no local SAM to rotate; its Administrator is the domain's, and that one # was set from this same variable when the forest was made. diff --git a/ansible/roles/gpos/defaults/main.yml b/ansible/roles/gpos/defaults/main.yml index 0a894e722..f1f2dbbdd 100644 --- a/ansible/roles/gpos/defaults/main.yml +++ b/ansible/roles/gpos/defaults/main.yml @@ -7,6 +7,15 @@ # Deny Tier 0's privilege rights name the Tier 0 Admins group by SID. A rebuild # is a new forest with a new SID, so `__TIER0SID__` is a token the role fills # from the live group at apply time, never a SID baked into the repo. +# `__DASID__` and `__EASID__` are Domain Admins and Enterprise Admins, filled +# the same way from the domain SID (RIDs 512 and 519). +# +# ADR-0136: the domain's own admins are refused the console and RDP on members, +# as Tier 0 Admins always were, because AD\Administrator is in neither Tier 0 +# Admins nor anything else this GPO named, and the 2026-11 titan audit found it +# logged on interactively there. They keep NETWORK logon: phoenix's Ansible +# connects as AD\Administrator over SSH, and sshd's key logon is a network +# (S4U) logon (ADR-0077). The console on a member is the local Administrator's. # # `cse` is gPCMachineExtensionNames, the client-side-extension GUIDs that tell a # member which engines to run for this GPO; without it the file in SYSVOL is @@ -24,8 +33,9 @@ gpos_defs: signature="$CHICAGO$" Revision=1 [Privilege Rights] - SeDenyInteractiveLogonRight = *__TIER0SID__ + SeDenyInteractiveLogonRight = *__TIER0SID__,*__DASID__,*__EASID__ SeDenyNetworkLogonRight = *__TIER0SID__ + SeDenyRemoteInteractiveLogonRight = *__TIER0SID__,*__DASID__,*__EASID__ # #1077: the member servers' advanced audit policy. #414 built it with the # File Share line alone, and an advanced policy replaces the basic one # outright, so titan and ramuh audited file shares and NOTHING else: no diff --git a/ansible/roles/gpos/tasks/main.yml b/ansible/roles/gpos/tasks/main.yml index 82153e627..a813e80e5 100644 --- a/ansible/roles/gpos/tasks/main.yml +++ b/ansible/roles/gpos/tasks/main.yml @@ -28,7 +28,11 @@ $want = $g.content if ($g.name -eq 'Deny Tier 0 Logon on Members') { if (-not $tier0) { throw 'Tier 0 Admins group not found; run the tiers role first' } + # ADR-0136: Domain Admins (512) and Enterprise Admins (519), from + # the domain SID; a one-domain forest, so the root's is this one. + $domSid = (Get-ADDomain).DomainSID.Value $want = $want.Replace('__TIER0SID__', $tier0) + $want = $want.Replace('__DASID__', "$domSid-512").Replace('__EASID__', "$domSid-519") } $gpo = Get-GPO -Name $g.name -ErrorAction SilentlyContinue diff --git a/ansible/verify.yml b/ansible/verify.yml index 74138e066..b64f07ee2 100644 --- a/ansible/verify.yml +++ b/ansible/verify.yml @@ -228,6 +228,20 @@ -not ((Get-GPInheritance -Target "OU=$_,$($base)").GpoLinks | Where-Object DisplayName -eq $lk.g) }) } + # ADR-0136: Deny Tier 0 refuses Domain Admins the console and RDP on + # members, and leaves them network logon, which phoenix's SSH is. + $deny = Get-GPO -Name 'Deny Tier 0 Logon on Members' -ErrorAction SilentlyContinue + $inf = if ($deny) { Join-Path $env:SystemRoot ` + "SYSVOL\domain\Policies\{$($deny.Id)}\Machine\Microsoft\Windows NT\SecEdit\GptTmpl.inf" } + $denyLines = if ($inf -and (Test-Path -LiteralPath $inf)) { + [IO.File]::ReadAllText($inf, [Text.Encoding]::Unicode) -split "`r?`n" } else { @() } + $daSid = [regex]::Escape("*$((Get-ADDomain).DomainSID.Value)-512") + $names = { param($right) ($denyLines | Where-Object { $_ -match "^\s*$right\s*=" }) -join '' } + foreach ($right in 'SeDenyInteractiveLogonRight', 'SeDenyRemoteInteractiveLogonRight') { + $r["Deny Tier 0 refuses Domain Admins $right"] = ((& $names $right) -match "$daSid(,|\s*$)") + } + $r['Deny Tier 0 leaves Domain Admins network logon'] = + -not ((& $names 'SeDenyNetworkLogonRight') -match "$daSid(,|\s*$)") } # --- #1077: what each guest audits, as auditpol reads it ------------- diff --git a/docs/adr/0136-deny-the-domains-own-admins-the-console-on-members.md b/docs/adr/0136-deny-the-domains-own-admins-the-console-on-members.md new file mode 100644 index 000000000..a8ac46fa4 --- /dev/null +++ b/docs/adr/0136-deny-the-domains-own-admins-the-console-on-members.md @@ -0,0 +1,74 @@ +# ADR-0136: Deny the domain's own admins the console on members + +**Status:** Accepted · 2026-11 · extends the tiering of +[`build-the-lab-domain.md`](../runbooks/build-the-lab-domain.md) §5, within +[ADR-0029](0029-size-the-lab-domain-and-separate-its-namespace-and-clock.md) +and [ADR-0077](0077-configure-the-lab-domain-with-ansible-from-phoenix.md) + +## Context + +§5 builds three tiers so that "a violation is an event": the GPO *Deny Tier 0 +Logon on Members*, linked to `Servers` and `Workstations`, refuses interactive +and network logon to the group `Tier 0 Admins`, whose one member is +`t0-admin`. + +A read-only audit of `titan` on 2026-11-13, re-checked on 2026-11-25, found +that the GPO names nothing else. `AD\Administrator` is in Domain, Enterprise +and Schema Admins and not in `Tier 0 Admins`, so it can log on to any member, +and it was logged on at `titan`'s console for the audit itself. `titan` is +the relay target. A Tier 0 credential in its LSASS is one Mimikatz run from +Enterprise Admin, and its logon raised no event, because nothing it did was +refused. + +The obvious fix, denying Domain Admins every kind of logon on members, locks +out the pipeline. Ansible on `phoenix` connects to every guest as +`AD\Administrator` over SSH (ADR-0077 decision 2). A key logon through +Windows OpenSSH is an S4U logon of the network type, so it is governed by +`SeDenyNetworkLogonRight`, not by the interactive right. + +## Decision + +**Domain Admins and Enterprise Admins are refused the console and RDP on +members, and keep network logon.** The GPO's privilege rights become: + +- `SeDenyInteractiveLogonRight`: Tier 0 Admins, Domain Admins, Enterprise + Admins +- `SeDenyRemoteInteractiveLogonRight`: the same three. RDP is already off on + all six, and this keeps it from becoming a way round. +- `SeDenyNetworkLogonRight`: Tier 0 Admins only, as before + +`roles/gpos` fills the two new SIDs from the domain SID (RIDs 512 and 519) at +apply time, as it already does for Tier 0 Admins, and `verify.yml` asserts +the three lines. The DCs are untouched: the GPO is not linked to their OU. + +**The console on a member belongs to its local `Administrator`**, whose +password `roles/base` sets from `LAB_ADMIN_PASSWORD`. On the two endpoints +there is also `labadmin`. An agent session or an audit on a member runs over +SSH from `phoenix`, or as the local account, never as a domain admin at the +console. + +## Alternatives considered + +- **Deny Domain Admins network logon as well, and give Ansible its own + Tier 1 account.** The cleanest tiering, but it reworks ADR-0077's access + path: a new account, a new key on six guests, and every role's + connection. It can follow later as its own ADR. This change does not get in + its way. +- **Accept the gap and record it.** It leaves the one credential that owns + the forest free to land on the box built to be compromised, with no event + when it does. +- **Add `AD\Administrator` to `Tier 0 Admins`.** That inherits the network + deny, so the pipeline breaks for the same reason. + +## Consequences + +- **A domain admin at a member's console now fails with 4625**, which is the + event the tiering exists to produce, and the logon never happens. +- **The pipeline is unchanged.** Ansible's SSH logon is a network logon. The + first apply goes through `--check` and one member before the rest, because + if this reasoning is wrong it locks `phoenix` out of the members. Recovery + then is the local `Administrator` at the console, which this does not + touch. +- **A network-logon Tier 0 credential is still possible on a member** (SMB, + WMI, SSH as a domain admin). That is the residual the alternative above + would close. diff --git a/docs/adr/0137-leave-the-lab-domain-unpatched-and-refresh-it-by-rebuild.md b/docs/adr/0137-leave-the-lab-domain-unpatched-and-refresh-it-by-rebuild.md new file mode 100644 index 000000000..dca9716e4 --- /dev/null +++ b/docs/adr/0137-leave-the-lab-domain-unpatched-and-refresh-it-by-rebuild.md @@ -0,0 +1,70 @@ +# ADR-0137: Leave the lab domain unpatched, and refresh it by rebuild + +**Status:** Accepted · 2026-11 · within +[ADR-0029](0029-size-the-lab-domain-and-separate-its-namespace-and-clock.md) + +## Context + +Nothing in the repository says whether ADR-0029's six Windows guests are +patched. A read-only audit of `titan` on 2026-11-13 found the newest hotfix +dated 2026-01-14, the template's baseline. On 2026-11-25 Windows Update listed +five pending, including the 2026-11 cumulative update and the 2026-10 .NET +security update. Windows Update on the guest downloads and notifies +(`AUOptions` 3), so nothing installs. The patch-state alerts of +[#1544](https://github.com/Gerrrt/HomeLab/pull/1544) read apt, so nothing +reports it either. + +Three things make in-place patching a poor fit for this domain: + +- **It exists to be attacked as Windows ships.** §0 of + [`build-the-lab-domain.md`](../runbooks/build-the-lab-domain.md) forbids + hardening it, and §5 already warns that a servicing update can move a + default the exercises depend on, such as SMB signing on `titan`. A + cumulative update is exactly that kind of change, arriving unannounced. +- **The servers are evaluation-licensed and cannot be rearmed.** They must be + rebuilt from the template before each expiry: `titan`'s ends about + 2027-04-05, and `LabWindowsEvaluationExpiring` warns 30 days ahead. The + rebuild is scripted ([#448](https://github.com/Gerrrt/HomeLab/issues/448)). + So every guest is replaced on a cycle of at most 180 days whatever this + decides. +- **Patching the DCs means reboots** on a 7.2K mirror whose boot storm §0 + already plans around. + +## Decision + +**The six are not patched in place.** Windows Update stays as the template +leaves it. Pending updates on a lab guest are expected, and are not an audit +finding. + +**The refresh is the rebuild.** Each rebuild before a licence expiry starts +from the template's install media, and whatever that media carries is the +patch level for the next cycle. This decision adds no update step to the +template build. + +**A deliberate patch is recorded, like a hardening switched off.** When an +exercise needs a specific patch level, it is installed on purpose and the +exercise's record says so (§0's rule, applied in the other direction). + +## Alternatives considered + +- **Monthly `win_updates` from `phoenix`.** Keeps the guests current, at the + cost of a monthly run, DC reboots, and an exercise environment that moves + under the exercises. `verify.yml` would catch a moved signing default + afterwards, but only after it had moved. +- **Patch the template before sysprep.** Each rebuild would then start + current, with no in-place patching. Worth revisiting if the install media + falls far behind, but it adds a long, network-bound step to a build that is + already the slow part. + +## Consequences + +- **The lab domain runs known vulnerabilities by decision.** It lives on + VLAN 30, the lab segment, built for the techniques ADR-0014 names, and + reaches nothing VLAN 30 is not already allowed to reach. Its guests do + reach the internet, so a guest is no safer than its unpatched browser and + SMB client. Browsing from a lab guest is part of that risk, and the lab is + not for browsing. +- **Future audits read pending updates as expected**, and look instead at + whether the rebuild cycle is being kept: the licence clock is the measure. +- **`#1544`'s alerts stay apt-only.** No Windows patch-state collector is + planned while this decision holds. diff --git a/docs/changelog.md b/docs/changelog.md index 84cf0b233..771091bad 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,32 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-25 +- **The read-only audit of `titan` (2026-11-13, re-checked today) leaves + four changes in the repository, and none yet on the guests.** What it found + matching: the shares and their ACLs, the decoy, inbound SMB signing off, the + agents, Sysmon's config hash, the exporter, `phoenix`'s key alone in + `sshd`, and all six ADR-0083 weaknesses absent. What it found wrong, and + where each goes: + - **`AD\Administrator` could log on to a member's console**, because *Deny + Tier 0 Logon on Members* named only `Tier 0 Admins`. ADR-0136 adds Domain + and Enterprise Admins to the interactive and RDP denies and leaves + network logon, which is how Ansible reaches the guests. `roles/gpos` and + `verify.yml` carry it. It takes effect at the next + `--tags gpos` run from `phoenix`. + - **No Windows patch since the template's baseline (2026-01-14), and five + pending.** ADR-0137 makes that the design: the six are refreshed by + rebuild before each licence expiry, not patched in place. + - **C: is 59 GB on `titan`'s 80 GB disk**, because Setup put the recovery + partition after it. The template now creates it before C:, and + `roles/base` grows C: into the disk. Neither touches a live guest's + partitions, so `titan` and `ramuh` change at their next rebuild. + - **`build-the-lab-domain.md` §10 still listed `5985` on the four servers.** + `SetupComplete.cmd` disables WinRM on every clone, and `titan` has no + listener. The section now says so. + + The nightly VSS freeze failures seen at about 05:05 between 2026-11-07 and + 2026-11-14 have not recurred. Their cause is not established. + - **`build-the-backup-guest.md` §2 gains a host firewall for `golem`.** The audit of 2026-11-13 left the choice open, and the entry below lists it as the last thing not done. `golem` can delete every backup the lab has, diff --git a/docs/runbooks/build-the-lab-domain.md b/docs/runbooks/build-the-lab-domain.md index 4ce4a4f59..e0f9cff4f 100644 --- a/docs/runbooks/build-the-lab-domain.md +++ b/docs/runbooks/build-the-lab-domain.md @@ -271,7 +271,7 @@ build, preview one stage at a time and apply it before previewing the next: | `population` | §5 | The people in [`population.yaml`](../../ansible/population/population.yaml): an OU per department under `OU=People`, their groups under `OU=Groups`, and the users, `authgen` among them, with passwords derived from `LAB_POPULATION_SEED` | | `authgen` | §6 | The batch-logon right and the `Lab-AuthGenerator` task on both endpoints, as `authgen` | | `tiers` | §5 | The five tier OUs, the three tier admins, the `Tier 0 Admins` group, and the members placed in `Servers`/`Workstations` | -| `gpos` | §5 | *Deny Tier 0 Logon on Members*, and the two audit policies: the member servers' (Windows defaults plus File Share) and the DCs' (their 17 subcategories plus Directory Service Changes), #1077 | +| `gpos` | §5 | *Deny Tier 0 Logon on Members* (with Domain and Enterprise Admins refused the console and RDP, ADR-0136), and the two audit policies: the member servers' (Windows defaults plus File Share) and the DCs' (their 17 subcategories plus Directory Service Changes), #1077 | | `audit` | §5 | Inherited audit entries on the domain head, so SPN and delegation writes on users and computers log a 5136 (#1077) | | `shares` | §5 | `titan`'s `Public` and `Finance` shares, with the decoy | | `soc` | §11 | Wazuh and Velociraptor installed on all six, in place of the deploy GPOs | @@ -834,6 +834,16 @@ ordinary users, and one service account with an SPN on a real service on > detection if the tiers exist. Build the GPO that denies Tier 0 interactive and > network logon anywhere but the two DCs, and then know that you have built the > thing the alert will key on. +> +> **The domain's own admins are Tier 0 too.** `AD\Administrator` is in Domain, +> Enterprise and Schema Admins and not in `Tier 0 Admins`, so a GPO naming only +> that group lets it log on anywhere. Since +> [ADR-0136](../adr/0136-deny-the-domains-own-admins-the-console-on-members.md) +> the same GPO also refuses Domain and Enterprise Admins the console and RDP +> on members. It does not refuse them network logon, because that is how +> `phoenix` gets in: Ansible connects as `AD\Administrator` over SSH, and a key +> logon is a network logon. At a member's console, log on as its local +> `Administrator`. `titan` gets the shares — including one obviously-interesting decoy, because a share nobody would open is not a share anyone will be caught opening. And check @@ -1244,9 +1254,14 @@ Firewall. The prose this table replaces was wrong in three places: - **RDP is answered by none of the six**, not all six. It is off as Windows ships it: `fDenyTSConnections` is `1` and the *Remote Desktop* firewall rules are disabled. Read on `bahamut` and `carbuncle`. -- **WinRM (`5985`) is open on the four servers**, as Server 2025 ships it, - and closed on the endpoints, as Windows 11 ships it. The old list did not - mention it. +- **WinRM (`5985`) was open on the four servers** on 2026-10-02, as Server + 2025 ships it, and closed on the endpoints, as Windows 11 ships it. **It is + closed on all six since the #448 rebuild:** every clone of the templates runs + `SetupComplete.cmd`, which disables and stops WinRM + (`packer/windows/scripts/SetupComplete.cmd`), so the `5985` in the table + above is no longer answered. Read on `titan` on 2026-11-25: the service is + disabled and nothing listens on `5985`. The other three servers follow from + the same script and have not been rescanned from Hicks. - **`ramuh` serves no SMB.** Only `titan` has shares, so only `titan` opens `445`. diff --git a/packer/windows/autounattend.xml.pkrtpl b/packer/windows/autounattend.xml.pkrtpl index 102fe45a8..5511c6d9b 100644 --- a/packer/windows/autounattend.xml.pkrtpl +++ b/packer/windows/autounattend.xml.pkrtpl @@ -57,9 +57,20 @@ MSR 16 + 3 Primary + 1024 + + + 4 + Primary true @@ -78,6 +89,13 @@ 3 3 NTFS + + DE94BBA4-06D1-4D40-A16A-BFD50179D6AC + + + 4 + 4 + NTFS C @@ -94,7 +112,7 @@ 0 - 3 + 4