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
44 changes: 44 additions & 0 deletions ansible/roles/exporter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,41 @@
path: "{{ windows_exporter_textfile_dir }}"
state: directory

# The collector serves whatever .prom files are here as the guest's own metrics,
# so whoever can write here can forge a gauge, the licence clock included.
# ProgramData's inherited ACL gave BUILTIN\Users Write (the bahamut audit,
# 2026-11-25). Only SYSTEM (the exporter, licence-clock's task) and
# Administrators (Ansible, licence-clock's handler) write or read it now, with
# inheritance cut so a file dropped in takes the same two. Compared by SID.
- name: Only SYSTEM and Administrators may use the textfile directory
ansible.windows.win_powershell:
script: |
[CmdletBinding(SupportsShouldProcess)]
param([string]$Dir)
$Ansible.Changed = $false
$sids = @('S-1-5-18', 'S-1-5-32-544')
$acl = Get-Acl -LiteralPath $Dir
$have = @($acl.Access | ForEach-Object {
'{0}|{1}|{2}' -f $_.IdentityReference.Translate([Security.Principal.SecurityIdentifier]).Value,
$_.FileSystemRights, $_.InheritanceFlags
} | Sort-Object) -join ';'
$want = @($sids | ForEach-Object { "$_|FullControl|ContainerInherit, ObjectInherit" } | Sort-Object) -join ';'
if (-not $acl.AreAccessRulesProtected -or $have -ne $want) {
$Ansible.Changed = $true
if (-not $Ansible.CheckMode) {
$new = New-Object System.Security.AccessControl.DirectorySecurity
$new.SetAccessRuleProtection($true, $false)
foreach ($sid in $sids) {
$new.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(
(New-Object System.Security.Principal.SecurityIdentifier($sid)), 'FullControl',
'ContainerInherit, ObjectInherit', 'None', 'Allow')))
}
Set-Acl -LiteralPath $Dir -AclObject $new
}
}
parameters:
Dir: "{{ windows_exporter_textfile_dir }}"

# Whether the pinned release is installed is read from its MSI product code,
# not inferred from a folder or a file. That lets a run where it is already
# installed skip the download entirely, and lets check mode answer without the
Expand Down Expand Up @@ -85,3 +120,12 @@
profiles: [domain]
state: present
enabled: true

# Installed is decided by product code above, never by the MSI being here, so
# it goes once the service runs: staged in C:\ProgramData\lab, BUILTIN\Users
# could read it (the bahamut audit, 2026-11-25). A version bump fetches the new
# one again.
- name: Remove the staged MSI
ansible.windows.win_file:
path: "C:\\ProgramData\\lab\\{{ exporter_msi }}"
state: absent
12 changes: 12 additions & 0 deletions ansible/roles/soc_agents/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@
state: started
when: soc_agents_velociraptor_present or not ansible_check_mode

# Installed is decided by product code, never by the MSI being here, so both
# go once their services run. Staged in C:\ProgramData\lab, BUILTIN\Users
# could read them, and the Velociraptor one carries its client config: the
# server's URL, CA and enrolment nonce (the bahamut audit, 2026-11-25).
- name: Remove the staged MSIs
ansible.windows.win_file:
path: "{{ item }}"
state: absent
loop:
- C:\ProgramData\lab\wazuh-agent.msi
- C:\ProgramData\lab\velociraptor-client.msi

# Retire the two GPOs that deployed these agents before this role did
# (build-the-soc-guest.md §11). Remove-GPO takes the GPO and its own SYSVOL
# folder, but the Wazuh startup script and the MSIs live in the domain scripts
Expand Down
13 changes: 13 additions & 0 deletions ansible/roles/sysmon/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@
- not ansible_check_mode
notify: Resubscribe the Wazuh agent to the Sysmon channel

# Installed is decided by the binary's version, not by the zip, and the
# upgrade above uninstalls with C:\Windows\Sysmon64.exe, so neither the zip
# nor its unpacked copy is needed once Sysmon runs. Left staged, BUILTIN\Users
# could read both (the bahamut audit, 2026-11-25). The config's own folder
# stays: it is the record of what was applied.
- name: Remove the staged zip and its unpacked copy
ansible.windows.win_file:
path: "{{ item }}"
state: absent
loop:
- "{{ sysmon_zip }}"
- "{{ sysmon_unpacked }}"

# Compare-first against what the driver last loaded, not against whether the
# copy above changed: a config changed by hand on the guest (sysmon -c) is drift
# too, and this puts the vendored one back. The file's own hash is read on the
Expand Down
12 changes: 12 additions & 0 deletions ansible/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@
# deletes. roles/base removes both; neither may be on any guest.
$r['no plaintext answer file in Panther'] = -not ((Test-Path C:\Windows\Panther\unattend-original.xml) -or
(Test-Path C:\Windows\Panther\unattend-oobe.xml))
# The bahamut audit's staging leftovers (2026-11-25): roles/soc_agents,
# exporter and sysmon remove their installers once installed, and only
# SYSTEM and Administrators may write a metric into the textfile folder.
$staged = Get-ChildItem C:\ProgramData\lab -Force -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like '*.msi' -or $_.Name -like 'Sysmon-*' }
$r['no staged installer in C:\ProgramData\lab'] = (@($staged).Count -eq 0)
$tf = 'C:\ProgramData\windows_exporter\textfile'
$r['only SYSTEM and Administrators in the textfile folder'] = [bool]((Test-Path $tf) -and
(Get-Acl $tf).AreAccessRulesProtected -and -not (@(Get-Item $tf; Get-ChildItem $tf -Force) | Get-Acl |
ForEach-Object Access | Where-Object {
$_.IdentityReference.Translate([Security.Principal.SecurityIdentifier]).Value -notin
@('S-1-5-18', 'S-1-5-32-544') }))
# --- #450: Sysmon, recording with the vendored config ----------------
# The driver as well as the service: Sysmon64 running over an unloaded
# SysmonDrv records nothing. ConfigHash is what the driver last loaded,
Expand Down
22 changes: 22 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ docstring gives: it is a record, not a claim about now.

