User account exposed to Kerberoastingedit

Detects when a user account has the servicePrincipalName attribute modified. Attackers can abuse write privileges over a user to configure Service Principle Names (SPNs) so that they can perform Kerberoasting. Administrators can also configure this for legitimate purposes, exposing the account to Kerberoasting.

Rule type: query

Rule indices:

  • winlogbeat-*
  • logs-system.*

Severity: high

Risk score: 73

Runs every: 5 minutes

Searches indices from: now-9m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References:

Tags:

  • Elastic
  • Host
  • Windows
  • Threat Detection
  • Credential Access
  • Active Directory

Version: 1

Added (Elastic Stack release): 8.2.0

Rule authors: Elastic

Rule license: Elastic License v2

Investigation guideedit

## Triage and analysis

### Investigating User account exposed to Kerberoasting

Service Principal Names (SPNs) are names by which Kerberos clients uniquely identify service instances for Kerberos target
computers.

By default, only computer accounts have SPNs, which creates no significant risk, since machine accounts have a default
domain policy that rotates their passwords every 30 days, and the password is composed of 120 random characters, making
them invulnerable to Kerberoasting.

A user account with an SPN assigned is considered a service account, and is accessible to the entire domain. If any
user in the directory requests a ticket-granting service (TGS), the domain controller will encrypt it with the secret
key of the account executing the service. An attacker can potentially perform a Kerberoasting attack with this
information, as the human-defined password is likely to be less complex.

For scenarios where SPNs cannot be avoided on user accounts, Microsoft provides the Group Managed Service Accounts (gMSA)
feature, which ensures that account passwords are robust and changed regularly and automatically. More information can
be found [here](https://docs.microsoft.com/en-us/windows-server/security/group-managed-service-accounts/group-managed-service-accounts-overview).

Attackers can also perform "Targeted Kerberoasting", which consists of adding fake SPNs to user accounts that they have
write privileges to, making them potentially vulnerable to Kerberoasting.

#### Possible investigation steps

- Identify the account that performed the action.
- Check whether this user should be doing this kind of activity.
- Contact the account owner and confirm whether they are aware of this activity.
- Investigate if the target account is a member of privileged groups (Domain Admins, Enterprise Admins, etc.).
- Investigate if tickets have been requested for the target account.
- Investigate other alerts related to the user in the last 48 hours.

### False positive analysis

- The use of user accounts as service accounts is a bad security practice and should not be allowed in the domain. The
security team should map and monitor any potential benign true positive (B-TP), especially if the account is privileged.
Domain Administrators that define this kind of setting can put the domain at risk as user accounts don't have the same
security standards as computer accounts (which have long, complex, random passwords that change frequently), exposing
them to credential cracking attacks (Kerberoasting, brute force, etc.).

### Response and remediation

- Initiate the incident response process based on the outcome of the triage.
- Reset the passwords of affected accounts, prioritizing privileged accounts.
- Quarantine the involved host for forensic investigation, as well as eradication and recovery activities.

## Config

The 'Audit Directory Service Changes' logging policy must be configured for (Success, Failure).
Steps to implement the logging policy with Advanced Audit Configuration:

```
Computer Configuration >
Policies >
Windows Settings >
Security Settings >
Advanced Audit Policies Configuration >
Audit Policies >
DS Access >
Audit Directory Service Changes (Success,Failure)
```

The above policy does not cover User objects, so set up an AuditRule using https://github.com/OTRF/Set-AuditRule.
As this specifies the servicePrincipalName Attribute GUID, it is expected to be low noise.

```
Set-AuditRule -AdObjectPath 'AD:\CN=Users,DC=Domain,DC=com' -WellKnownSidType WorldSid -Rights WriteProperty -InheritanceFlags Children -AttributeGUID f3a64788-5306-11d1-a9c5-0000f80367c1 -AuditFlags Success
```

Rule queryedit

event.action:"Directory Service Changes" and event.code:5136 and
winlog.event_data.ObjectClass:"user" and
winlog.event_data.AttributeLDAPDisplayName:"servicePrincipalName"

Threat mappingedit

Framework: MITRE ATT&CKTM