Credential theft is part of almost all attacks within a network, and one of the most widely known forms of credential stealing is surrounding clear-text credentials by accessing lsass.exe. However, this is only a piece of the bigger picture of the Windows credential model. In Part 1 of the Credential Dumping Series, I took a closer look at vulnerabilities within Windows authentication and credential management and explained why these are prime targets for attackers; in this post, I’ll walk you through some of the protective measures your organization can take to mitigate Windows credential theft.

Disable Clear-Text Passwords In Memory From WDigest

With an offensive objective in mind, what attacker wouldn’t want to get their hands on cleartext passwords? For older hosts running Windows 7, 8, Server 2008, and Server 2012, a key configuration that enables someone to achieve cleartext passwords is not disabled by default.

The reason clear-text credentials can be pulled from Local Security Authority Subsystem Service (LSASS) is generally because of WDigest. WDigest is a now legacy challenge/response protocol that was used in Windows Server 2003 for LDAP and web authentication. The security concern with this protocol is that it stores the clear-text password in memory to be used during the session.

WDigest has been disabled by default in Windows 8.1, Server 2012 R2, and all operating systems thereafter. For older hosts, such as Windows 7, 8, Server 2008, and Server 2012 this behavior is not enabled by default.

To mitigate this risk, Microsoft issued a patch in KB2871997. When the patch is installed, the legacy hosts have the ability to choose how WDigest credentials will be stored.

When the value of ‘0’ is applied to the UseLogonCredential registry under the subkey below, WDigest will not store credentials in memory. Conversely, when the value of this subkey is ‘1’, WDigest will store credentials in memory. It is, for obvious reasons, best practice to ensure this value is set to ‘0’. It is also not uncommon for malicious actors to modify the value of UseLogonCredential back to ‘1’ in an attempt to gain clear-text credentials from LSASS.

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\WDigest 

NTLM and other hashes will still be present in LSASS by just disabling WDigest, which can still be used for movement, but they are not as versatile as a clear-text password.

Things to Consider: If you suspect that credential material has been stolen from LSASS, check this registry key to better determine if clear-text passwords could have been stolen from WDigest.

Prevent LSAAS Dump By Enabling Protected Mode On LSASS

On Windows operating systems starting with 8.1, LSASS can be configured to run in “protected mode.” This means that only other protected-mode processes can call LSASS. In addition, a debugger cannot be attached to LSASS when it is running as a protected process.

How to Activate LSAAS Protected Mode

To enable LSASS in protected mode, the following registry key needs to be updated to ‘1’: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\RunAsPPL

How to activate LSAAS protected mode by editing DWORD

A reboot will be needed for the changes to take effect.

After a reboot, we can see the following behaviors when attempting to dump credential material:

Mimikatz

Screenshot of Mimikatz showing error upon dump attempt

Procdump

Windows PowerShell screenshot showing "access denied" when opening LSAAS.exe is attempted

Task Manager

Screenshot showing "Access denied" window when attempting to access lsaas.exe via the task manager

Functionality Concerns

A protected process must meet the following criteria:

  • Signature Verification
    • Protected mode requires any process loaded into LSA to have a digital signature by Microsoft. Any unsigned or invalidly signed program will not be able to load within LSA
    • Drivers must be signed with the WHQL Certification
    • Adhere to the Microsoft Security Development Lifecycle process guidance

In short, if a third-party authentication application is using LSASS (such as an authentication tool), the functionality could break if it does not adhere to the above criteria.

Protected Users Security Group

Introduced within Windows 2012 R2 domain controllers, the Protected Users Security Group was designed to have non-configurable protections applied to their accounts. When a user is added to this domain group, they acquire the following protections:

  • Credential delegation (CredSSP) does not cache the user’s plain text credentials, regardless of the Group Policy settings in place
  • WDigest will not cache the plain text credentials
  • NTLM will not cache plain text credentials
  • Kerberos will no longer create DES or RC4 keys. Plain text credentials or long-term keys will not be cached after the TGT is acquired
  • A cached verifier (cached credential) is not created on sign-in or unlock. Offline sign-in is not supported

Within the context of the domain controller, the following protections are given:

  • The user is no longer able to authenticate with NTLM authentication
    • Can only authenticate with Kerberos
  • DES and RC4 encryption are not supported in Kerberos pre-authentication
  • Unable to be delegated with unconstrained or constrained delegation
  • Unable to renew the Kerberos TGT beyond 4 hours
    • Need to re-enter credentials and obtain a new TGT every 4 hours

This group is available by default in all Windows systems after 8.1 and Server 2012 R2. Microsoft Security Advisory 2871997 added support for those hosts running Windows 7, Server 2008 R2, and Windows Server 2012.

From an attacker’s perspective, this means that credential material will no longer be stored in LSASS for these users, and pass-the-hash style attacks are no longer effective as NTLM have been disabled.

Functionality Concerns

According to Microsoft, accounts for services and computers should never be added to this group. Authentication for these users will always fail when they are in this group. The consequences of Kerberos-only authentication and the 4-hour TGT must also be considered for logins. Lack of cached credentials may cause issues when a domain controller is not available.

Accelerate LSASS Memory Clear

On Windows hosts after Windows 8.1 and Windows 10, the default behavior is to force clear logon credentials from memory 30 seconds after when a user logs off of their session. In Windows version previous to 8.1, this is not the default behavior.

In Windows update 2871997, Microsoft added the ability to change this behavior in Windows 7, Server 2008 R2, 8, Server 2012, RT. By modifying the following registry key after the update, you can adjust the seconds until the credentials are cleared after logoff:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\TokenLeakDetectDelaySecs

