HiveNightmare (CVE-2021-36934)


HiveNightmare AKA SeriousSAM AKA CVE-2021-36934 is a Microsoft Windows vulnerability which affects Windows 10 and 11 starting with Windows 10 version 1809. This vulnerability allows for an attacker that has local access to any low level (non-administrator) account to perform a privilege escalation attack in order to elevate their privileges or harvest credentials and pivot laterally within a corporate environment.

Exploitation is possible due to a misconfiguration of permissions as it relates to the Windows registry hives. While a system is in use, these hives may not be accessed directly even if the user has permissions to do so. Even so, if the Volume Copy Shadow Service (VSCS) is enabled and there are restore points created, an attacker may leverage these weak permissions within the shadow copy of the hives–gaining unauthorized access.



  • System Protection must be turned on
  • At least one restore point must be created
  • “BUILTIN\Users” must have READ and EXECUTE permissions on the hives

N.B. The password hashes recovered are dependent on the age of the restore point.
For example, if an administrator changed their password in between the cadence of taking restore points, the recovered hash will not be updated or valid for subsequent attacks.

Before going through the exploitation phase, we must verify that all pre-requisites have been met. By running the “icacls” Windows-native tool, the permissions are displayed for groups on the current system. As seen below in Figure 1, “BUILTIN\Users” has the necessary READ and EXECUTE permissions on the SAM hive.

Next, we need to verify that System Protection is enabled and that there is at least one restore point created. With local access, this can be done easily via the Windows GUI.

Figure 2. Checking the status of System Protection

Now that all pre-requisites have been satisfied, we are ready to move onto the exploitation phase for this vulnerability. This system is exploitable!


For this exercise, we will be using a HiveNightmare proof-of-concept created by “GossiTheDog” which can be found via their GitHub page:

For those who do not wish to download and compile the binary themselves, there is a direct download link for the latest version of the executable which is located here:

Using whatever method desired, download a copy of the HiveNightmare.exe binary to the victim system. Once downloaded, run the binary to obtain copies of the SAM, SYSTEM, and SECURITY hives from the restore point. If there are many restore points, an integer can be passed as an argument to increase the number searched.

Figure 3. Running the HiveNightmare binary to obtain hives

After obtaining a copy of the hives from VSCS, we will exfiltrate these files back to our attacker system and proceed to extract the password hashes. While running “” on our attacker system, the “copy” command is used to move the files. This is seen below in Figures 4 and 5, respectively. This spins up an SMB share that is used to copy files back and forth.

Figure 4. Running to allow for sending and receiving files via SMB

Depending on the available or allowed versions of the protocol negotiated, the additional “-smb2support” flag may need to be used.

Figure 5. Using the copy command to exfiltrate the hive copies

Finally, these three hive files can be used with the “” tool to extract the password hashes and secrets as seen below in Figure 6.

Figure 6. Extracting the password hashes from the hive files

At this point we have completed the exploitation for this vulnerability as the goal was to gain unauthorized access to the hives and then extract the password hashes. In the next section, we will go through the Post-Exploitation phase where we will use the password hashes to escalate our privileges and own the system.


Now that we have the password hashes, we can use them to login to the victim system as the corresponding user(s). We can use a password cracking utility such as “john” or “hashcat” to crack the hash to obtain the cleartext password and login. This is seen below in Figure 7.

Figure 7. Using john with the rockyou.txt wordlist to crack the hashes

We can now use the credential pairs and login as these users. It’s worth mentioning that this is a lab environment and the passwords were purposely selected from this wordlist for the demonstration. So what happens if the password policy is strong and the password doesn’t reside in any known wordlist?

We will need to leverage a different kind of attack: Pass-the-Hash (PtH).

It is still possible to authenticate as a user without knowing the password if the attacker possesses the correct NTLM hash. This can be passed to the victim system in place of plaintext credentials. Taking the LM:NTLM hash of the “Administrator” user, the attacker is able to use the pass-the-hash technique and achieve elevated access on the victim system.

Figure 8. Using the tool to perform a PtH attack

We are now running within the context of “NT AUTHORITY\SYSTEM”!

Figure 9. The attacker elevates their access to “NT AUTHORITY\SYSTEM”


At the time of this post, there are currently no official patches released for this vulnerability. There is, however, a workaround currently being implemented until one is released.

In order to temporarily mitigate this vulnerability, two things must be done:

  1. All system restore points must be deleted
  2. The permissions to the “C:\Windows\System32\Config\” directory and files must be limited via the following command: icacls C:\Windows\System32\Config\*.* /inheritance:e

Once, these steps have been taken, a new system restore point may be created. It is also noteworthy that other applications which use VSCS may encounter issues depending on functionality and requirements.

Published by nop5L3D

Persistent, enthusiastic, and honest. I am a security professional and aspiring Penetration Tester interested in all things within the offensive realm of cybersecurity.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: