Detection rules › Kusto
Potential Kerberoasting
A service principal name (SPN) is used to uniquely identify a service instance in a Windows environment. Each SPN is usually associated with a service account. Organizations may have used service accounts with weak passwords in their environment. An attacker can try requesting Kerberos ticket-granting service (TGS) service tickets for any SPN from a domain controller (DC) which contains a hash of the Service account. This can then be used for offline cracking. This hunting query looks for accounts that are generating excessive requests to different resources within the last hour compared with the previous 24 hours. Normal users would not make an unusually large number of request within a small time window. This is based on 4769 events which can be very noisy so environment based tweaking might be needed.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Credential Access | T1558 Steal or Forge Kerberos Tickets |
Event coverage
| Provider | Event | Title |
|---|---|---|
| Security-Auditing | Event ID 4769 | A Kerberos service ticket was requested. |
Rule body kusto
id: 1572e66b-20a7-4012-9ec4-77ec4b101bc8
name: Potential Kerberoasting
description: |
'A service principal name (SPN) is used to uniquely identify a service instance in a Windows environment.
Each SPN is usually associated with a service account. Organizations may have used service accounts with weak passwords in their environment.
An attacker can try requesting Kerberos ticket-granting service (TGS) service tickets for any SPN from a domain controller (DC) which contains a hash of the Service account. This can then be used for offline cracking.
This hunting query looks for accounts that are generating excessive requests to different resources within the last hour compared with the previous 24 hours. Normal users would not make an unusually large number of request within a small time window. This is based on 4769 events which can be very noisy so environment based tweaking might be needed.'
severity: Medium
requiredDataConnectors:
- connectorId: SecurityEvents
dataTypes:
- SecurityEvent
- connectorId: WindowsSecurityEvents
dataTypes:
- SecurityEvent
- connectorId: WindowsForwardedEvents
dataTypes:
- WindowsEvent
queryFrequency: 1h
queryPeriod: 1d
triggerOperator: gt
triggerThreshold: 0
tactics:
- CredentialAccess
relevantTechniques:
- T1558
query: |
let starttime = 1d;
let endtime = 1h;
let prev23hThreshold = 4;
let prev1hThreshold = 15;
let Kerbevent = (union isfuzzy=true
(SecurityEvent
| where TimeGenerated >= ago(starttime)
| where EventID == 4769
| parse EventData with * 'TicketEncryptionType">' TicketEncryptionType "<" *
| where TicketEncryptionType == '0x17'
| parse EventData with * 'TicketOptions">' TicketOptions "<" *
| where TicketOptions == '0x40810000'
| parse EventData with * 'Status">' Status "<" *
| where Status == '0x0'
| parse EventData with * 'ServiceName">' ServiceName "<" *
| where ServiceName !contains "$" and ServiceName !contains "krbtgt"
| parse EventData with * 'TargetUserName">' TargetUserName "<" *
| where TargetUserName !contains "$@" and TargetUserName !contains ServiceName
| parse EventData with * 'IpAddress">::ffff:' ClientIPAddress "<" *
),
(
WindowsEvent
| where TimeGenerated >= ago(starttime)
| where EventID == 4769 and EventData has '0x17' and EventData has '0x40810000' and EventData has 'krbtgt'
| extend TicketEncryptionType = tostring(EventData.TicketEncryptionType)
| where TicketEncryptionType == '0x17'
| extend TicketOptions = tostring(EventData.TicketOptions)
| where TicketOptions == '0x40810000'
| extend Status = tostring(EventData.Status)
| where Status == '0x0'
| extend ServiceName = tostring(EventData.ServiceName)
| where ServiceName !contains "$" and ServiceName !contains "krbtgt"
| extend TargetUserName = tostring(EventData.TargetUserName)
| where TargetUserName !contains "$@" and TargetUserName !contains ServiceName
| extend ClientIPAddress = tostring(EventData.IpAddress)
));
let Kerbevent23h = Kerbevent
| where TimeGenerated >= ago(starttime) and TimeGenerated < ago(endtime)
| summarize ServiceNameCountPrev23h = dcount(ServiceName), ServiceNameSet23h = makeset(ServiceName)
by Computer, TargetUserName,TargetDomainName, ClientIPAddress, TicketOptions, TicketEncryptionType, Status
| where ServiceNameCountPrev23h < prev23hThreshold;
let Kerbevent1h =
Kerbevent
| where TimeGenerated >= ago(endtime)
| summarize min(TimeGenerated), max(TimeGenerated), ServiceNameCountPrev1h = dcount(ServiceName), ServiceNameSet1h = makeset(ServiceName)
by Computer, TargetUserName, TargetDomainName, ClientIPAddress, TicketOptions, TicketEncryptionType, Status;
Kerbevent1h
| join kind=leftanti
(
Kerbevent23h
) on TargetUserName, TargetDomainName
// Threshold value set above is based on testing, this value may need to be changed for your environment.
| where ServiceNameCountPrev1h > prev1hThreshold
| project StartTime = min_TimeGenerated, EndTime = max_TimeGenerated, TargetUserName, Computer, ClientIPAddress, TicketOptions,
TicketEncryptionType, Status, ServiceNameCountPrev1h, ServiceNameSet1h, TargetDomainName
| extend HostName = tostring(split(Computer, ".")[0]), DomainIndex = toint(indexof(Computer, '.'))
| extend HostNameDomain = iff(DomainIndex != -1, substring(Computer, DomainIndex + 1), Computer)
| extend TargetAccount = strcat(TargetDomainName, "\\", TargetUserName)
| project-away DomainIndex
entityMappings:
- entityType: Account
fieldMappings:
- identifier: FullName
columnName: TargetAccount
- identifier: Name
columnName: TargetUserName
- identifier: NTDomain
columnName: TargetDomainName
- entityType: Host
fieldMappings:
- identifier: FullName
columnName: Computer
- identifier: HostName
columnName: HostName
- identifier: DnsDomain
columnName: HostNameDomain
- entityType: IP
fieldMappings:
- identifier: Address
columnName: ClientIPAddress
version: 1.1.7
kind: Scheduled
metadata:
source:
kind: Community
author:
name: Microsoft Security Research
support:
tier: Community
categories:
domains: [ "Security - Others", "Identity" ]
Stages and Predicates
Parameters
let starttime = 1d;
let endtime = 1h;
let prev23hThreshold = 4;
let prev1hThreshold = 15;
Let binding: Kerbevent23h
let Kerbevent23h = Kerbevent
| where TimeGenerated >= ago(starttime) and TimeGenerated < ago(endtime)
| summarize ServiceNameCountPrev23h = dcount(ServiceName), ServiceNameSet23h = makeset(ServiceName)
by Computer, TargetUserName,TargetDomainName, ClientIPAddress, TicketOptions, TicketEncryptionType, Status
| where ServiceNameCountPrev23h < prev23hThreshold;
Derived from starttime, endtime, prev23hThreshold, Kerbevent.
The stages below define let Kerbevent1h (the rule's main pipeline source).
Stage 1: source
let Kerbevent
Stage 2: source
let Kerbevent23h
Stage 3: source
let Kerbevent1h
Stage 4: union
union isfuzzy=true
Stage 5: source
SecurityEvent
Stage 6: where
| where TimeGenerated >= ago(starttime)
The stages below run on Kerbevent1h (the outer pipeline).
Stage 7: where
Kerbevent1h
| where EventID == 4769
Stage 8: parse
| parse EventData with * 'TicketEncryptionType">' TicketEncryptionType "<" *
Stage 9: where
| where TicketEncryptionType == '0x17'
Stage 10: parse
| parse EventData with * 'TicketOptions">' TicketOptions "<" *
Stage 11: where
| where TicketOptions == '0x40810000'
Stage 12: parse
| parse EventData with * 'Status">' Status "<" *
Stage 13: where
| where Status == '0x0'
Stage 14: parse
| parse EventData with * 'ServiceName">' ServiceName "<" *
Stage 15: where
| where ServiceName !contains "$" and ServiceName !contains "krbtgt"
Stage 16: parse
| parse EventData with * 'TargetUserName">' TargetUserName "<" *
Stage 17: where
| where TargetUserName !contains "$@" and TargetUserName !contains ServiceName
Stage 18: parse
| parse EventData with * 'IpAddress">::ffff:' ClientIPAddress "<" *
Stage 19: source
WindowsEvent
Stage 20: where
| where TimeGenerated >= ago(starttime)
Stage 21: where
| where EventID == 4769 and EventData has '0x17' and EventData has '0x40810000' and EventData has 'krbtgt'
Stage 22: extend
| extend TicketEncryptionType = tostring(EventData.TicketEncryptionType)
Stage 23: where
| where TicketEncryptionType == '0x17'
Stage 24: extend
| extend TicketOptions = tostring(EventData.TicketOptions)
Stage 25: where
| where TicketOptions == '0x40810000'
Stage 26: extend
| extend Status = tostring(EventData.Status)
Stage 27: where
| where Status == '0x0'
Stage 28: extend
| extend ServiceName = tostring(EventData.ServiceName)
Stage 29: where
| where ServiceName !contains "$" and ServiceName !contains "krbtgt"
Stage 30: extend
| extend TargetUserName = tostring(EventData.TargetUserName)
Stage 31: where
| where TargetUserName !contains "$@" and TargetUserName !contains ServiceName
Stage 32: extend
| extend ClientIPAddress = tostring(EventData.IpAddress)
Stage 33: where
| where TimeGenerated >= ago(endtime)
Stage 34: summarize
| summarize min(TimeGenerated), max(TimeGenerated), ServiceNameCountPrev1h = dcount(ServiceName), ServiceNameSet1h = makeset(ServiceName)
by Computer, TargetUserName, TargetDomainName, ClientIPAddress, TicketOptions, TicketEncryptionType, Status
Stage 35: join (negated)
| join kind=leftanti
(
Kerbevent23h
) on TargetUserName, TargetDomainName
Stage 36: where
| where ServiceNameCountPrev1h > prev1hThreshold
Stage 37: project
| project StartTime = min_TimeGenerated, EndTime = max_TimeGenerated, TargetUserName, Computer, ClientIPAddress, TicketOptions,
TicketEncryptionType, Status, ServiceNameCountPrev1h, ServiceNameSet1h, TargetDomainName
Stage 38: extend (3 consecutive steps)
| extend HostName = tostring(split(Computer, ".")[0]), DomainIndex = toint(indexof(Computer, '.'))
| extend HostNameDomain = iff(DomainIndex != -1, substring(Computer, DomainIndex + 1), Computer)
| extend TargetAccount = strcat(TargetDomainName, "\\", TargetUserName)
Stage 39: project-away
| project-away DomainIndex
Exclusions
Top-level NOT(...) conjuncts: predicates this rule actively suppresses.
| Field | Kind | Excluded values |
|---|---|---|
ServiceName | contains | $ |
ServiceName | contains | krbtgt |
TargetUserName | contains | $@ |
TargetUserName | contains | ServiceName |
ServiceName | contains | $ |
ServiceName | contains | krbtgt |
TargetUserName | contains | $@ |
TargetUserName | contains | ServiceName |
EventData | match | 0x17 |
EventData | match | 0x40810000 |
EventData | match | krbtgt |
EventID | eq | 4769 |
ServiceNameCountPrev23h | lt | 4 |
Status | eq | 0x0 |
TicketEncryptionType | eq | 0x17 |
TicketOptions | eq | 0x40810000 |
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
EventData | match |
|
EventID | eq |
|
ServiceName | contains |
|
ServiceNameCountPrev1h | gt |
|
Status | eq |
|
TargetUserName | contains |
|
TicketEncryptionType | eq |
|
TicketOptions | eq |
|
Output fields
Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.
| Field | Source |
|---|---|
ClientIPAddress | project |
Computer | project |
EndTime | project |
ServiceNameCountPrev1h | project |
ServiceNameSet1h | project |
StartTime | project |
Status | project |
TargetDomainName | project |
TargetUserName | project |
TicketEncryptionType | project |
TicketOptions | project |
HostName | extend |
HostNameDomain | extend |
TargetAccount | extend |