Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.** 139 ADRs covering what was chosen
- **Documented decisions and runbooks.** 140 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
Expand Down Expand Up @@ -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/ # 139 ADRs — architecture decision records
│ ├── adr/ # 140 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
Expand Down
20 changes: 14 additions & 6 deletions ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,31 @@ covered in the runbook's [*Run it from `phoenix`*][run] section.
| `ucd` | Unconstrained delegation on `ramuh` | §5a |
| `cd` | Constrained delegation, `svc-web` to `titan` CIFS | §5a |
| `rbcd` | Resource-based constrained delegation on `titan` | §5a |
| `unsigned_ldap` | LDAP signing enforcement lifted on both DCs | §5a |
| `maq` | The shipped machine account quota of 10 | §5a |
| `spooler` | Print Spooler running on both DCs, as shipped | §5a |
| `sysmon` | Sysmon and its config, on every guest | §7 |

The `tiers`, `shares` and `soc` tags (#448) apply the rest of §5's skeleton and
§11's agents. The last six are
§11's agents. The nine from `kerberoast` to `spooler` are
[#449](https://github.com/Gerrrt/HomeLab/issues/449)'s deliberate weaknesses
([ADR-0083]), each off until asked for: `weakness_<name>_state` is `absent` by
default, so a plain run leaves none of them present. Enable one, watch the SOC
([ADR-0083], and [ADR-0140] for the last three), each off until asked for:
`weakness_<name>_state` is `absent` by default, so a plain run leaves none of
them present. The last three are shipped defaults on the DCs, so for `maq` and
`spooler` a plain run is the change: it sets the quota to 0 and disables
Spooler on both DCs. `unsigned_ldap` absent leaves signing enforced, as Server
2025 ships it. Enable one, watch the SOC
see it, disable it, confirm the signal goes:

```bash
ansible-playbook lab-domain.yml --tags kerberoast -e weakness_kerberoast_state=present
ansible-playbook verify.yml -e weakness_kerberoast_state=present # it is on
ansible-playbook lab-domain.yml --tags kerberoast # off again
ansible-playbook verify.yml # all six absent
ansible-playbook verify.yml # all nine absent
```

A plain `ansible-playbook verify.yml` asserts every one of these six weakness
primitives is absent — the per-primitive negative test. It does not walk the
A plain `ansible-playbook verify.yml` asserts every one of these nine weakness
primitives is absent, and that `dsHeuristics` is still unset ([ADR-0140]) — the per-primitive negative test. It does not walk the
domain's authorization graph, so it does not by itself prove *no* path to
Domain Admin exists; that graph-level check is a BloodHound collector run with
the tags off ([#451](https://github.com/Gerrrt/HomeLab/issues/451)) — the "run
Expand Down Expand Up @@ -219,6 +226,7 @@ guest.
[ADR-0077]: ../docs/adr/0077-configure-the-lab-domain-with-ansible-from-phoenix.md
[ADR-0080]: ../docs/adr/0080-record-the-lab-domain-with-sysmon-and-capture-on-demand-with-pktmon.md
[ADR-0083]: ../docs/adr/0083-give-the-lab-domain-its-deliberate-weaknesses-as-switchable-tags.md
[ADR-0140]: ../docs/adr/0140-switch-three-of-the-dcs-shipped-defaults-and-keep-dsheuristics.md
[ADR-0085]: ../docs/adr/0085-check-the-lab-domains-host-keys-against-keys-read-through-the-guest-agent.md
[runbook]: ../docs/runbooks/build-the-lab-domain.md
[run]: ../docs/runbooks/build-the-lab-domain.md#run-it-from-phoenix
15 changes: 14 additions & 1 deletion ansible/inventory/group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ soc_agents_velociraptor_msi_url: >-
# dcsync and delegation exercises. Like every secret it comes from phoenix.env,
# never this tree, and the dedicated accounts share it. A role refuses to
# enable a weakness while it is unset. Nothing is enabled by default: a plain
# run leaves all six absent, which is #449's negative test.
# run leaves all nine absent, which is #449's negative test. The last three
# (ADR-0140) are shipped defaults on the DCs: a plain run turns MAQ and Spooler
# off, and leaves LDAP signing enforced.
lab_weak_password: "{{ lookup('ansible.builtin.env', 'LAB_WEAK_PASSWORD') }}"
# The dedicated accounts model Tier 1 service identities, so they live in the
# Tier 1 OU the skeleton already owns; absent deletes them and the OU stays.
Expand Down Expand Up @@ -147,6 +149,17 @@ lab_weakness_cd_target_spn: "CIFS/titan.{{ lab_domain }}"
lab_weakness_rbcd_account: svc-rbcd
lab_weakness_rbcd_spn: "HOST/svc-rbcd.{{ lab_domain }}"
lab_weakness_rbcd_resource: TITAN

# unsigned_ldap (ADR-0140): Server 2025 enforces LDAP signing while this value
# is unset. present writes it as 0; absent removes it.
lab_weakness_unsigned_ldap_key: HKLM:\SYSTEM\CurrentControlSet\Services\NTDS\Parameters
lab_weakness_unsigned_ldap_value: LdapServerEnforceIntegrity

# maq (ADR-0140): ms-DS-MachineAccountQuota on the domain head. present is
# Windows' shipped 10; absent is 0.
lab_weakness_maq_present: 10
lab_weakness_maq_absent: 0

# --- Sysmon (#450, ADR-0080) -------------------------------------------------
# Microsoft publishes Sysmon at one unversioned URL, so this pin goes stale the
# day a new release ships. roles/sysmon then fails at the checksum, before
Expand Down
27 changes: 25 additions & 2 deletions ansible/lab-domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@
# (weakness_<name>_state, default absent in the role). A plain run leaves every
# one absent — the negative test, that the path to Domain Admin is not there.
# Enable one, watch the SOC see it, disable it, watch the signal go. ADR-0083,
# and the identifiers are in group_vars/all.yaml. All six are directory writes,
# so they run on the PDC emulator like tiers and population.
# and the identifiers are in group_vars/all.yaml. The first six are directory
# writes, so they run on the PDC emulator like tiers and population. The last
# three (ADR-0140) are shipped defaults on the DCs, where absent is the
# hardened side: a plain run sets MAQ to 0 and disables Spooler on both DCs.
- name: Kerberoast — an SPN on a crackable account
hosts: dc_primary
gather_facts: false
Expand Down Expand Up @@ -244,3 +246,24 @@
roles:
- role: weakness_rbcd
tags: [rbcd]

- name: Unsigned LDAP — signing enforcement lifted on the DCs
hosts: dcs
gather_facts: false
roles:
- role: weakness_unsigned_ldap
tags: [unsigned_ldap]

- name: Machine account quota — ordinary users create computer accounts
hosts: dc_primary
gather_facts: false
roles:
- role: weakness_maq
tags: [maq]

- name: Print Spooler on the DCs — the coercion primitive
hosts: dcs
gather_facts: false
roles:
- role: weakness_spooler
tags: [spooler]
8 changes: 8 additions & 0 deletions ansible/roles/weakness_maq/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Off by default: a plain run sets the quota to 0. Enable (back to Windows'
# shipped 10) with
# ansible-playbook lab-domain.yml --tags maq -e weakness_maq_state=present
# and disable by applying the same tag with the default (or =absent). The two
# values are in inventory/group_vars/all.yaml, shared with verify.yml
# (ADR-0083, ADR-0140).
weakness_maq_state: absent
36 changes: 36 additions & 0 deletions ansible/roles/weakness_maq/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# ADR-0140: ms-DS-MachineAccountQuota on the domain head. At the shipped 10,
# any domain user can create computer accounts, the first step of RBCD and
# shadow-credential chains that need no other switch. present restores 10;
# absent sets 0. Nothing the build does needs it: every join runs as
# AD\Administrator, and weakness_rbcd brings its own controlled principal.
# Runs on the PDC emulator; compares before it writes.

- name: The toggle is a state this role understands
ansible.builtin.assert:
that: weakness_maq_state in ['present', 'absent']
fail_msg: >-
weakness_maq_state is '{{ weakness_maq_state }}', not 'present' or
'absent'. A typo must fail here, not take the teardown branch and
silently remove the weakness.
quiet: true

- name: Set the domain's machine account quota
ansible.windows.win_powershell:
script: |
[CmdletBinding(SupportsShouldProcess)]
param([int]$Want)
$Ansible.Changed = $false
Import-Module ActiveDirectory
$dn = (Get-ADDomain).DistinguishedName
$have = (Get-ADObject -Identity $dn -Properties 'ms-DS-MachineAccountQuota').'ms-DS-MachineAccountQuota'
if ([int]$have -ne $Want) {
if (-not $Ansible.CheckMode) {
Set-ADObject -Identity $dn -Replace @{ 'ms-DS-MachineAccountQuota' = $Want }
}
$Ansible.Changed = $true
}
parameters:
Want: >-
{{ lab_weakness_maq_present if weakness_maq_state == 'present'
else lab_weakness_maq_absent }}
7 changes: 7 additions & 0 deletions ansible/roles/weakness_spooler/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Off by default: a plain run disables Print Spooler on both DCs. Enable (back
# to Windows' shipped Automatic and running) with
# ansible-playbook lab-domain.yml --tags spooler -e weakness_spooler_state=present
# and disable by applying the same tag with the default (or =absent)
# (ADR-0083, ADR-0140).
weakness_spooler_state: absent
43 changes: 43 additions & 0 deletions ansible/roles/weakness_spooler/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# ADR-0140: Print Spooler on the domain controllers. A DC is trusted for
# unconstrained delegation by default, so a running spooler lets any domain
# user coerce the DC's machine account into authenticating to a host of their
# choosing. present leaves it as Windows ships it; absent stops and disables
# it. The DCs only: the members keep theirs, which is no path to Tier 0.
#
# PowerShell rather than win_service, which writes every property it
# manages: its desktop_interact defaults to false, and Server 2025 ships
# Spooler with it true, so win_service would change a third thing besides
# start mode and state. This touches those two only, and compares first.

- name: The toggle is a state this role understands
ansible.builtin.assert:
that: weakness_spooler_state in ['present', 'absent']
fail_msg: >-
weakness_spooler_state is '{{ weakness_spooler_state }}', not 'present'
or 'absent'. A typo must fail here, not take the teardown branch and
silently remove the weakness.
quiet: true

- name: Run or disable Print Spooler
ansible.windows.win_powershell:
script: |
[CmdletBinding(SupportsShouldProcess)]
param([string]$Want)
$Ansible.Changed = $false
$s = Get-Service -Name Spooler -ErrorAction Stop
$on = ($Want -eq 'present')
$mode = if ($on) { 'Automatic' } else { 'Disabled' }
$state = if ($on) { 'Running' } else { 'Stopped' }
if ($s.StartType -ne $mode) {
if (-not $Ansible.CheckMode) { Set-Service -Name Spooler -StartupType $mode }
$Ansible.Changed = $true
}
if ($s.Status -ne $state) {
if (-not $Ansible.CheckMode) {
if ($on) { Start-Service -Name Spooler } else { Stop-Service -Name Spooler -Force }
}
$Ansible.Changed = $true
}
parameters:
Want: "{{ weakness_spooler_state }}"
7 changes: 7 additions & 0 deletions ansible/roles/weakness_unsigned_ldap/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Off by default: signing stays enforced unless this is present. Enable with
# ansible-playbook lab-domain.yml --tags unsigned_ldap -e weakness_unsigned_ldap_state=present
# and disable by applying the same tag with the default (or =absent). The
# registry location is in inventory/group_vars/all.yaml, shared with verify.yml
# (ADR-0083, ADR-0140).
weakness_unsigned_ldap_state: absent
49 changes: 49 additions & 0 deletions ansible/roles/weakness_unsigned_ldap/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# ADR-0140: LDAP signing, off on demand. Server 2025 DCs enforce signing while
# LdapServerEnforceIntegrity is unset. present writes it as 0, so the DC takes
# unsigned simple and SASL binds, which makes NTLM relay to LDAP possible. absent
# removes the value, and the DC returns to the 2025 default.
#
# LDAPServerIntegrity is not written here. It ships as 1, and at 2 the DC
# requires signing whatever this value says. So present refuses to run on a DC
# where it is not 1, rather than report the switch as on when it is not.
# Runs on both DCs; compares before it writes, so a second run of either
# direction reports nothing changed.

- name: The toggle is a state this role understands
ansible.builtin.assert:
that: weakness_unsigned_ldap_state in ['present', 'absent']
fail_msg: >-
weakness_unsigned_ldap_state is '{{ weakness_unsigned_ldap_state }}', not
'present' or 'absent'. A typo must fail here, not take the teardown branch
and silently remove the weakness.
quiet: true

- name: Set or remove the DC's LDAP signing enforcement
ansible.windows.win_powershell:
script: |
[CmdletBinding(SupportsShouldProcess)]
param([string]$Path, [string]$Name, [string]$Want)
$Ansible.Changed = $false
$p = Get-ItemProperty -Path $Path -ErrorAction Stop
if ($Want -eq 'present') {
if ([int]$p.LDAPServerIntegrity -ne 1) {
throw ("LDAPServerIntegrity is '$($p.LDAPServerIntegrity)', not the shipped 1: " +
'signing would stay required. ADR-0140.')
}
if ($null -eq $p.$Name -or [int]$p.$Name -ne 0) {
if (-not $Ansible.CheckMode) {
New-ItemProperty -Path $Path -Name $Name -PropertyType DWord -Value 0 -Force | Out-Null
}
$Ansible.Changed = $true
}
} elseif ($null -ne $p.$Name) {
if (-not $Ansible.CheckMode) {
Remove-ItemProperty -Path $Path -Name $Name
}
$Ansible.Changed = $true
}
parameters:
Path: "{{ lab_weakness_unsigned_ldap_key }}"
Name: "{{ lab_weakness_unsigned_ldap_value }}"
Want: "{{ weakness_unsigned_ldap_state }}"
38 changes: 37 additions & 1 deletion ansible/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
rbcd_state: "{{ weakness_rbcd_state | default('absent') }}"
rbcd_account: "{{ lab_weakness_rbcd_account }}"
rbcd_resource: "{{ lab_weakness_rbcd_resource }}"
# ADR-0140's three, on the DCs.
unsigned_ldap_state: "{{ weakness_unsigned_ldap_state | default('absent') }}"
unsigned_ldap_key: "{{ lab_weakness_unsigned_ldap_key }}"
unsigned_ldap_value: "{{ lab_weakness_unsigned_ldap_value }}"
maq_state: "{{ weakness_maq_state | default('absent') }}"
maq_present: "{{ lab_weakness_maq_present }}"
maq_absent: "{{ lab_weakness_maq_absent }}"
spooler_state: "{{ weakness_spooler_state | default('absent') }}"
SysmonVersion: "{{ sysmon_version }}"
SysmonConfig: "{{ sysmon_config_sha256 }}"
script: |
Expand Down Expand Up @@ -149,6 +157,11 @@
$f = Get-DnsServerForwarder
$r["forwards to $Gateway only"] = ((@($f.IPAddress.IPAddressToString) -join ',') -eq $Gateway)
$r['no root hints'] = -not (Get-DnsServerRootHint)
# ADR-0140: dsHeuristics kept as Server 2025 ships it, unset. The
# 3051/3054 events at boot are expected; a value here is a hardening.
$dsh = Get-ADObject -Identity ("CN=Directory Service,CN=Windows NT,CN=Services," +
(Get-ADRootDSE).configurationNamingContext) -Properties dsHeuristics
$r['dsHeuristics unset, as shipped'] = [string]::IsNullOrEmpty($dsh.dsHeuristics)
$src = (w32tm /query /source | Out-String).Trim()
if ([bool]::Parse($IsPrimary)) {
$r["clock from $Gateway"] = ($src -like "$Gateway*")
Expand Down Expand Up @@ -292,7 +305,7 @@
}

# --- #449: each deliberate weakness is in the state its toggle names -
# Default absent, so a plain run asserts every one of these six
# Default absent, so a plain run asserts every one of these nine
# primitives is NOT there — the per-primitive negative test. It does
# not walk the authorization graph, so it is not on its own a proof
# that no path to Domain Admin exists; that graph-level check is the
Expand Down Expand Up @@ -368,6 +381,29 @@
$bHave = ($trusted -contains $rp.SID.Value)
}
$r['rbcd matches its toggle'] = ($bHave -eq ($Weak.rbcd_state -eq 'present'))

# maq (ADR-0140): the quota on the domain head, 10 or 0, and
# nothing between.
$q = (Get-ADObject -Identity $wbase -Properties 'ms-DS-MachineAccountQuota').'ms-DS-MachineAccountQuota'
$qWant = if ($Weak.maq_state -eq 'present') { $Weak.maq_present } else { $Weak.maq_absent }
$r["machine account quota is $qWant, as maq names"] = ([int]$q -eq [int]$qWant)
}

if ($onDc) {
# unsigned_ldap (ADR-0140): present is the enforcement value at 0
# over the shipped LDAPServerIntegrity of 1; absent is the value
# unset, Server 2025's enforced default.
$lp = Get-ItemProperty -Path $Weak.unsigned_ldap_key -ErrorAction SilentlyContinue
$lv = $lp.($Weak.unsigned_ldap_value)
$lHave = ($null -ne $lv -and [int]$lv -eq 0 -and [int]$lp.LDAPServerIntegrity -eq 1)
$r['unsigned_ldap matches its toggle'] = if ($Weak.unsigned_ldap_state -eq 'present') {
$lHave } else { ($null -eq $lv) }

# spooler (ADR-0140): running and Automatic, or stopped and Disabled.
$spl = Get-Service Spooler -ErrorAction SilentlyContinue
$r['spooler matches its toggle'] = if ($Weak.spooler_state -eq 'present') {
[bool]($spl -and $spl.Status -eq 'Running' -and $spl.StartType -eq 'Automatic')
} else { [bool]($spl -and $spl.Status -eq 'Stopped' -and $spl.StartType -eq 'Disabled') }
}

if ($LabRole -eq 'endpoint') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
> [ADR-0077](0077-configure-the-lab-domain-with-ansible-from-phoenix.md) amends the "join none of the estate's loops"
> consequence. The text here is left as written, per ADR-0001 and ADR-0115.
>
> [ADR-0140](0140-switch-three-of-the-dcs-shipped-defaults-and-keep-dsheuristics.md) amends "LDAP signing on the two DCs" in the
> list of hardening deliberately removed: it is removed on demand, by the
> `unsigned_ldap` switch, and stays enforced as shipped otherwise. The text
> here is left as written, per ADR-0001 and ADR-0115.
>
> The host this ADR calls `zion` is named **`smaug`** since 2026-09
> ([ADR-0038](0038-name-the-nas-smaug-and-reserve-zion-for-the-box-that-does-not-exist.md)).
> The address, the rules and the decision are unchanged — only the label. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ secret in `phoenix.env`) and
[ADR-0078](0078-populate-the-lab-domain-from-a-committed-file-and-a-seed.md)
(the weaknesses it said would come)

> [!NOTE]
> [ADR-0140](0140-switch-three-of-the-dcs-shipped-defaults-and-keep-dsheuristics.md) adds three switches in this model, `unsigned_ldap`,
> `maq` and `spooler`, under the reopen clause below. For `maq` and `spooler`
> `absent` is the hardened side, so applying them with the defaults changes
> the DCs, where this ADR's six changed nothing on merge. The text here is
> left as written, per ADR-0001 and ADR-0115.

## Context

[ADR-0029](0029-size-the-lab-domain-and-separate-its-namespace-and-clock.md)
Expand Down
Loading
Loading