Query Details
// =========================================================
// RULE-05 | AD-ShadowCredentials-KeyCredentialLink
// Description : Shadow Credentials attack detection — Event
// 5136 (Directory Service Object Modified)
// showing a WRITE operation on the attribute
// msDS-KeyCredentialLink on any user or computer
// object.
// An attacker with GenericWrite on a target
// writes their own public key to this attribute,
// then uses PKINIT (certificate-based Kerberos)
// to obtain the NT hash without touching the
// password.
// Severity : High (user object) → Critical (computer object
// or DA-level account targeted)
// Frequency : Every 15 minutes, look-back 15 minutes
// MITRE : T1556.006 — Modify Authentication Process:
// Multi-Factor Authentication
// T1098 — Account Manipulation
// Tables : SecurityEvent
// =========================================================
let LookBack = 15m;
// High-value targets: DA/EA/privileged accounts
// (determined heuristically — expand as needed)
let TierZeroNames = datatable(TZName:string)
[
"Domain Admins", "Enterprise Admins", "Schema Admins",
"Administrators", "Account Operators", "krbtgt"
];
SecurityEvent
| where TimeGenerated > ago(LookBack)
| where EventID == 5136 // DS Object Modified
| where OperationType == "%%14674" // Write Value (attribute set)
| where AttributeLDAPDisplayName =~ "msDS-KeyCredentialLink"
| extend
ActorAccount = strcat(SubjectDomainName, "\\", SubjectUserName),
TargetObject = ObjectDN,
ObjectClass = ObjectClass,
IsComputerObj = ObjectClass =~ "computer",
IsUserObj = ObjectClass =~ "user"
| extend
IsTierZeroTarget = iff(ObjectDN has_any (TierZeroNames), true, false)
| extend
Severity = case(
IsTierZeroTarget or IsComputerObj, "Critical",
IsUserObj, "High",
"Medium"
),
WhySuspicious = strcat(
"ShadowCredentials_KeyCredentialLink_Write; ",
iff(IsTierZeroTarget, "TierZero_Target; ", ""),
iff(IsComputerObj, "Computer_Object_Target; ", ""),
iff(IsUserObj, "User_Object_Target; ", ""),
"Actor: ", SubjectUserName
)
| project
TimeGenerated,
Severity,
WhySuspicious,
ActorAccount,
TargetObject,
ObjectClass,
IsTierZeroTarget,
Computer,
SubjectUserName,
SubjectDomainName
| order by TimeGenerated desc
This query is designed to detect potential "Shadow Credentials" attacks in an Active Directory environment. Here's a simplified breakdown of what it does:
Purpose: The query identifies suspicious modifications to the msDS-KeyCredentialLink attribute on user or computer objects in Active Directory. This is indicative of a "Shadow Credentials" attack, where an attacker writes their own public key to this attribute to gain unauthorized access without needing the password.
Severity Levels:
Frequency: The query runs every 15 minutes and looks back over the last 15 minutes of data.
Detection Logic:
OperationType == "%%14674") on the msDS-KeyCredentialLink attribute.Output: The query produces a list of suspicious activities, detailing:
Use Case: This query is useful for security teams to monitor and respond to potential unauthorized access attempts in their Active Directory environment, especially those targeting high-value accounts or systems.

David Alonso
Released: March 24, 2026
Tables
Keywords
Operators