Skeleton Key
Introduction
The Skeleton Key attack is an advanced persistence technique targeting Microsoft Active Directory (AD) environments. It involves injecting a malicious patch into the Local Security Authority Subsystem Service (LSASS) process on a domain controller, allowing attackers to bypass authentication mechanisms. This creates a "skeleton key" password that works for any user account without altering existing credentials or logs. The attack is particularly dangerous because it enables covert and persistent access to all accounts within the domain.
Skeleton Key attacks exploit the trust and centralization inherent in Active Directory systems. Once the malware is injected, it effectively enables the attacker to authenticate as any user while maintaining a low profile, making detection challenging.
Attack Description
A Skeleton Key attack unfolds as follows:
Initial Compromise: The attacker gains administrative access to a domain controller, often through privilege escalation techniques or by compromising high-privilege accounts.
Injection of Malicious Code: The attacker injects a malicious DLL into the LSASS process on the domain controller. This modifies the authentication flow to allow a hardcoded "skeleton key" password.
Stealthy Access: Using the skeleton key password, the attacker can authenticate as any user, including administrators, without altering credentials in the directory.
Persistence: The skeleton key remains active until the domain controller is rebooted. If not remediated, attackers can reinject the key after a reboot.
Skeleton Key attacks are often conducted with tools like Mimikatz and require administrative-level access to the domain controller.
Detection Techniques
Monitor LSASS Process Modifications:
Look for signs of unauthorised access or injections into the LSASS process.
Use Event ID 4688 (Process Creation) to detect execution of suspicious tools like Mimikatz.
Unusual Authentication Behavior:
Analyse authentication logs for repeated logins from the same account using different devices or IPs.
Correlate Event ID 4624 (Successful Logon) to identify anomalous patterns such as simultaneous logins to multiple systems.
Memory Analysis:
Perform memory forensics on domain controllers to detect injected DLLs or modifications to LSASS.
Network Traffic Analysis:
Monitor for lateral movement and unexpected authentication attempts across the network.
Behavioral Analytics:
Use User and Entity Behavior Analytics (UEBA) to detect deviations in normal user behaviour, especially for high-privilege accounts.
Events that Detect a Skeleton Key
Source of detection
Event ID 1102: Events generated when the ‘Security’ audit log is cleared. To avoid detection, malicious actors may clear this audit log to remove any evidence of their activities. Analysing this event can assist in identifying if a Domain Controller has been compromised.
Event ID 3033: Events generated when a driver fails to load because it does not meet Microsoft’s signing requirements. This indicates that a code integrity check determined that a process, usually LSASS.exe, attempted to load a driver that did not meet the Microsoft signing level requirements. These drivers fail to load if LSASS protection is enabled and should be audited before enabling protection. Furthermore, an unknown driver or plugin may indicate attempted tampering with the LSASS process.
Event ID 3063: Events generated when a driver failed to load because it did not meet the security requirements for shared sections. This indicates a code integrity check determined that a process, usually lsass.exe, attempted to load a driver that did not meet the security requirements for shared sections. These drivers will fail to load if LSASS protection is enabled and should be audited before enabling protection. An unknown driver or plugin may also indicate attempted tampering with the LSASS process.
Event ID 4103: Events generated when PowerShell executes and logs pipeline execution details. Common malicious tools used to execute a Skeleton Key, such as Mimikatz, use PowerShell. Analysing this event for PowerShell execution relating to a Skeleton Key may indicate a compromise.
Event ID 4104: Events generated when code is executed by PowerShell, capturing scripts and the commands run. Abnormal script execution should be investigated, noting that PowerShell-based tools such as Invoke-Mimikatz can be utilised to deploy a Skeleton Key without having to copy any files onto the Domain Controller.
Event ID 4663: Events generated when an attempt was made to access an object. If ‘Kernel Object Auditing’ is enabled, this will include logging when a process attempts to access the memory of the LSASS process. This is the most direct indicator of tampering with the LSASS process. Any event with the object as ‘lsass.exe’ from an unexpected process (including remote administrative tools such as PowerShell Remoting [wsmprovhost.exe]), could indicate the deployment of a Skeleton Key. Certain antivirus or endpoint solutions may access the LSASS process; therefore, it is important to determine what security solutions are present and expected on the host.
Event ID 4673: Events generated when a privileged service is called. This event triggers when the ‘SeDebugPrivilege’ privilege is enabled, which is required to successfully execute a Skeleton Key. This event also triggers when the ‘SeTCBPrivilege’ privilege is used. The ‘SeTCBPrivilege’ privilege allows for the impersonation of the system account and is often requested by Mimikatz.
Event ID 4697: Events generated when a service has been installed on the system. If this is an unknown kernel mode driver it may indicate a malicious or vulnerable driver being leveraged for exploitation, such as to bypass LSA protection. A service type field of ‘0x1’ or ‘0x2’ can indicate kernel driver services. Services are also installed with the use of some remoting tools, such as PSExec.
Event ID 4703: Events generated when a user right is adjusted. The addition of the ‘SeDebugPrivilege’ privilege, or other sensitive privileges such as ‘SeTCBPrivilege’, for an account may indicate attempts to deploy a Skeleton Key.
Mitigation Techniques
Limit Access to Domain Controllers:
Restrict administrative access to domain controllers to a minimal number of trusted accounts.
Enforce multi-factor authentication (MFA) for all privileged accounts.
Patch and Update Regularly:
Ensure all domain controllers are up-to-date with the latest security patches to mitigate known vulnerabilities.
Monitor for Known Attack Tools:
Use endpoint detection and response (EDR) tools to identify the presence of tools like Mimikatz.
Enable Secure LSASS Protections:
On supported Windows versions, enable Credential Guard and configure LSASS to run as a protected process to prevent tampering.
Auditing and Logging:
Enable advanced auditing for process creation, authentication, and administrative actions.
Centralise logs in a SIEM solution for continuous monitoring.
Periodic Memory Dumps:
Regularly analyse memory dumps of domain controllers for signs of injected code.
The following security controls should be implemented to mitigate Skeleton Key:
Limit access to Domain Controllers to only privileged users that require access. This reduces the number of opportunities for malicious actors to gain access to Domain Controllers.
Restrict privileged access pathways to Domain Controllers to jump servers and secure admin workstations using only the ports and services that are required for administration. Domain Controllers are classified as ‘Tier 0’ assets within Microsoft’s ‘Enterprise Access Model’.
Run the LSASS process in protected mode. This makes it more difficult to override the LSASS process, which is required for Skeleton Key to succeed.
Implement Microsoft’s vulnerable driver blocklist. Restricting known malicious or vulnerable drivers on Domain Controllers makes it more difficult for malicious actors to bypass LSASS protection.
Restrict driver execution to an approved set. Restricting the drivers that can be loaded on Domain Controllers to an approved set hardens it against attempts to bypass LSASS protection. This can be achieved through application control solutions, including Microsoft’s Windows Defender Application Control.
Only use Domain Controllers for AD DS and do not install any non-security-related services or applications. This reduces the attack surface of Domain Controllers as there are fewer services, ports and applications that may be vulnerable and used to compromise a Domain Controller.
Centrally log and analyse Domain Controller logs in a timely manner to identify malicious activity. Domain Controller logs provide a rich source of information that is important for investigating potentially malicious activity on Domain Controllers and in the domain.
Disable the Print Spooler service on Domain Controllers. For example, threat actors have targeted the Print Spooler service on Domain Controllers as a technique to authenticate to a system they control to collect the Domain Controllers computer object password hash or TGT. Malicious actors can then use this to authenticate to the Domain Controller they coerced and gain administrative access
Incident Response Planning:
Have a robust incident response plan in place to quickly isolate and remediate compromised domain controllers.
Skeleton Key attacks represent a critical risk to Active Directory environments due to their stealth and impact. By implementing strong access controls, proactive monitoring, and regular audits, organisations can reduce the likelihood of such attacks and enhance their overall security posture.
KQL Detection Queries
Detecting a Skeleton Key attack requires identifying suspicious activity on domain controllers, such as unauthorised LSASS process modifications, abnormal authentication patterns, or lateral movement activity. The following is a query tailored to detect potential Skeleton Key activity in Microsoft Sentinel.
KQL Query to Detect Skeleton Key
Explanation of the Query
Step 1: Detect Suspicious Processes:
Monitors for processes created with
lsass.exe
as the parent or suspicious tools like Mimikatz.Filters for commands (
sekurlsa::
) associated with Skeleton Key activities.
Step 2: Identify Unusual Authentication:
Tracks high-frequency logins (
4624
) from the same account or IP address, which may indicate Skeleton Key usage.Focuses on network or remote logons (
LogonType 3, 10
).
Step 3: Privileged Account Activity:
Detects privileged logons (
4672
) where sensitive privileges likeSeDebugPrivilege
are granted, often used for LSASS tampering.
Step 4: Correlation:
Combines suspicious process activity, unusual authentication patterns, and privileged logon activity on the same domain controller.
Highlights cases where multiple indicators of compromise occur (
Count > 2
).
Customisations
Adjust thresholds like
LoginCount > 5
orCount > 2
based on your organisation’s activity baseline.Add filters for specific tools or command-line arguments known to be used in Skeleton Key attacks.
Include additional privileged actions, such as
SeTakeOwnershipPrivilege
orSeBackupPrivilege
.
Output
The query provides:
The domain controller (
Computer
) where activity occurred.The accounts (
AccountName
,TargetUserName
) involved in suspicious processes or logons.Details of suspicious commands, privileges, and IP addresses.
Usage
Integrate this query into Microsoft Sentinel for:
Dashboards: Visualise suspicious activity related to domain controllers.
Alerts: Set up real-time alerts for correlated suspicious activity.
Investigation: Use the output to prioritise response to potential Skeleton Key attacks.
This advanced query leverages process monitoring, authentication analysis, and privilege detection to identify Skeleton Key attacks effectively.
Splunk Detection Queries
The following are Splunk queries designed to detect potential Skeleton Key activity. This query identifies LSASS tampering, unusual authentication patterns, privilege escalation, and lateral movement commonly associated with Skeleton Key attacks.
Splunk Query for Skeleton Key Detection
Explanation of the Query
Search Scope:
Searches across relevant indexes (
index=security
,index=windows
,index=active_directory
) for event types associated with Skeleton Key activities:4688: Process creation for detecting LSASS tampering and suspicious tools like
mimikatz.exe
.4624: Authentication events for detecting unusual login behaviour.
4672: Privileged logon events for monitoring sensitive privilege usage.
Activity Classification:
Assigns an
ActivityType
to each event for easier categorisation:Process Creation, Authentication, and Privileged Logon.
Suspicious Activity Flags:
Flags events indicative of Skeleton Key activity:
LSASS tampering: Parent process is
lsass.exe
or suspicious processes likemimikatz.exe
.Skeleton Key commands: Presence of commands such as
sekurlsa::
.Unusual authentication: Frequent logons from non-administrator accounts or network logon types (3, 10).
Suspicious privileges: Sensitive privileges like
SeDebugPrivilege
,SeTakeOwnershipPrivilege
, orSeBackupPrivilege
.
Event Aggregation and Thresholding:
Groups events by
ActivityType
,ComputerName
, andUser_Name
.Filters results where
EventCount > 2
to surface significant activity.
Customisations
Thresholds:
Adjust
EventCount > 2
based on your organisation's normal activity levels.
Process Detection:
Add more known malicious tools or commands (e.g.,
procdump.exe
,taskmgr.exe
) to theNew_Process_Name
orCommand_Line
checks.
Accounts:
Add specific accounts or roles to monitor, such as domain administrators or service accounts.
Privileges:
Expand the privileges list to include additional sensitive privileges used in your environment.
Output
The query provides:
ComputerName: The system where the suspicious activity occurred.
User_Name: The account executing the activity.
TargetUsers: Accounts targeted in suspicious logons.
SourceIPs: IP addresses associated with the activity.
ActivityType: Classification of the event (e.g., Process Creation, Authentication).
DetectedActivities: Specific suspicious behaviors flagged.
EventCount: Total number of correlated suspicious events.
Usage
Real-Time Alerts: Set up Splunk alerts to trigger on high event counts or specific suspicious activities.
Dashboards: Use the query in a Splunk dashboard to monitor for Skeleton Key activities in realtime.
Incident Response: Investigate events flagged in the query to determine the scope and impact of potential Skeleton Key attacks.
This Splunk query provides a robust framework for detecting and responding to Skeleton Key attacks by correlating key indicators across process, authentication, and privilege events.
Reference
Last updated