TExcelTAD
Home › Windows & Active Directory Security › Event Log Channels and the Audit Policy

Event Log Channels and the Audit Policy

Every detection in this course names an event ID: 4769 for Kerberoasting, 4662 for DCSync, 5136 for a changed ACL. Each of those events exists only if the audit policy told Windows to write it, and only helps if the log was big enough to still hold it and was copied somewhere the attacker couldn't clear. Incident responders regularly find that the one event that would have explained the intrusion was never generated. This lesson is about making sure it is: which channels exist, how the advanced audit policy works, what domain controllers and members should audit, and how to check a machine's actual setting from an export.

The classic channels and the most common Security event IDs were introduced in The Windows Registry and Event Log; parsing exports in PowerShell is practised in Parsing CSV and JSON Event Exports. The reference table of AD event IDs is in The Key Event IDs and Sysmon.

Channels worth collecting

Channel Why a domain defender wants it
Security logons, Kerberos and NTLM on DCs, account and group changes, directory access, process creation
System service installs (7045), time changes, log cleared (104)
Microsoft-Windows-PowerShell/Operational script-block logging 4104 (PowerShell Security)
Microsoft-Windows-Sysmon/Operational Sysmon, if deployed
Directory Service (DCs) LDAP signing (2886–2889), expensive or inefficient LDAP queries (1644, with diagnostic logging)
Microsoft-Windows-NTLM/Operational NTLM use when NTLM auditing is enabled: the inventory you need before restricting NTLM
Microsoft-Windows-TaskScheduler/Operational, …-WinRM/Operational, …-TerminalServices-* scheduled tasks, remote management, RDP sessions
Microsoft-Windows-Windows Defender/Operational detections (1116, 1117) and tampering

How the advanced audit policy works

The Security log is controlled by the advanced audit policy: 10 categories split into about 60 subcategories, each set to Success, Failure, both or none. It replaced the nine coarse "legacy" categories; when both are configured through Group Policy, set "Audit: Force audit policy subcategory settings to override audit policy category settings" so the advanced one wins. Some events need a second switch:

  • Directory Service Changes (5136, 5137, 5141) and Directory Service Access (4662) need the subcategory and a SACL on the objects (the default SACL on the domain root covers much, but not everything).
  • Process Creation (4688) records command lines only with "Include command line in process creation events".
  • File System and Registry auditing (4663, 4657) need SACLs on the files or keys.

auditpol /get /category:* /r prints the effective setting as CSV; that is the authoritative view, because local policy, GPO and legacy settings combine. The export below is abridged to three columns (the real output also has machine, policy target, the subcategory GUID and exclusion settings) from the lab DC.

powershell · try it yourself
$effective = @'
Subcategory,Inclusion Setting
Credential Validation,Success
Kerberos Authentication Service,Success and Failure
Kerberos Service Ticket Operations,No Auditing
Logon,Success and Failure
Special Logon,Success
Account Lockout,No Auditing
Security Group Management,Success
User Account Management,Success
Computer Account Management,No Auditing
Directory Service Access,No Auditing
Directory Service Changes,No Auditing
Process Creation,Success
Audit Policy Change,Success
Sensitive Privilege Use,No Auditing
Certification Services,No Auditing
'@ | ConvertFrom-Csv

# What this course's detections need on a DC: subcategory -> (setting, events it produces)
$need = [ordered]@{
  'Credential Validation'              = 'Success and Failure', '4776'
  'Kerberos Authentication Service'    = 'Success and Failure', '4768 4771'
  'Kerberos Service Ticket Operations' = 'Success and Failure', '4769'
  'Logon'                              = 'Success and Failure', '4624 4625'
  'Special Logon'                      = 'Success', '4672'
  'Account Lockout'                    = 'Failure', '4625 (lockout status)'
  'Security Group Management'          = 'Success', '4728 4732 4756'
  'User Account Management'            = 'Success and Failure', '4720 4738 4765'
  'Computer Account Management'        = 'Success', '4741 4742'
  'Directory Service Access'           = 'Success', '4662'
  'Directory Service Changes'          = 'Success', '5136 5137 5141'
  'Process Creation'                   = 'Success', '4688'
  'Audit Policy Change'                = 'Success', '4719'
}

