Credential Theft

So we’ve figured out our logon types and have an unexpected but surprisingly loving relationship with the humble network logon. We are also appropriately wary of the untrusted workstation.

But relationships are hard, and your eyes and hands wander, and before you know it you’re back up to your old tricks, using interactive sessions like it’s no big deal and generally being a one-man (or woman) APT-enabler.

What sort of trouble can your dalliances get you into?

Cached Credential Theft

By default, any interactive logon to a domain-joined computer will generate a cached credential on the host. This allows the user to log on even if the domain controller is unavailable.

In an environment with reliable wired connections, this is likely unnecessary, but this functionality is critical for road warriors. Cached credentials are enabled by default.

The cached credentials are stored in one of two formats. Windows XP and earlier use MS-CACHE v1, while Vista and beyond use MS-CACHE v2.

In the MS-CACHE v2 formula, the 10240 represents the iteration count of the PBKDF2 algorithm. This makes it very computationally expensive to generate the hash. On identical hardware, the hash computations/second for MS-CACHE v1 can be measured in tens of millions, MS-CACHE v2 in the hundreds, as in 10^2. Cached credential theft is not a good thing, but it could get a lot worse.

Like cleartext credential theft, for example.

Cleartext Credential Theft

When Windows XP xploded (ha! hahaha!) on the scene circa 2001, it brought with it WDigest.dll, the charming and harmless Windows implementation of a digest authentication protocol for use with HTTP for single signon-y things.

The details of WDigest aren’t super important to what we’re talking about here, but just know that it existed to make life a bit easier and a bit more secure for Windows users accessing web content. Think SSO combined with challenge/response mechanism similar to NTLM and you’re barking up the right tree.

All good so far.

WDigest requires the user’s cleartext credentials, not the LM or NT hash, to perform its SSO functionality, which lsass.exe would then store, since that’s what it does.

So, since about 2001, and especially since the release of tools such as Mimikatz and Windows Credential Editor (WCE), a user with administrator privileges on a system can retrieve the credentials for pretty much any user with an active interactive/service/batch session.

What’s the big deal? Administrators can do all the things. That’s what they do! Admin things! And if you’re already an administrator, what more could you want?

The big deal is that the administrator may just be administrator of the local system, while the sessions on the system could have domain-wide privileges.

This is about as bad as it gets from a I-effed-up-and-logged-onto-the-wrong-box-the-wrong-way perspective. For all intents and purposes, an attacker with your credentials is pretty much you. A notable exception to this is two-factor authentication, but even this has its limitations.

Luckily, Microsoft fixed this in Windows 2012 R2 and 8.1, and then backported the fix with KB2871997 in May of 2014. Unluckily for the 95% of Windows users who just install the damn patches without reading the damn patch notes, the fix wasn’t fully enabled by default. The path will prevent every SSP in LSASS with the exception of WDigest from storing cleartext credentials.

To prevent WDigest from storing cleartext, you need to set the following registry key: