Browse learn

Kerberos Service Principal Names (SPNs)

Learn how Kerberos service principal names map services to accounts, how clients use them, and why duplicate or incorrect SPNs break authentication.

On this page

What is a Service Principal Name (SPN) in Kerberos?

A Service Principal Name (SPN) is a directory-unique identifier that enables secure, direct authentication to a networked service using the Kerberos protocol. Instead of relying on a service’s underlying account name or credentials, clients use the SPN to signal exactly which service instance they intend to access. The SPN acts as a Kerberos “handle,” binding a visible network service endpoint—such as a web server, SQL database, or LDAP directory—to the security principal (user, service, or computer account) authorized to operate it. This mapping allows the Key Distribution Center (KDC) to issue service tickets, providing efficient, passwordless authentication while abstracting sensitive credential details from clients and intermediaries.

SPNs are central to Kerberos. Without accurate SPN assignment, authentication requests cannot be reliably routed to the right account, breaking key security assumptions and often causing silent service failures. Both user and service (computer or managed service) accounts can have SPNs assigned, but correct assignment—matched to deployment and security context—is essential.

SPN Structure and Naming Constraints

The structure of SPNs is strictly governed by standards such as RFC 4120. The canonical format is:

text
serviceclass/hostname[:port][/servicename]
  • serviceclass: Identifies the protocol or service type (e.g., HTTP, LDAP, MSSQLSvc, HOST).
  • hostname: The DNS, NetBIOS, or fully qualified domain name where the service is running.
  • :port: Optional. Needed if the service listens on a non-default port (for example, SQL Server’s default is 1433).
  • /servicename: Rare; used only for distinguishing among logical instances or special services.

Typical, standard forms are:

  • HTTP/webapp.example.com
  • MSSQLSvc/sqlhost.example.com:1433
  • HOST/fileserver01

Most SPNs use only the service class and host components. The port and service name are used only when required to assure uniqueness—especially for multi-instance services or non-default port deployments.

Uniqueness across the directory is mandatory. No two accounts in the same Active Directory forest may publish the same SPN. Any ambiguity—even as subtle as differing only by case or port—prevents the KDC from resolving authentication requests, causing ticketing failures. SPNs must precisely reflect the network endpoint actually serving the intended service, or clients risk silent misrouting or denial.

SPNs in the Kerberos Authentication Flow

SPNs are fundamental to how Kerberos resolves service tickets:

  1. Client targets a networked service. The client composes (or receives from configuration) the service’s SPN.
  2. Client requests a service ticket. The client asks the KDC for a service ticket corresponding to the target SPN.
  3. KDC looks up the SPN. The KDC searches the directory for a unique account advertising the SPN.
  4. Ticket issued. The KDC encrypts a ticket with the account’s secret key and returns it to the client.
  5. Client presents ticket. The client sends the ticket to the service; the service uses its secret key to decrypt the ticket, validating both sides.

In this flow, the SPN relieves the client from needing to know which account actually runs the service. Moving a service to another server, changing its account, or scaling horizontally—all remain transparent to clients as long as the SPN mapping stays up to date.

Registering and Managing SPNs in Active Directory

SPN management in Active Directory determines the reliability and security of Kerberos authentication for both standard and custom services. SPNs are stored as multi-valued attributes on user or computer accounts.

Automatic vs. Manual SPN Assignment

  • Automatic: Many built-in and standard Windows services (such as HOST, LDAP, or computer-based services) auto-register the appropriate SPNs when the machine is joined to the domain, or when a service is installed. This automatic registration reduces manual errors for common cases.
  • Manual: Custom services, services running under user or managed service accounts, and multi-instance deployments usually require explicit, manual SPN registration. Failure to do so results in authentication failures or fallback to weaker protocols.

Tooling and Permissions

The primary tool for SPN management in Windows environments is the setspn command-line utility. Running setspn operations typically requires either Domain Admin rights or delegated control over the specific account object.

Key setspn Commands:

  • View existing SPNs for an account:

    setspn -L <accountname>
    

    Example:
    setspn -L svcMyApp
    Lists all SPNs registered on svcMyApp.

  • Add (register) a new SPN:

    setspn -A <spn> <accountname>
    

    Example:
    setspn -A HTTP/webapp.example.com svcWebApp
    Registers the SPN HTTP/webapp.example.com to the svcWebApp service account.

  • Remove a stale or incorrect SPN:

    setspn -D <spn> <accountname>
    

    Example:
    setspn -D MSSQLSvc/sqlhost.example.com:1433 DBAlice
    Removes the SPN from the user account DBAlice.

Practical registration scenarios:

  • Web server using dedicated service account:
    Service account svcWebApp runs IIS and needs Kerberos auth. Register:
    setspn -A HTTP/webapp.example.com svcWebApp

  • SQL Server instance on custom port:
    SQL service running as svcSQL on port 1440. Register:
    setspn -A MSSQLSvc/sqlhost.example.com:1440 svcSQL

  • Audit for possible duplicates before change:
    setspn -Q <spn>
    Example:
    setspn -Q HTTP/webapp.example.com
    Checks the directory for conflicting registrations.

