Shadow Credentials
Shadow Credentials abuses Key Trust: a user or computer’s msDS-KeyCredentialLink attribute holds
public keys used for certificate authentication (PKINIT), the mechanism behind Windows Hello for
Business. If an attacker can write that attribute on a target account, they add their own key pair
and then authenticate via PKINIT as that account, obtaining its TGT and NT hash —without changing
its password or leaving the account unusable. The broken invariant is that write control over an
account equals being able to authenticate as it.
flowchart LR
A["Attacker with write access<br/>over the victim"] -->|"adds their public key"| K["victim's<br/>msDS-KeyCredentialLink"]
A -->|"PKINIT with their private key"| DC[Domain Controller]
DC -->|"victim's TGT + NT hash"| A
A -->|"removes the key"| K
Threat model
Section titled “Threat model”- Who attacks: someone with write access to the victim’s
msDS-KeyCredentialLink(GenericAll,GenericWrite,WritePropertyover that attribute,WriteOwner/WriteDACLto grant it) —exactly the kind of edge BloodHound reveals by the dozen (AddKeyCredentialLink). - What it breaks: the separation between “administer an object” and “be that object.” Writing an authentication key into the account is, in effect, impersonating it.
- What it gains: the victim’s TGT and NT hash, stealthily and reversibly: you add the key, authenticate, and remove it; the legitimate user never notices.
- Versus a password reset: resetting is noisy, breaks the user’s access and is obvious. Shadow Credentials isn’t. That’s why it’s the preferred path when you have write access over an account.
Prerequisites
Section titled “Prerequisites”- A DC with PKINIT/Key Trust support (DC 2016+). It doesn’t require a vulnerable AD CS template like the ESCs: the domain’s Key Trust is enough (though having AD CS is the norm).
- Write access over the victim’s
msDS-KeyCredentialLink, discovered in enumeration or in BloodHound.
Anatomy
Section titled “Anatomy”What a Key Credential is
Section titled “What a Key Credential is”Each msDS-KeyCredentialLink entry associates a public key with the account for certificate
authentication. Windows Hello for Business uses it legitimately: on enrollment, the TPM generates the
pair and the public key is stored there. The attacker does the same with a pair they control.
UnPAC-the-hash
Section titled “UnPAC-the-hash”After authenticating via PKINIT, the attacker doesn’t just have the TGT: the PKINIT exchange also returns the victim’s NT hash (UnPAC-the-hash). That enables pass-the-hash even though the password stays unknown.
Red Team
Section titled “Red Team”Exploitation from Linux (Certipy)
Section titled “Exploitation from Linux (Certipy)”The most direct way: certipy shadow auto adds the key, does PKINIT, recovers the NT hash and cleans
the key in a single step.
certipy shadow auto -u 'jdoe@corp.local' -p 'Passw0rd!' -dc-ip 10.10.10.10 -account 'victim'Step by step, if you want control over each phase (add, list, remove, clear):
certipy shadow add -u 'jdoe@corp.local' -p 'Passw0rd!' -dc-ip 10.10.10.10 -account 'victim'certipy auth -pfx victim.pfx -dc-ip 10.10.10.10certipy shadow clear -u 'jdoe@corp.local' -p 'Passw0rd!' -dc-ip 10.10.10.10 -account 'victim'Alternative (pywhisker + PKINITtools)
Section titled “Alternative (pywhisker + PKINITtools)”pywhisker manages msDS-KeyCredentialLink entries (--action add/list/remove/clear) and
gettgtpkinit.py + getnthash.py do the PKINIT and UnPAC-the-hash. It’s the path when you don’t use
Certipy.
Chained with relay
Section titled “Chained with relay”If you arrive via NTLM relay to LDAP with the authentication of an account
that has write access over the victim, ntlmrelayx --shadow-credentials writes the attribute directly
during the relay.
Over computer accounts
Section titled “Over computer accounts”Shadow Credentials over a computer’s account gives its TGT; if that computer is a DC, it leads
to DCSync. It’s the natural outcome of a GenericWrite over a computer found in BloodHound, an
alternative to setting up RBCD (delegation).
Investigator workflow
Section titled “Investigator workflow”- BloodHound: do I have
AddKeyCredentialLink(or equivalent write) over any valuable account? certipy shadow autoover that account → NT hash and TGT.- Always clear the key (don’t leave the added entry).
- Chain: NT hash → pass-the-hash / lateral; if the victim is a DC → DCSync.
- Certipy (
shadow add/auto/clear): the whole flow from Linux. - pywhisker + PKINITtools (
gettgtpkinit.py,getnthash.py): modular alternative. - Whisker (C#): Windows equivalent.
- ntlmrelayx (
--shadow-credentials): write the attribute via relay.
Impact and chaining
Section titled “Impact and chaining”It turns a write edge into the victim’s TGT and NT hash without touching their password. Over a DC,
DCSync; over a privileged user, their full identity. Along with RBCD, it’s the standard way to monetize
GenericWrite/GenericAll.
Blue Team
Section titled “Blue Team”Detection
Section titled “Detection”- Event 5136 (directory object modification) with a WRITE on
msDS-KeyCredentialLink: the main signal. It requires directory change auditing enabled (SACL on the objects). - Event 4662 as an alternative if 5136 isn’t available.
- Blind spot: an account modifying its own
msDS-KeyCredentialLinkis usually legitimate WHfB (enrollment). Detections exclude the “source = object” case, so watch mostly for writes by one account over another. - Legitimate false positives: Windows Hello for Business, Azure AD Connect and ADFS provisioning write this attribute. Correlate with the expected flow (who writes, over what object class, in what window).
Telemetry and sources
Section titled “Telemetry and sources”- Directory Service Changes auditing on the DCs, with a SACL on
msDS-KeyCredentialLink. - Sigma/Elastic-style rules on 5136 +
AttributeLDAPDisplayName = msDS-KeyCredentialLink.
Hardening
Section titled “Hardening”- Restrict writing of
msDS-KeyCredentialLinkto dedicated identity-management accounts; review and trim theAddKeyCredentialLinkedges BloodHound shows. - Protect Tier 0 accounts: no low-privilege principal should have write access over a DC or a Domain Admin.
- Keep 5136 auditing active over the attribute on all DCs.
Response
Section titled “Response”On a suspicious write: remove the added Key Credential, investigate which account wrote it and with
what permission, rotate the victim’s credentials (and, if it’s a DC, consider rotating krbtgt) and
fix the write edge that allowed it.
CVEs and real cases
Section titled “CVEs and real cases”- Not a CVE: it’s an abuse of Key Trust’s design (MITRE T1556.006), described by Elad Shamir in “Shadow Credentials” (SpecterOps, 2021).
- It became the stealthy alternative to password reset and RBCD for monetizing write access over accounts, and is built into Certipy, ntlmrelayx and BloodHound.
Test checklist
Section titled “Test checklist”- Do I have write access over some valuable account’s
msDS-KeyCredentialLink(BloodHound)? - DC with PKINIT/Key Trust support (2016+)?
-
certipy shadow auto→ victim’s TGT and NT hash? - Added key removed when done?
- Write access over a computer/DC leading to DCSync?
- Blue: 5136 auditing over
msDS-KeyCredentialLinkon? Excludes only the “source = object” case?