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`
 2EventCode IN (4887)
 3Attributes="*SAN:*upn*"
 4Attributes="*CertificateTemplate:*"
 5
 6| stats
 7    count
 8    min(_time) as firstTime
 9    max(_time) as lastTime
10    values(name) as name
11    values(status) as status
12    values(Subject) as ssl_subject
13    values(SubjectKeyIdentifier) as ssl_hash
14    by Computer, EventCode, Requester, Attributes, RequestId
15
16| rex field=Attributes "(?i)CertificateTemplate:(?<object>[^\r\n]+)"
17
18| rex field=Attributes "(?i)ccm:(?<req_src>[^\r\n]+)"
19
20| rex max_match=10 field=Attributes "(?i)(upn=(?<req_user_1>[^\r\n&]+))"
21
22| rex max_match=10 field=Attributes "(?i)(dns=(?<req_dest_1>[^\r\n&]+))"
23
24| rex field=Requester "(.+\\\\)?(?<src_user>[^\r\n]+)"
25
26| rename
27    Attributes as object_attrs
28    EventCode as signature_id
29    name as signature
30    RequestId as ssl_serial
31    Requester as ssl_subject_common_name
32
33| eval user = lower(coalesce(req_user_1, req_user_2))
34
35| join user [
36    search `wineventlog_security`
37    EventCode=4768
38    CertThumbprint=*
39    
40| rename
41        TargetUserName as user
42        Computer as auth_dest
43        IpAddress as auth_src
44    
45| fields auth_src, auth_dest, user
46]
47
48| eval
49    src = upper(coalesce(auth_src, req_src)),
50    dest = upper(coalesce(auth_dest, req_dest_1, req_dest_2)),
51    risk_score = 50
52
53| eval flavor_text = case(
54    signature_id=="4887",
55    "User account [" . user . "] authenticated after a suspicious certificate was issued for it by [" . src_user . "] using certificate request ID: " . ssl_serial
56)
57
58| fields - req_* auth_*
59
60| `security_content_ctime(firstTime)`
61
62| `security_content_ctime(lastTime)`
63
64| `windows_steal_authentication_certificates___esc1_authentication_filter`

Data Source

Name Platform Sourcetype Source
Windows Event Log Security 4768 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Security'
Windows Event Log Security 4887 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Security'

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
Exploitation
DE.CM
CIS 10

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:

Possible AD CS ESC1 authentication on $dest$

Risk Object Risk Object Type Risk Score Threat Objects
dest system 50 ssl_hash, ssl_serial
src system 50 ssl_hash, ssl_serial
user user 50 ssl_hash, ssl_serial
src_user user 50 ssl_hash, ssl_serial

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: 8