Manual changes to SPNs should always involve auditing for existing assignments, and require communication with service owners and identity operations teams to prevent unintended authentication failures.

User SPN vs. Service SPN: Key Differences

SPNs may be associated with both service (computer or managed service) accounts and user accounts, with significant security and operational distinctions:

  • Service SPNs:
    Assigned to non-interactive accounts such as computer objects (SERVER01$) or managed service accounts (svcWebApp). This is the standard and recommended model. Services authenticate using SPNs bound to these accounts, minimizing exposure and simplifying credential policy enforcement.

  • User SPNs:
    Sometimes, particularly for legacy or third-party services, SPNs may be assigned to “normal” user accounts. This increases risk, as user accounts are often interactive, may have broader or accumulated privileges, and are more susceptible to weak password practices.

Examples:

  • A dedicated service account for a web application registers HTTP/webapp.example.com as a service SPN.
  • In rare cases, a legacy SQL database might register MSSQLSvc/sqlhost.example.com:1433 on a user account for compatibility with old deployment tools.

Implication: Assigning SPNs to user accounts is discouraged unless unavoidable. This spreads the attack surface and amplifies the consequences of compromised user credentials.

Troubleshooting SPN and Kerberos Issues

Most Kerberos authentication issues in Active Directory are caused by SPN misconfiguration. Key symptoms and troubleshooting methods include:

  • Duplicate SPNs:
    Multiple accounts publishing the same SPN causes ticket resolution failures at the KDC—users may experience silent authentication failures or unexpected fallback to NTLM.

  • Missing SPNs:
    If a required SPN is absent, the client cannot obtain a service ticket for the target; Kerberos authentication silently fails and may fall back or error out, causing ambiguous support situations.

  • Stale SPNs:
    Deprecated or unused SPNs left registered create ambiguity, potential security risks, or can cause legacy services to behave erratically.

Troubleshooting approach:

  • Always audit SPNs before making changes:
    setspn -Q <spn> (lists ownership and detects duplicates).
  • Use setspn -L <accountname> to review all SPNs on an account.
  • Monitor authentication logs and directory change events for errors or unusual patterns tied to ticket requests or SPN updates.
  • After any change, test the authentication flow from a client to confirm functionality.

Security Implications: SPN Mismanagement and Kerberoasting

Poor SPN practices can create serious security exposures in Active Directory environments:

  • Kerberoasting:
    Adversaries can request service tickets for any SPN published in the directory. If the corresponding account (especially a user account) has weak credentials, attackers can extract and crack the encrypted ticket offline to recover the password. This technique disproportionately targets accounts with user-assigned SPNs or service accounts lacking strong policies.

  • Broadened attack surface:
    Publishing SPNs on interactive or highly-privileged user accounts exposes critical credentials—sometimes domain administrators—to Kerberos-based privilege escalation.

Monitoring and Detection:
Administrators should take specific steps to detect signs of SPN misuse or attack:

  • Regularly audit SPN assignments for accidental or excessive expansion.
  • Monitor Active Directory event logs, specifically:
    • Service ticket requests for sensitive SPNs (e.g., Event ID 4769 in Windows Security log): Unexpected spikes or requests for rarely-used SPNs may indicate enumeration or Kerberoasting attempts.
    • Directory changes to SPN attributes (object modifications): Frequent or unauthorized SPN changes should trigger alerts.
  • Periodically review granted tickets and look for anomalous service ticket volume from user accounts.

Combining strong credential policies with rigorous SPN monitoring is essential for mitigating Kerberoasting risk.

Best Practices and Warnings for SPN Management

Prudent SPN management greatly reduces both authentication failures and security risks.

  • Uniqueness is not optional: Ensure each SPN is registered to only one account across the forest.
  • Minimize user-assigned SPNs: Where possible, use non-interactive service or managed service accounts for SPN registration.
  • Strong credentials required: Enforce complex password or key policies for all accounts holding SPNs.
  • Audit and clean up: Remove stale, unused, or migrated SPNs as part of routine service lifecycle operations.

Warning:
SPN changes—or even audits—should be planned and coordinated with directory, service, and identity operations teams. Uncoordinated changes almost always cause silent or partial outages for live authentication flows, and can lead to hours-long disruptions before diagnosis.

  • Test after change: Validate client authentication to each affected service after SPN updates to ensure service continuity.
  • Continuous monitoring: Watch for sudden spikes in service ticket requests (possible attack) or unauthorized modifications to SPN attributes.
  • Document assignments: Keep a record of all SPN-to-account mappings for core and custom services to aid future troubleshooting.

Failure to follow these practices leads to difficult-to-debug outages, silent security holes, and expensive incident response. SPN handling is a foundational identity and security discipline for any organization using Kerberos-backed authentication.

Sources