Detection: Windows AD Suspicious GPO Modification

EXPERIMENTAL DETECTION

This detection status is set to experimental. The Splunk Threat Research team has not yet fully tested, simulated, or built comprehensive datasets for this detection. As such, this analytic is not officially supported. If you have any questions or concerns, please reach out to us at research@splunk.com.

Description

This analytic looks for a the creation of potentially harmful GPO which could lead to persistence or code execution on remote hosts. Note, this analyic is looking for the absence of the corresponding 5136 events which is evidence of the GPOs being manually edited (using a tool like PowerView) or potentially missing logs.

 1`wineventlog_security` EventCode=5145 ShareName="\\\\*\\SYSVOL" RelativeTargetName IN (*\\ScheduledTasks.xml, *\\Groups.xml, *\\Registry.xml, *\\Services.xml, *\\Scripts\\*) NOT RelativeTargetName=*\\Scripts\\scripts.ini AccessMask=0x2  
 2| rex field=AccessList max_match=0 "(?P<AccessList>%%\d+)"  
 3| table _time AccessMask src_ip src_user RelativeTargetName Logon_ID dvc  
 4| rex field=RelativeTargetName "Policies\\\(?P<gpo_guid>{.*?})\\\(?P<scope>\w+?)\\\(\w+)\\\(?P<folder>\w+)\\\(?P<file>\w+\.\w+)$" 
 5| eval src=if(match(src_ip, "(?i)^fe80:"),dvc,src_ip), folder=case(RelativeTargetName like "%\\Scripts\\%","Scripts",folder="Groups","Local users and groups",1=1,folder) 
 6| appendpipe 
 7  [
 8| map search="search `wineventlog_security` EventCode=5136 ObjectClass=groupPolicyContainer AttributeLDAPDisplayName=gPCMachineExtensionNames $gpo_guid$" 
 9  
10| stats min(_time) as _time values(eval(if(OperationType=="%%14675",AttributeValue,null))) as old_value values(eval(if(OperationType=="%%14674",AttributeValue,null))) as new_value values(OperationType) as OperationType by ObjectClass ObjectDN OpCorrelationID src_user SubjectLogonId 
11  
12| rex field=old_value max_match=10000 "(?P<old_values>\{.*?\})" 
13  
14| rex field=new_value max_match=10000 "(?P<new_values>\{.*?\})" 
15  
16| rex field=ObjectDN max_match=10000 "CN=(?P<policy_guid>\{.*?\})" 
17  
18| mvexpand new_values 
19  
20| where NOT new_values IN (old_values,"{00000000-0000-0000-0000-000000000000}",policy_guid) AND match(new_values, "^\{[A-Z
21|\d]+\-[A-Z
22|\d]+\-[A-Z
23|\d]+\-[A-Z
24|\d]+\-[A-Z
25|\d]+\}") 
26  
27| lookup msad_guid_lookup guid as new_values OUTPUTNEW displayName as policyType 
28  
29| eval newPolicy=if(policyType like "%",policyType,new_values) 
30  
31| stats values(OpCorrelationID) as OpCorrelationID values(newPolicy) as newPolicy by ObjectDN 
32  
33| rex field=ObjectDN max_match=10000 "CN=(?P<gpo_guid>\{.*?\})" 
34  
35| fields - ObjectDN] 
36
37| stats values(AccessMask) as AccessMask values(src) as src values(src_user) as src_user values(RelativeTargetName) as RelativeTargetName values(Logon_ID) as Logon_ID values(newPolicy) as newPolicy values(OpCorrelationID) as OpCorrelationID values(folder) as folder values(file) as file by gpo_guid  
38| mvexpand folder  
39| where NOT folder IN (newPolicy) 
40| `windows_ad_suspicious_gpo_modification_filter`

Data Source

No data sources specified for this detection.

Macros Used

Name Value
wineventlog_security eventtype=wineventlog_security OR Channel=security OR source=XmlWinEventLog:Security
windows_ad_suspicious_gpo_modification_filter search *
windows_ad_suspicious_gpo_modification_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1484 Domain or Tenant Policy Modification Defense Evasion
T1484.001 Group Policy Modification Privilege Escalation
T1222 File and Directory Permissions Modification Defense Evasion
T1222.001 Windows File and Directory Permissions Modification Privilege Escalation
KillChainPhase.EXPLOITAITON
NistCategory.DE_CM
Cis18Value.CIS_10
APT41
Cinnamon Tempest
Indrik Spider
Wizard Spider

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Notable Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Risk Event True
This configuration file applies to all detections of type TTP. These detections will use Risk Based Alerting and generate Notable Events.

Implementation

Ingest EventCodes 5145 and 5136 from domain controllers. Additional SACLs required to capture EventCode 5136, see references for further information on how to configure this. The Group Policy - Audit Detailed File Share will need to be enabled on the DCs to generate event code 5145, this event is very noisy on DCs, consider tuning out sysvol events which do not match access mask 0x2.

Known False Positives

When a GPO is manually edited and 5136 events are not logging to Splunk.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message Risk Score Impact Confidence
$src_user$ has added new GPO Client Side Extensions $folder$ to the policy $gpo_guid$ 80 100 80
The Risk Score is calculated by the following formula: Risk Score = (Impact * Confidence/100). Initial Confidence and Impact is set by the analytic author.

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Not Applicable N/A N/A N/A
Unit Passing Dataset XmlWinEventLog:Security XmlWinEventLog
Integration ✅ Passing Dataset XmlWinEventLog:Security XmlWinEventLog

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub | Version: 2