
PrintNightmare
PrintNightmare (CVE-2021-34527 and CVE-2021-1675) in the Windows Print Spooler, covering remote code execution, local privilege escalation, detection and mitigation.
Description
PrintNightmare is a bug in the Windows Print Spooler service (spoolsv.exe). The name covers two CVEs: CVE-2021-34527 (remote code execution) and CVE-2021-1675 (local privilege escalation). Both come from how the spooler handles printer driver installation.
The flaw sits in RpcAddPrinterDriverEx(). A caller can make the spooler load a driver DLL it supplies, without the authorization and validation checks that should apply. The spooler runs as SYSTEM, so the DLL does too.
In Active Directory, a spooler running on a domain controller or print server turns this into lateral movement and possibly domain compromise. Microsoft scored it CVSS 8.8.
Still exploitable after the first patch
PrintNightmare works locally and remotely and gives SYSTEM. The first patches left hosts exploitable when Point and Print policy allowed driver installs without elevation.
Impact
- Remote code execution as SYSTEM on any host where the spooler is reachable.
- Local privilege escalation from a low-privileged user to SYSTEM.
- Lateral movement to other domain-joined machines from a compromised host.
- A path to domain compromise through print servers or domain controllers that run the spooler.
- Persistence through a malicious printer driver left installed.
- SYSTEM access means cached credentials and tokens are readable.
The spooler runs by default on most Windows systems, domain controllers included, which is why this one hit so widely.
Technical details
CVE-2021-34527 (remote code execution)
- Lets a remote attacker install a malicious printer driver.
- Calls
RpcAddPrinterDriverEx()over the MS-RPRN protocol. - Works remotely whenever the Print Spooler service is reachable.
CVE-2021-1675 (local privilege escalation)
- Lets a local user install a printer driver and escalate privileges.
- Gets around driver signing requirements through Point and Print.
- Abuses trust relationships in Active Directory environments.
Common attack scenarios
- Remote exploitation of a network-reachable spooler.
- Local exploitation by an authenticated low-privileged user.
- Lateral movement through domain trust relationships.
- A compromised print server used to reach the rest of the domain.
Detection
Event logs:
- Event ID 316 in Microsoft-Windows-PrintService/Operational (a printer driver was added or updated). The Operational log is off by default.
- Event ID 808 in Microsoft-Windows-PrintService/Admin ("The print spooler failed to load a plug-in module"), logged when the spooler cannot load the DLL it was pointed at.
- Unusual print activity in the System and Security logs.
Network:
- RPC traffic to the spooler (MS-RPRN) from hosts that have no reason to send it.
- Unexpected SMB connections on TCP 445 used to fetch driver files.
- Print service enumeration from workstations.
File system:
- New files in
C:\Windows\System32\spool\drivers\. - Unfamiliar DLLs in printer driver directories.
- New or modified files in print processor locations.
Process:
- Child processes of
spoolsv.exe. - Outbound network connections from the spooler.
- Abnormal memory allocation in the spooler process.
Remediation
Steps in order of priority.
Immediate actions
Apply the Microsoft security updates:
- Install KB5004945 (July 2021) and later updates.
- Check the patch is present with
Get-HotFix. - Test patches outside production first.
If the host does not need to print, disable the Print Spooler service:
Stop-Service -Name Spooler -Force
Set-Service -Name Spooler -StartupType DisabledRegistry mitigations
Lock down Point and Print so users cannot install drivers silently:
[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint]
"NoWarningNoElevationOnInstall"=dword:00000000
"UpdatePromptSettings"=dword:00000000
"NoWarningNoElevationOnUpdate"=dword:00000000
"TrustedServers"=dword:00000001
"ServerList"="print.company.com"Network controls
Restrict who can reach the spooler:
- Block TCP 445 (SMB) and 135 (RPC Endpoint Mapper) where you can.
- Put print servers in their own network segment.
- Use Windows Firewall to limit access to the spooler.
Watch RPC traffic:
- Monitor for MS-RPRN abuse.
- Alert on print service enumeration.
Active Directory hardening
Limit print service permissions:
- Remove the "Print Operators" group from domain controllers.
- Restrict printer installation rights to administrators.
- Audit the printer drivers already installed.
Group Policy:
- Deploy Point and Print restrictions through GPO.
- Disable the "Allow users to install printer drivers" policy.
- Enable "Only use Package Point and Print".
Detection and monitoring
Turn on the audit policies:
auditpol /set /subcategory:"Other System Events" /success:enable /failure:enable
auditpol /set /subcategory:"Security System Extension" /success:enable /failure:enableCheck drivers and service state from PowerShell:
# Check for suspicious printer drivers
Get-PrinterDriver | Where-Object {$_.InfPath -like "*temp*" -or $_.InfPath -like "*users*"}
# Monitor Print Spooler service status
Get-Service Spooler | Select-Object Name, Status, StartTypeVerification
To confirm the fix took:
Patch present:
Get-HotFix | Where-Object {$_.HotFixID -eq "KB5004945"}Service state:
Get-Service Spooler | Format-List Name, Status, StartTypePoint and Print policy values:
Get-ItemProperty "HKLM:\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint"Installed drivers:
Get-PrinterDriver | Select-Object Name, InfPath, DriverVersionExploitation examples
Remote exploitation (CVE-2021-34527)
Tools used for remote exploitation:
- Impacket's
rpcdump.pyand custom RPC clients. - Metasploit modules for PrintNightmare.
- PowerShell scripts that call the RPC functions directly.
Local privilege escalation (CVE-2021-1675)
Local exploitation usually goes like this:
- Install a malicious printer driver as a low-privileged user.
- Use Point and Print to bypass UAC.
- The payload runs as SYSTEM.
Authorized testing only
Run these only against systems you are authorized to test.
References
MITRE ATT&CK techniques
- T1068 - Exploitation for Privilege Escalation - Privilege escalation via exploitation
- T1210 - Exploitation of Remote Services - Remote code execution
- T1547 - Boot or Logon Autostart Execution - Persistence via print drivers
Vulnerabilities
- CVE-2021-34527 - PrintNightmare RCE - Remote code execution variant
- CVE-2021-1675 - Print Spooler EoP - Local privilege escalation
- CWE-269 - Improper Privilege Management - Weakness classification
Microsoft documentation
- Microsoft guidance for CVE-2021-34527 - Official guidance
Tools
- Impacket CVE-2021-1675 - Python PrintNightmare exploit
Next steps
If you find PrintNightmare during a test:
- Check how many hosts expose the spooler across the environment.
- Recommend patching all Windows systems, domain controllers first.
- Review domain trust relationships and printer deployment policies.
Print Operators Group Exploitation and Defense
Print Operators privilege escalation on Windows. Abuse SeLoadDriverPrivilege to load a vulnerable driver such as Capcom.sys and run code as SYSTEM, then detect and block it.
Windows Scheduled Tasks for Privilege Escalation and Persistence
Exploiting and abusing Windows Task Scheduler for privilege escalation, lateral movement, and persistent access on compromised systems.