Active Directory Series

👤 A Top 1% Hands-On: Reproducing the Shadow Credentials Attack Abusing msDS-KeyCredentialLink Yourself — Impersonating a Target Without Ever Knowing Its Password

Introduction

This article is part of the Top 1% Series Complete Article Guide, and article 43.3 in the Active Directory Series.

Prerequisite Knowledge

Getting the Big Picture

msDS-KeyCredentialLink is an attribute stored on a user or computer object, supporting certificate-based passwordless authentication (PKINIT), like Windows Hello for Business. With just write permission on this attribute (GenericWrite, GenericAll, and similar), an attacker can register a key pair they themselves control into it, without ever needing to know the target’s password at all. Authenticate via PKINIT using that key, and the attacker can impersonate the target, even recovering its NT hash.

sequenceDiagram
    participant Attacker as Attacker
    participant AD as msDS-KeyCredentialLink
    participant KDC as KDC (PKINIT)
    Attacker->>Attacker: Generate their own key pair
    Attacker->>AD: Register the public key into the target's msDS-KeyCredentialLink, using write permission
    Attacker->>KDC: Authenticate as the target via PKINIT, using their own private key
    KDC->>Attacker: Issues a TGT; the NT hash can also be recovered

Deep Dive Into the Fundamentals

Why There’s Never Any Need to Know the Password

Ordinary Kerberos authentication uses a key derived from the password, but PKINIT is an entirely different authentication method, using public-key cryptography. If you can register your own public key into msDS-KeyCredentialLink, you can authenticate via PKINIT using only your own private key, completely independent of whatever the target’s actual password is. This means an attacker never needs to change, or even know, the target’s password at all.

The Attack Requires AD CS’s PKINIT Prerequisite

For this attack to succeed, the domain controller needs a server authentication certificate that allows Kerberos authentication via PKINIT. In many environments, this certificate gets issued by AD CS (Active Directory Certificate Services), which is a prerequisite for the Key Trust authentication method.

Why This Attack Is a "Quiet" One

Many organizations don’t include changes to the msDS-KeyCredentialLink attribute in their monitoring scope at all. Compared to well-known attack techniques like DCSync or Kerberoasting, detection for changes to this attribute is often simply not in place, making this attack easy to overlook.

What a Pro Sees Here (Top 1% Understanding)

“Write Permission,” One Single Premise, Becomes the Entry Point for Multiple Different Attacks

RBCD and this Shadow Credentials attack both rest on the exact same underlying premise: “write permission on the target object.” The specific steps of each attack differ, but inventorying “who holds write permission on which object” is a shared defensive starting point against multiple different attack techniques. The habit of identifying the more fundamental premise an attack abuses, instead of addressing each specific attack technique in isolation, is the perspective a top-1% engineer carries.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. You want to investigate suspicious PKINIT authentication for a specific account: Check whether that account’s msDS-KeyCredentialLink attribute contains an unrecognized key.
  2. You want to invalidate a key an attacker registered: Remove the relevant key from msDS-KeyCredentialLink, carefully, so you don’t accidentally remove a legitimate Windows Hello for Business enrollment.
  3. You want to assess your own environment’s resilience against this attack: Inventory, from the ACLs, who holds write permission on which object’s msDS-KeyCredentialLink.

Summary

Takeaways to Apply Today

  1. Include changes to important accounts’ msDS-KeyCredentialLink attribute in your monitoring scope.
  2. Treat inventorying who holds write permission on which object as a shared defense against multiple attack techniques.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).