## 2026-11-26

- **Lab domain: the `bahamut` audit's last two findings.** The staging
leftovers: `C:\ProgramData\lab` on every guest kept the Wazuh, Velociraptor
and exporter MSIs, the Sysmon zip and its unpacked folder, all readable by
`BUILTIN\Users`. The Velociraptor MSI carries its client config. `BUILTIN\Users`
could also write into the exporter's textfile directory, so any local user
could forge a gauge, the licence clock included. `roles/soc_agents`,
`exporter` and `sysmon` now delete their installers once installed (installed
is decided by product code or version, so nothing reinstalls). `roles/exporter`
limits the textfile directory to SYSTEM and Administrators with inheritance
cut, and `verify.yml` checks both. Applied and tested on `leviathan`: a second
run changed nothing, `licence-clock` still rewrote its gauge as SYSTEM, and
the exporter served it. The other five follow on the next run. The DFSR
5014/5004 pair both DCs log nightly around 05:00 UTC is the snapshot backup
freezing each guest in turn. `build-the-backup-guest.md` §8 now says so.
- **Lab domain: the `bahamut` audit's decisions applied to the live domain.**
After #1765, #1769 and ADR-0136's GPO (#1757) merged, `lab-domain.yml
--tags forest,gpos,unsigned_ldap,maq,spooler` ran on the DCs and members
from `phoenix`. It set the machine account quota to 0, disabled Print Spooler
on both DCs, applied the Tier 0 logon denial, and cleared `bahamut`'s root
hints and `cache.dns`. `verify.yml` then held on all four: `bahamut` 66
checks, `leviathan` 33, `titan` 27, `ramuh` 23. The endpoints were off and
not checked.
- **Correction to the entry below, "what the `bahamut` audit found,
decided (ADR-0140)".** That decision is
[ADR-0141](adr/0141-switch-three-of-the-dcs-shipped-defaults-and-keep-dsheuristics.md).
Expand Down
9 changes: 9 additions & 0 deletions docs/runbooks/build-the-backup-guest.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,15 @@ is in, because its case notes are in no repository
([ADR-0091](../adr/0091-put-a-kali-purple-analyst-workstation-on-saruman.md)).
The job selects VMIDs, so a new guest stays out unless someone adds it.

**The DCs log a DFSR 5014 and 5004 every night, and that is this job.** The
guest agent freezes each guest's filesystems for its snapshot, one guest at a
time, so each DC loses its replication partner for a few seconds and logs
DFSR event 5014, then 5004 about 10 s later when it reconnects. It happens
around 05:00 UTC (21:00 on `Saruman`, which keeps UTC−8) on both DCs. The
`bahamut` audit matched it to vzdump's log on 2026-11-25. Replication is clean
afterwards. A 5014 with no 5004 after it, or one at another hour, is a real
fault.

**Every guest in the job carries the Proxmox tag `backup`.** For the domain's
six and `garuda` it comes from `tofu/guests.tf`. `odin` is hand-built, so
`qm set 160 --tags` gives it the tag, keeping its existing ones.
Expand Down
16 changes: 16 additions & 0 deletions docs/runbooks/build-the-lab-domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,22 @@ have to go looking for. It is not a control against someone who already owns
`alexander`, and `security.md` records it as a residual rather than a
mitigation.

Then close the textfile directory to everyone but SYSTEM and Administrators,
and delete the MSI. The collector serves whatever `.prom` file it finds there
as the guest's own metrics. `ProgramData`'s inherited ACL lets
`BUILTIN\Users` write there, so any local user could forge a gauge, the
licence clock's included. The MSI is not needed once the service runs; the
same goes for the Wazuh and Velociraptor MSIs and the Sysmon zip and its
unpacked folder, and the Velociraptor MSI carries its client config.
`roles/exporter`, `soc_agents` and `sysmon` do both, and `verify.yml` checks
them:

```powershell
$tf = 'C:\ProgramData\windows_exporter\textfile'
icacls $tf /inheritance:r /grant:r '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F'
Remove-Item C:\ProgramData\lab\*.msi, C:\ProgramData\lab\Sysmon-* -Recurse
```

Finally the licence clock — a weekly scheduled task writing one gauge into the
textfile directory. **On the four servers only:** the endpoints run activated
Windows 11 Pro, where `GracePeriodRemaining` is `0`, so the gauge there would
Expand Down