Detection: ServicePrincipalNames Discovery with PowerShell

Description

The following analytic identifies PowerShell usage, using Script Block Logging EventCode 4104, related to querying the domain for Service Principal Names (SPNs). This is typically a precursor activity related to kerberoasting or silver ticket attacks. What is a ServicePrincipalName? A service principal name (SPN) is a unique identifier of a service instance. SPNs are used by Kerberos authentication to associate a service instance with a service logon account. This allows a client application to request that the service authenticate an account even if the client does not have the account name. The analytic identifies the use of KerberosRequestorSecurityToken class within the script block. Using .NET System.IdentityModel.Tokens.KerberosRequestorSecurityToken class in PowerShell is equivalent to using setspn.exe. This version reduces false positives by requiring both KerberosRequestorSecurityToken usage AND SPN-like patterns, while excluding common monitoring/hook function patterns. During triage, review parallel processes for further suspicious activity.

Annotations

No annotations available.

Implementation

To successfully implement this analytic, you will need to enable PowerShell Script Block Logging on some or all endpoints. Additional setup here https://help.splunk.com/en/security-offerings/splunk-user-behavior-analytics/get-data-in/5.4.1/add-other-data-to-splunk-uba/configure-powershell-logging-to-see-powershell-anomalies-in-splunk-uba.

Known False Positives

Security monitoring tools that implement PowerShell hooks, administrative scripts that legitimately reference Kerberos token classes, PowerShell modules or functions that contain the class name for educational purposes, and development environments where kerberoasting techniques are being researched.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message Risk Score Impact Confidence
Potential kerberoasting attempt detected on $device_hostname$ by user $actor_user_uid$. PowerShell command contains KerberosRequestorSecurityToken usage with SPN patterns, suggesting Service Principal Name enumeration for credential extraction. 72 80 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


Version: 4