In addition, if security update 3126593 (MS16-014) is installed, this becomes the default behavior on the patched host.

Windows Credential Guard

Credential Guard was a functionality that was released for Windows 10 Enterprise and Windows Server 2016 and after. This protection is particularly interesting because it relies on virtualization-based security.

When Credential Guard is used, instead of storing credential secrets in the LSA memory space, the LSA process will communicate with an isolated LSA process which will store the secrets. This new isolated LSA process is protected by virtualization and is not accessible to the rest of the operating system. The virtualization is handled by a Hypervisor. A quick diagram is below of LSA implemented within Credential Guard.

Diagram of LSA implemented within Credential Guard

Credential Guard can be enabled through group policy, Microsoft Intune, within the registry, and with the Windows Defender Credential Guard hardware readiness tool.

Functionality Concerns

When credential guard is enabled, NTLMv1, MS-CHAPv2, Digest, and CredSSP cannot use the signed-in credentials. This breaks single sign-on (SSO) for these protocols. Applications can still prompt for credentials or use credentials stored in the Windows Vault, which are not protected by Credential Guard with the above protocols. Valuable credentials are recommended to not utilize these protocols when credential guard is enabled. If they must be used, Microsoft recommends implementing secondary credentials for the user.

Windows Credential Manager

Credential Manager is a tool that is built into Windows where users can store passwords to access network resources. In the following example, you can see an example of a stored password for a user to access “DomainController.company.com”:

Screenshot of Windows Credential Manager

Mimikatz also has the ability to pull passwords from this location:

Screenshot of mimikatz accessing passwords in credential manager

Within Group Policy, there is a way to disable this functionality. It can be found under:

Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options -> Network Access: Do not allow storage of passwords and credentials for network authentication

Local Group Policy Editor: Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options -> Network Access: Do not allow storage of passwords and credentials for network authentication

Screenshot showing "Local Security Setting" toggled to "enabled"

Now, when a user tried to save a password, the system will not allow the action. This will not, however, remove credentials which are already stored.

Screenshot of Credential Manager error "Unable to save credentials"

Things to Consider: If possible, when a suspected credential dump has occurred, see if users have the ability to store passwords within credential manager, and determine if they are.

Limiting Credential Caching

By default, within Windows systems, the cached credentials for the last 10 domain users is stored within the registry at HKEY_LOCAL_MACHINE\SECURITY\Cache.

Within the local policy, it is possible to limit the number of users that will be cached to the system. This setting can be found under Local Security Policy -> Local Policies -> Security Options -> Interactive Logon: Number of previous logons to cache (in case domain controller is not available).

Local Security Policy -> Local Policies -> Security Options -> Interactive Logon: Number of previous logons to cache (in case domain controller is not available)

Local Security Setting dialog box with drop-down to limit cache to certain number of logons

Functionality Concerns

The threshold for this setting needs to be carefully considered in the context of the machine’s usage and its domain context. For those servers which are permanently on the domain, this can be set to low, maybe even 0 (assuming the risk of domain outages). For user workstations, this may not be desirable – if there is no Internet or VPN connection, the user will be unable to access their workstation if there are no cached credentials in place.

Things to Consider: When a potential credential dump has occurred, check this registry key to see what the number of cached users is. See which users fall into that threshold and reset passwords as needed.

Conclusion

In conclusion, in the Windows credential model, wherever there are stored credential materials, there are also risks. Microsoft has implemented many protections in recent years to further protect these secrets, but all security comes with a cost to convenience. It is important to weigh the pros and cons of each protection to decide what is best for your network. Always keep hosts up to date and on a regular patch schedule to receive the automatic protections built in from Microsoft.

How To Prevent Credential Theft In Your Organization

While there is no one-size-fits-all solution for every company, consider the following points when evaluating credential protections. Always consider any functionality concerns mentioned above and test before deploying a protection to your production environment.

  1. Ensure all legacy hosts have the Microsoft patches installed to enable additional safety features
  2. If not already enabled/default behavior, ensure cleartext passwords are disabled in memory for WDigest
  3. If possible, with your applications, run LSASS in protected mode to prevent unauthorized access
  4. If possible, put privileged users who are not service or machine accounts in the protected users security group
  5. Ensure LSASS memory clearing is set within TokenLeakDetectDelaySecs. The default in Windows 8.1+ is 30 seconds
  6. If possible, based on SSO needs and operating system, enable Credential Guard to isolate the LSA process
  7. If not needed for business use, disable the use of Windows Credential Manager
  8. Limit or disable credential caching on any host where it is not needed. Keep in mind, credential caching is recommended on workstations/laptops that require domain credentials to log in. Set levels appropriate to your risk profile

Mitigating Credential Theft With ReliaQuest GreyMatter

GreyMatter, ReliaQuest’s security operations platform, helps mitigate credential stealing by integrating and normalizing data from disparate technologies including SIEM, EDR, multi-cloud, and point tools to provide a unified view for detecting, investigating, and threat hunting  – all within the GreyMatter UI.  Through GreyMatter, security teams can leverage custom detection content to identify and investigate activity that may indicate credential theft.  With an integrated threat hunting feature, GreyMatter allows for a security teams to proactively search over large periods of time for suspicious LSASS activity on an EDR. By automating across the security lifecycle, ReliaQuest GreyMatter aggregates, de-dupes and enriches alerts from across your security ecosystem to serve up a research package, providing analysts with all of the telemetry and recommendations they need, in one place, to prosecute and remediate threats.