Detection: Windows Steal Authentication Certificates - ESC1 Authentication

Description

The following analytic detects when a suspicious certificate with a Subject Alternative Name (SAN) is issued using Active Directory Certificate Services (AD CS) and then immediately used for authentication. This detection leverages Windows Security Event Logs, specifically EventCode 4887, to identify the issuance and subsequent use of the certificate. This activity is significant because improperly configured certificate templates can be exploited for privilege escalation and environment compromise. If confirmed malicious, an attacker could gain unauthorized access, escalate privileges, and potentially compromise the entire environment.

 1`wineventlog_security` EventCode IN (4887) Attributes="*SAN:*upn*" Attributes="*CertificateTemplate:*" 
 2| stats count min(_time) as firstTime max(_time) as lastTime values(name) as name values(status) as status values(Subject) as ssl_subject values(SubjectKeyIdentifier) as ssl_hash by Computer, EventCode, Requester, Attributes, RequestId 
 3| rex field=Attributes "(?i)CertificateTemplate:(?<object>[^\r\n]+)" 
 4| rex field=Attributes "(?i)ccm:(?<req_src>[^\r\n]+)" 
 5| rex max_match=10 field=Attributes "(?i)(upn=(?<req_user_1>[^\r\n&]+))" 
 6| rex max_match=10 field=Attributes "(?i)(dns=(?<req_dest_1>[^\r\n&]+))" 
 7| rex field=Requester "(.+\\\\)?(?<src_user>[^\r\n]+)" 
 8| rename Attributes as object_attrs, EventCode as signature_id, name as signature, RequestId as ssl_serial, Requester as ssl_subject_common_name 
 9| eval user = lower(coalesce(req_user_1,req_user_2))  
10| join user [ 
11| search `wineventlog_security` EventCode=4768 CertThumbprint=* 
12| rename TargetUserName as user, Computer as auth_dest, IpAddress as auth_src 
13| fields auth_src,auth_dest,user ] 
14| eval src = upper(coalesce(auth_src,req_src)), dest = upper(coalesce(auth_dest,req_dest_1,req_dest_2)), risk_score = 90 
15| eval flavor_text = case(signature_id=="4887", "User account [".'user'."] authenticated after a suspicious certificate was issued for it by [".'src_user'."] using certificate request ID: ".'ssl_serial') 
16| fields - req_* auth_* 
17| `security_content_ctime(firstTime)` 
18| `security_content_ctime(lastTime)` 
19| `windows_steal_authentication_certificates___esc1_authentication_filter`

Data Source

Name Platform Sourcetype Source Supported App
Windows Event Log Security 4768 Windows icon Windows 'xmlwineventlog' 'XmlWinEventLog:Security' N/A

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
windows_steal_authentication_certificates___esc1_authentication_filter search *
windows_steal_authentication_certificates___esc1_authentication_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
T1649 Steal or Forge Authentication Certificates Credential Access
T1550 Use Alternate Authentication Material Defense Evasion
KillChainPhase.EXPLOITAITON
NistCategory.DE_CM
Cis18Value.CIS_10
APT29

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

To implement this analytic, enhanced Audit Logging must be enabled on AD CS and within Group Policy Management for CS server. See Page 115 of first reference. Recommend throttle correlation by RequestId/ssl_serial at minimum.

Known False Positives

False positives may be generated in environments where administrative users or processes are allowed to generate certificates with Subject Alternative Names for authentication. Sources or templates used in these processes may need to be tuned out for accurate function.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message Risk Score Impact Confidence
Possible AD CS ESC1 authentication on $dest$ 90 100 90
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 Passing 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