Any user account in the domain is enough for Kerberoasting; the attack doesn’t generate even a single failed sign-in attempt. The attacker requests Kerberos tickets encrypted with a key derived from the service account’s password, then tries to crack the password offline on their own hardware. AS-REP roasting applies the same idea to accounts with pre-authentication turned off. Below we explain the mechanics of both attacks from a defender’s point of view, the inventory of risky accounts, protection with gMSA and AES, and detection from event logs.
The Kerberos ticket flow and the logic of the attack
In Kerberos (RFC 4120), the user first gets a TGT from the Key Distribution Center (KDC; the domain controller in AD) (AS-REQ/AS-REP). When they want to access a service, they present the TGT and request a service ticket for that service’s Service Principal Name (SPN) (TGS-REQ/TGS-REP). The encrypted part of the service ticket is encrypted with the long-term key of the account the SPN is registered to; this key is derived from that account’s password.
By protocol design, the KDC issues a ticket for any SPN to any user with a valid TGT; checking whether the user is authorized for that service is the service’s job. The attacker gets the ticket, never connects to the service, and tries to decrypt the encrypted part with password guesses. Because a ticket decrypted with the right key has a valid structure, the attacker knows the guess was right. On the DC, this looks like an ordinary ticket request; account lockout and failed sign-in counters never kick in. A lockout policy is useless here.
Two factors decide success: the strength of the password and the encryption type. With RC4-HMAC (etype 23), the key is the account’s NT hash directly and there is no salt; guess attempts are very fast. AES (etypes 17 and 18) keys, on the other hand, are derived with a salt and PBKDF2 using many iterations, making each guess noticeably more expensive. Still, a weak password is cracked with AES too. The encryption type extends the time; it doesn’t fix a weak password.
The difference between Kerberoasting and AS-REP roasting
| Feature | Kerberoasting | AS-REP roasting |
|---|---|---|
| Target account | User accounts with an SPN | Accounts with pre-authentication turned off |
| Attacker requirement | Any valid domain account | The account name is enough |
| Data cracked | The service ticket in the TGS-REP | The encrypted part in the AS-REP |
| DC event | 4769 | 4768 (pre-authentication type 0) |
| Basic measure | gMSA or a long random password, AES | Turning pre-authentication on |
Normally the client proves its identity by encrypting a timestamp with its own key in the AS-REQ (pre-authentication). If “Do not require Kerberos preauthentication” is checked on the account, the KDC returns an AS-REP without asking for this proof, and part of the response is encrypted with the user’s key. In the field, we usually find this setting turned on years ago for an old application or a Unix integration and then forgotten. Nobody remembers it.
Computer accounts carry SPNs too, but their passwords are automatically generated long random values and change every 30 days by default. That’s why the practical target is user accounts with an SPN.
Inventory of risky accounts (PowerShell)
Defense starts with seeing the list the attacker will see before they do. The queries below use the ActiveDirectory module to list user accounts with SPNs and accounts with pre-authentication turned off:
Import-Module ActiveDirectory
# User accounts with an SPN (excluding krbtgt)
Get-ADUser -Filter 'ServicePrincipalName -like "*"' -Properties ServicePrincipalName,
PasswordLastSet, AdminCount, 'msDS-SupportedEncryptionTypes', Enabled |
Where-Object SamAccountName -ne 'krbtgt' |
Select-Object SamAccountName, Enabled, AdminCount, PasswordLastSet,
@{n='EncTypes';e={$_.'msDS-SupportedEncryptionTypes'}},
@{n='SPN';e={$_.ServicePrincipalName -join '; '}} |
Sort-Object PasswordLastSet | Format-Table -AutoSize
# Accounts with Kerberos pre-authentication turned off
Get-ADUser -Filter 'DoesNotRequirePreAuth -eq $true' -Properties DoesNotRequirePreAuth |
Select-Object SamAccountName, Enabled, DistinguishedName
Ask four questions to prioritize: Is the account in a privileged group (AdminCount 1)? When was its password last changed? Is msDS-SupportedEncryptionTypes empty, or does it include RC4? Does the SPN still belong to a running service? A privileged account with an SPN whose password hasn’t changed in years goes to the top of the list; why such an account is privileged at all should also be questioned from the perspective of the AD tier model.
For accounts with pre-authentication turned off, the fix is usually simple: turn the setting off (Set-ADAccountControl -Identity account -DoesNotRequirePreAuth $false) and test the related application. If an exception is really needed, the account’s password must be very long and random, and the exception must be recorded.
Protection with gMSA and long passwords
The most lasting solution is to move service accounts to Group Managed Service Accounts (gMSA). A gMSA password is a long random value generated by AD and changes on its own every 30 days by default; no human knows this password, and cracking it with a dictionary attack isn’t practical. A gMSA is defined so that only authorized servers can retrieve the password:
# Once per forest: KDS root key (wait 10 hours for replication)
Add-KdsRootKey -EffectiveImmediately
# Create the gMSA; only the SQL servers group can retrieve the password
New-ADServiceAccount -Name gmsa-sql01 -DNSHostName gmsa-sql01.corp.local `
-PrincipalsAllowedToRetrieveManagedPassword "SQL-Servers" `
-KerberosEncryptionType AES128,AES256 `
-ServicePrincipalNames "MSSQLSvc/sql01.corp.local:1433"
# On the target server
Install-ADServiceAccount -Identity gmsa-sql01
Test-ADServiceAccount -Identity gmsa-sql01
Add-KdsRootKey -EffectiveImmediately creates the key right away, but before enabling a gMSA you wait 10 hours for the key to replicate to all DCs. Skipping this and trying to create a gMSA immediately is where first installations most often get stuck. In the service configuration, the account name is entered as CORP\gmsa-sql01$ and the password field is left empty. SQL Server, IIS application pools and scheduled tasks support gMSA; some third-party applications may not.
For accounts that can’t be moved to gMSA:
- The password should be long (a common recommendation is at least 25 characters) and randomly generated, and stored in a password vault.
- The password should be changed regularly and when the person responsible for the account leaves.
- The account should be removed from privileged groups and have rights only on the servers it needs.
- Unused SPNs should be removed; the SPN of a service that no longer runs is just attack surface.
Reducing RC4 use
Which encryption type the KDC chooses for a service ticket depends on the target account’s msDS-SupportedEncryptionTypes value and on domain settings. An account with the value 24 (0x18) supports only AES128 and AES256. To enforce AES for an account:
Set-ADUser -Identity svc-application -KerberosEncryptionType AES128,AES256
# If the password was set before AES keys were generated, it must be reset
Set-ADAccountPassword -Identity svc-application -Reset
For passwords set before the domain functional level was raised to 2008 and never changed since, AD may not have an AES key; moving these accounts to AES without changing the password causes authentication failures. Before the migration, watch the Ticket Encryption Type field in 4769 events on DCs, list the services that still receive RC4 (0x17) tickets and plan tests with the application owners. Microsoft has announced phased changes aimed at turning off RC4 use in Kerberos by default; follow the timeline and the required preparations in Microsoft’s current announcements.
Detection from event logs
For detection, the Account Logon > Audit Kerberos Service Ticket Operations and Audit Kerberos Authentication Service subcategories under Advanced Audit Policy must be turned on to record success events on domain controllers. If they’re off, there’s no data to detect anything with. The basic signals for Kerberoasting:
- A 4769 event with
TicketEncryptionType0x17 (RC4) where the service name isn’t a computer account (ending in$) or krbtgt; in environments that have moved to AES, this alone is a strong signal. - A single user requesting tickets for many different SPNs within a short time.
- Ticket requests from a user or workstation that normally never connects to that service.
For AS-REP roasting, look for a PreAuthType value of 0 in event 4768. The script below groups RC4 service ticket requests from the last 24 hours on a DC by user:
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4769;
StartTime=(Get-Date).AddHours(-24)} |
ForEach-Object {
$x = [xml]$_.ToXml(); $d = @{}
$x.Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }
[pscustomobject]$d
} |
Where-Object { $_.TicketEncryptionType -eq '0x17' -and
$_.ServiceName -notlike '*$' -and $_.ServiceName -ne 'krbtgt' } |
Group-Object TargetUserName |
Sort-Object Count -Descending |
Select-Object Count, Name
In production, this logic moves to the SIEM and events from all DCs are evaluated together; detection that looks at a single DC is blind on the day the request goes to another DC. Products such as Microsoft Defender for Identity also offer ready-made detections for this behavior.
Early warning with a decoy SPN
Weeding out false positives in 4769 events for real service accounts takes time. A complementary method is to set up a decoy account that no legitimate process will ever use:
- Create a user account with a realistic name (e.g. an old archive database service account), assign a very long random password, and don’t add it to any group.
- Add a convincing SPN to the account:
Set-ADUser -Identity svc-archivesql -ServicePrincipalNames @{Add='MSSQLSvc/sql-archive01.corp.local:1433'} - Define every 4769 event for this account as a high-priority alarm; no ticket is requested for this SPN for a legitimate reason.
- Also tie the 4768 (TGT request) and 4771 (pre-authentication failure) events generated on DCs for the account to the alarm; these show the attacker is trying the decoy account’s password.
Design the decoy account to appear in SPN enumeration but give no access to any real system. Checking whether this alarm fires during a penetration test is a practical way to verify that the detection chain works end to end. If the alarm doesn’t come, the chain is broken somewhere.
NTLM-based attacks are a separate topic, covered in the NTLM auditing and restriction article. To see how service account privileges combine into a path to domain admin, see the AD attack path analysis article. An assessment of the accounts with SPNs and the Kerberos configuration in your environment can be handled within an Active Directory security audit, and vault management of service account passwords within privileged access management.
Frequently asked questions
Does the attacker need administrator rights for Kerberoasting?
No. Any valid user account in the domain can request service tickets for accounts with SPNs. An ordinary user account compromised through phishing is enough to start the attack; defense relies on making service account passwords uncrackable and on setting up detection.
Does moving to AES prevent Kerberoasting completely?
No. AES makes each password guess much more expensive than with RC4, and an RC4 ticket request leaves a clear detection signal. But a weak or dictionary password is cracked from an AES-encrypted ticket too. The lasting solution is gMSA or very long random passwords.
Can gMSA be used with every application?
No. Windows services, SQL Server, IIS application pools and scheduled tasks support gMSA; some applications that want the password in a configuration file or run on non-Windows platforms don’t. For these accounts, a long random password, a password vault, regular rotation and least privilege are applied.
What should you do if 4769 events show lots of RC4 entries?
First report which service accounts receive RC4 tickets and from which clients those tickets are requested. Set the accounts’ msDS-SupportedEncryptionTypes value to AES, reset their passwords and test with the application owners. As RC4 entries decrease, the remaining RC4 requests become a stronger attack signal.