$have = @{}
$effective | ForEach-Object { $have[$_.Subcategory] = $_.'Inclusion Setting' }
function Covers($has, $want) {
  if ($has -eq 'Success and Failure') { return $true }
  return $has -eq $want
}
$gaps = 0
foreach ($sub in $need.Keys) {
  $want, $events = $need[$sub]
  $has = $have[$sub]
  if (-not (Covers $has $want)) {
    $gaps++
    "{0,-36} has {1,-20} needs {2,-20} -> missing {3}" -f $sub, $has, $want, $events
  }
}
"$gaps of $($need.Count) subcategories short of the detection baseline"
Credential Validation                has Success              needs Success and Failure  -> missing 4776
Kerberos Service Ticket Operations   has No Auditing          needs Success and Failure  -> missing 4769
Account Lockout                      has No Auditing          needs Failure              -> missing 4625 (lockout status)
User Account Management              has Success              needs Success and Failure  -> missing 4720 4738 4765
Computer Account Management          has No Auditing          needs Success              -> missing 4741 4742
Directory Service Access             has No Auditing          needs Success              -> missing 4662
Directory Service Changes            has No Auditing          needs Success              -> missing 5136 5137 5141
7 of 13 subcategories short of the detection baseline

This DC would log logons and group changes, but no service tickets (so no Kerberoasting detection), no directory access or changes (no DCSync, no ACL or GPO tampering detection) and no computer account creation (no detection of the first step of a resource-based delegation abuse). Those are exactly the gaps that let most of the weaknesses in this course go unseen. Certification Services isn't in the list because it belongs on the CA (CA01), not the DC; AD CS covers it.

How gaps are detected

  • Measure, don't assume: collect auditpol /r from every DC and a sample of members and compare with the baseline, as above. Alert on 4719 (system audit policy was changed) and on 1102 / 104 (log cleared).
  • Volume monitoring: a DC whose 4769 count drops to zero has a broken policy or a broken forwarder; alert on missing data, not just on bad data.
  • Test the pipeline: generate a known event in the lab (add a test user to a test group) and check that it arrives in the SIEM within minutes.

How it is fixed

  • Configure the advanced audit policy through a GPO linked to the Domain Controllers OU and one for members, starting from Microsoft's audit policy recommendations or the security baseline, and add what your detections need.
  • Size the Security log on DCs to hold days (hundreds of MB to several GB) and forward events with Windows Event Forwarding or a SIEM agent, so that clearing the local log doesn't erase the evidence.
  • Add SACLs for directory objects you want to watch: AdminSDHolder, the domain root (replication rights), GPO containers, AD CS templates, msDS-AllowedToActOnBehalfOfOtherIdentity on servers.
  • Restrict who can manage auditing (SeSecurityPrivilege, "Manage auditing and security log") to administrators only.

Pitfalls

  • Auditing everything. "Success and Failure" on Filtering Platform Connection or Handle Manipulation floods the log and pushes the important events out within minutes. Turn on what you use.
  • GPO conflict with legacy categories. Without the "force subcategory" option, a legacy setting can silently override the advanced policy.
  • Forgetting the SACL. Directory Service Changes is "on", yet 5136 never appears for the object you care about because no SACL covers it.
  • Unsynchronised clocks make correlation across DCs and members wrong; Kerberos needs them in sync anyway.

Practice

1. Which two settings must be on for 4688 events to show the full command line?

The Process Creation subcategory (Success) and the policy "Include command line in process creation events" (Administrative Templates → System → Audit Process Creation).

2. After fixing the GPO, the DC logs 4662 for some objects but not for the GPO containers. Why?

4662 needs a SACL entry on the object. The GPO containers under CN=Policies,CN=System need an auditing entry (for example Everyone, write property, success) for changes and access to be recorded.

3. Extend the script: also flag subcategories set to Success and Failure where the baseline says nothing, as "noise candidates".

Loop over $effective, skip names that are keys of $need, and print those whose Inclusion Setting is not No Auditing. In the export above that is none; on real machines it often finds Filtering Platform or Object Access settings that fill the log.

Test yourself

Which subcategory must be audited on a DC to get 4769 (service ticket requested) events?

  1. Logon
  2. Kerberos Service Ticket Operations
  3. Directory Service Changes
  4. Special Logon

Why can Directory Service Changes be enabled and still produce no 5136 for an object?

  1. 5136 only exists on workstations
  2. The object needs a SACL entry that matches the change
  3. The event is only written on Sundays
  4. Because 5136 is a System-log event

Which event ID says the system audit policy was changed?

  1. 4719
  2. 4720
  3. 4625
  4. 7045

Which command shows a machine's effective advanced audit policy as CSV?

  1. gpupdate /force
  2. auditpol /get /category:* /r
  3. wevtutil cl Security
  4. net user /domain