How the attack works
msDS-KeyCredentialLink stores the public keys an account can use for key-based (PKINIT) Kerberos sign-in. Windows Hello for Business key trust and device registration populate it legitimately, normally through Microsoft Entra Connect synchronization or device write-back. A domain controller that supports key trust accepts a TGT request signed with any key listed there.
An attacker who can write this attribute on a target (GenericAll, GenericWrite or a specific write right on msDS-KeyCredentialLink, often reached through an ACL attack path or an NTLM relay to LDAP) adds a key pair they generated. They then request a TGT as the target and can recover its NT hash from the PKINIT response. The password is untouched, so the owner notices nothing; the only directory trace is the attribute write.
What an attacker needs
- Write access to
msDS-KeyCredentialLinkon the target user or computer object. - At least one domain controller running Windows Server 2016 or later with a certificate that supports PKINIT (present in most environments with AD CS or Windows Hello for Business).
Impact
Full takeover of the target account for as long as the key stays on the object, including its NT hash. On a privileged user or a domain controller computer account this is a direct path to domain compromise, and it doubles as quiet persistence.
Detection rules
Key Credential Added to an Account by a Computer Account
Detects a value added to msDS-KeyCredentialLink by a computer account. This covers the common relay variant of Shadow Credentials, where a coerced and relayed machine authentication is used to write a key on another object. Requires Audit Directory Service Changes and a SACL that audits writes to msDS-KeyCredentialLink.
title: Key Credential Added to an Account by a Computer Account
id: d48619a8-be8e-4992-b375-d9e2b5d08171
status: experimental
description: >-
Detects a value added to msDS-KeyCredentialLink by a computer account. This
covers the common relay variant of Shadow Credentials, where a coerced and
relayed machine authentication is used to write a key on another object.
Requires Audit Directory Service Changes and a SACL that audits writes to
msDS-KeyCredentialLink.
references:
- https://attack.mitre.org/techniques/T1098/
- https://learn.microsoft.com/en-us/windows/security/identity-protection/hello-for-business/how-it-works
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5136
author: Forestall
date: 2026-11-10
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098
logsource:
product: windows
service: security
detection:
selection:
EventID: 5136
AttributeLDAPDisplayName: msDS-KeyCredentialLink
OperationType:
- '%%14674'
- 'Value Added'
SubjectUserName|endswith: '$'
condition: selection
falsepositives:
- Device registration flows and gMSA-based synchronization accounts that write keys legitimately. A computer writing a key to its own object (SubjectUserName matches the CN in ObjectDN) is far less suspicious than one writing to another object; baseline the writers in your environment.
level: medium
False positives
- Device registration flows and gMSA-based synchronization accounts that write keys legitimately. A computer writing a key to its own object (SubjectUserName matches the CN in ObjectDN) is far less suspicious than one writing to another object; baseline the writers in your environment.
Key Credential Added to an Account by a User Account
Detects a value added to msDS-KeyCredentialLink on a user or computer object by an account that is not a computer account. Legitimate keys are written by synchronization or device registration services; a regular user writing a key to another account is the Shadow Credentials technique. Requires Audit Directory Service Changes and a SACL that audits writes to msDS-KeyCredentialLink.
title: Key Credential Added to an Account by a User Account
id: 730c61c3-43ef-4273-b825-638e442bdb7e
status: experimental
description: >-
Detects a value added to msDS-KeyCredentialLink on a user or computer object
by an account that is not a computer account. Legitimate keys are written by
synchronization or device registration services; a regular user writing a key
to another account is the Shadow Credentials technique. Requires Audit
Directory Service Changes and a SACL that audits writes to
msDS-KeyCredentialLink.
references:
- https://attack.mitre.org/techniques/T1098/
- https://learn.microsoft.com/en-us/windows/security/identity-protection/hello-for-business/how-it-works
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5136
author: Forestall
date: 2026-11-10
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098
logsource:
product: windows
service: security
detection:
selection:
EventID: 5136
AttributeLDAPDisplayName: msDS-KeyCredentialLink
OperationType:
- '%%14674'
- 'Value Added'
filter_computer_accounts:
SubjectUserName|endswith: '$'
filter_entra_connect:
SubjectUserName|startswith: 'MSOL_'
condition: selection and not 1 of filter_*
falsepositives:
- Microsoft Entra Connect writing Windows Hello for Business keys (MSOL_ accounts are excluded; add your sync or AD FS service account to filter_entra_connect if it uses another name).
- Administrators manually restoring a user's key during troubleshooting.
level: high
False positives
- Microsoft Entra Connect writing Windows Hello for Business keys (MSOL_ accounts are excluded; add your sync or AD FS service account to filter_entra_connect if it uses another name).
- Administrators manually restoring a user's key during troubleshooting.
Detection logic
Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.
Key credential written to an account, then a public key ticket request for the same account
The write to msDS-KeyCredentialLink only prepares the takeover. The attacker then requests a ticket-granting ticket as the target with the added key, which the domain controller logs as event 4768 with public key pre-authentication. The write, followed by such a ticket request for the same account from an address that is neither the writer's own system nor one the account normally uses, shows the planted key being used.
- A key is added: event 5136 with
AttributeLDAPDisplayNamemsDS-KeyCredentialLink andOperationTypeValue Added. KeepObjectDN,SubjectUserNameandSubjectLogonId. - Find where the write came from: event 4624 on the same domain controller whose
TargetLogonIdequals thatSubjectLogonId. ReadIpAddress. - Resolve
ObjectDNto the account name and SID of the target, because the ticket event does not hold the distinguished name. - Within 60 minutes, find event 4768 with result code 0x0 for that
TargetSidwhosePreAuthTypeis 16 or 15, the public key types that Microsoft lists for smart card logon. Compare itsIpAddresswith the address of the write and with the systems the account normally signs in from.
Events513646244768
LimitsWindows Hello for Business key trust and device registration also write a key, followed by key-based sign-ins of the real user from that user's device; the writer and the address tell them apart. Microsoft does not describe how a key trust sign-in appears in event 4768, so check on a known Windows Hello sign-in which pre-authentication type your domain controllers log. The 60 minutes are a starting point, and the write needs a SACL.
Triage
- Identify the target (ObjectDN) and the writer (SubjectUserName); a regular user or an unrelated computer account writing a key to another object is the attack pattern.
- Confirm whether the writer is the Entra Connect synchronization account or a device registration process, and whether the target uses Windows Hello for Business.
- Look for a 4768 TGT request for the target shortly after the write with certificate-based (PKINIT) pre-authentication (PreAuthType 16 or 15) from an unusual host (IpAddress).
- If unexplained, remove the added key, reset the target's password and investigate how the writer obtained the right.
Response
Once the attack is confirmed:
- Remove the unauthorized key from msDS-KeyCredentialLink on the target. Leave the keys that belong to registered devices in place.
- Reset the password of the target. The attacker could recover its NT hash from the PKINIT response, and removing the key does not take that hash away.
- Disable or reset the account that wrote the key. If the writer was a computer account, look for the relay behind it and isolate the address the write came from.
- If the target is the computer account of a domain controller or a privileged user, check for directory replication and other privileged activity since the write, and handle a positive result as a domain compromise.
- Remove the access right that allowed the write, and check the other objects the writer could reach for keys added in the same period.
Mitigation
- Remove unnecessary write rights (GenericAll, GenericWrite, write
msDS-KeyCredentialLink) on privileged users and computers; review them as part of ACL attack path analysis. - Enforce LDAP signing and channel binding on domain controllers so relayed NTLM authentication cannot write the attribute.
- Periodically inventory
msDS-KeyCredentialLinkvalues on privileged accounts and remove keys that do not belong to a registered device. - Configure a SACL that audits writes to
msDS-KeyCredentialLinkand enable "Audit Directory Service Changes" on domain controllers.
Frequently asked questions
Does resetting the password of the target remove the attacker's access?
Not by itself. The added key does not depend on the password, and the takeover lasts for as long as the key stays on the object. Remove the key first. Reset the password as well, because the attacker can recover the NT hash of the account from the PKINIT response.
How do I tell a Windows Hello for Business key from a planted one?
Legitimate keys are written by Microsoft Entra Connect synchronization or by device registration, for accounts that use Windows Hello for Business. A regular user, or a computer account that writes to an object other than its own, is the attack pattern. A key that does not belong to a registered device should be removed.
Why are there separate rules for user accounts and computer accounts as writers?
They cover two variants. A user account that writes a key to another account is the direct technique, with synchronization accounts filtered out. A computer account as writer covers the relay variant, in which a coerced and relayed machine authentication is used for the write. Computers also write keys legitimately, so that rule has the lower level.
Why does the owner of the account notice nothing?
The password is not touched, so the owner keeps signing in as before. The attacker signs in with the added key through key-based Kerberos (PKINIT). The only trace in the directory is the write to msDS-KeyCredentialLink, and it is logged only where a SACL audits that attribute and Audit Directory Service Changes is enabled.
References
- MITRE ATT&CK T1098: Account Manipulation
- How Windows Hello for Business works: key synchronization to msDS-KeyCredentialLink
- MS-ADTS: Key Credential Link structures
- Event 5136: A directory service object was modified
- Event 4768: A Kerberos authentication ticket (TGT) was requested (pre-authentication types 15 and 16)
- Event 4624: An account was successfully logged on