Rapid7 Vulnerability & Exploit Database

CVE-2022-21999 SpoolFool Privesc

Back to Search

CVE-2022-21999 SpoolFool Privesc



The Windows Print Spooler has a privilege escalation vulnerability that can be leveraged to achieve code execution as SYSTEM. The `SpoolDirectory`, a configuration setting that holds the path that a printer's spooled jobs are sent to, is writable for all users, and it can be configured via `SetPrinterDataEx()` provided the caller has the `PRINTER_ACCESS_ADMINISTER` permission. If the `SpoolDirectory` path does not exist, it will be created once the print spooler reinitializes. Calling `SetPrinterDataEx()` with the `CopyFiles\` registry key will load the dll passed in as the `pData` argument, meaning that writing a dll to the `SpoolDirectory` location can be loaded by the print spooler. Using a directory junction and UNC path for the `SpoolDirectory`, the exploit writes a payload to `C:\Windows\System32\spool\drivers\x64\4` and loads it by calling `SetPrinterDataEx()`, resulting in code execution as SYSTEM.


  • Oliver Lyak
  • Shelby Pace






Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/windows/local/cve_2022_21999_spoolfool_privesc
msf exploit(cve_2022_21999_spoolfool_privesc) > show targets
msf exploit(cve_2022_21999_spoolfool_privesc) > set TARGET < target-id >
msf exploit(cve_2022_21999_spoolfool_privesc) > show options
    ...show and set options...
msf exploit(cve_2022_21999_spoolfool_privesc) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security