MachineAccountQuota Compromise
Introduction
MachineAccountQuota is an attribute in Active Directory that specifies how many machine accounts a user can create in the domain. By default, this value is set to 10, meaning any authenticated domain user can create up to 10 machine accounts without administrative privileges. While this setting supports certain use cases, it also introduces a security risk if exploited by attackers.
Compromise of MachineAccountQuota occurs when an attacker abuses this privilege to create unauthorised machine accounts. These accounts can then be used for malicious purposes, such as lateral movement, privilege escalation, or persistence, often bypassing standard account monitoring mechanisms.
This technique is categorised under the Persistence and Credential Access tactics in the MITRE ATT&CK Framework.
How MachineAccountQuota Compromise Works
Discovery:
Attackers first enumerate the domain to identify the current MachineAccountQuota setting.
This can be done using tools like
PowerShell
orBloodHound
.
Creating Machine Accounts:
If the quota is greater than 0, attackers create new machine accounts. These accounts often have names ending with
$
(e.g.,MACHINE01$
).
Abusing Machine Accounts:
Machine accounts are assigned credentials, just like user accounts. Attackers extract the credentials (password hashes) for further use.
These accounts may be leveraged to:
Perform lateral movement within the domain.
Bypass monitoring systems that focus on user accounts.
Establish persistence by hiding malicious activities behind machine accounts.
Further Exploitation:
Attackers may use tools like Impacket, Rubeus, or Mimikatz to dump the machine account's credentials, request Kerberos tickets, or escalate privileges.
Why MachineAccountQuota Compromise is Dangerous
Default Configuration Risk:
The default value of 10 allows any authenticated domain user to create machine accounts, significantly expanding the attack surface.
Hard-to-Monitor Accounts:
Machine accounts are often less scrutinised than user accounts, making them ideal for covert operations.
Persistence and Evasion:
Attackers can create machine accounts and use them to maintain access even after compromised user accounts are disabled or locked.
Privilege Escalation:
By controlling machine accounts, attackers can escalate privileges or impersonate legitimate systems.
Indicators of MachineAccountQuota Compromise
Unusual Account Creation:
Creation of multiple machine accounts (accounts ending with
$
) by non-administrative users.
High Volume of New Machine Accounts:
A significant number of machine accounts created within a short period.
Suspicious Logon Activity:
Newly created machine accounts logging into sensitive systems or initiating lateral movement.
Abnormal Usage of Machine Accounts:
Machine accounts performing tasks typically associated with user accounts, such as accessing shared resources or running administrative commands.
Detection Strategies
Monitor Account Creation Logs:
Windows Event ID 4741: Logs when a computer account is created.
Windows Event ID 4720: Logs when a user account is created (occasionally relevant if attackers disguise machine accounts as users).
Look for Anomalous Behavior:
Machine accounts (names ending with
$
) logging in from unusual locations or performing abnormal activities.
Audit Active Directory:
Periodically check the MachineAccountQuota setting using PowerShell:
Correlate with Threat Intelligence:
Cross-reference newly created accounts with known attack patterns or malicious tools.
Mitigation Strategies
Reduce MachineAccountQuota:
Set
ms-DS-MachineAccountQuota
to 0 for most environments where non-administrative users do not need to create machine accounts:
Restrict Account Creation Rights:
Limit the ability to create machine accounts to specific administrative groups.
Enable Logging and Alerts:
Configure alerts for unusual account creation activity (Event ID 4741).
Audit Existing Machine Accounts:
Regularly review machine accounts to ensure they are legitimate and necessary.
Monitor for Tools and TTPs:
Watch for signs of attacker tools such as BloodHound, Impacket, or Rubeus, which are commonly used to enumerate and exploit Active Directory.
The MachineAccountQuota feature, while useful in specific scenarios, poses a significant security risk if left misconfigured. By understanding how attackers exploit this setting and implementing proactive detection and mitigation strategies, organisations can better protect their Active Directory environments from compromise.
The MachineAccountQuota attribute in Active Directory defines the number of machine accounts a user can create in the domain. Attackers exploit this setting to register new machine accounts and abuse these accounts for lateral movement, persistence, or further exploitation. Detecting MachineAccountQuota abuse requires monitoring account creations and anomalous behaviours related to machine accounts.
KQL Detection Query
To detect MachineAccountQuota compromise using KQL in Microsoft Sentinel or other platforms you can monitor for unusual creation of machine accounts (accounts ending with $
) by non-administrative users. These activities are primarily logged under Windows Security Event ID 4741 (A computer account was created).
Query for Detecting MachineAccountQuota Compromise
Query Breakdown
Target Event:
EventID 4741: Captures the creation of computer accounts in Active Directory.
Focus on Machine Accounts:
Filters accounts with names ending in
$
(standard naming convention for machine accounts).
Aggregate Data:
Groups activities by the
InitiatorAccount
(the user who created the accounts).Tracks:
CreationCount: Total number of machine accounts created.
CreatedAccounts: List of machine accounts created.
UniqueInitiators: Number of unique users initiating account creation.
Initiators: Names of users initiating the activity.
Threshold for Suspicion:
Flags users who create more than 5 machine accounts within a specific time period.
Assigns a SuspiciousScore based on the volume of accounts created:
High: More than 10 accounts.
Medium: More than 5 accounts.
Output:
Provides key details for investigation, including the initiator, the created accounts, and the time range of activity.
Splunk Detection Query
The MachineAccountQuota attribute in Active Directory defines the number of machine accounts a user can create in the domain. Attackers exploit this setting to register new machine accounts and abuse these accounts for lateral movement, persistence, or further exploitation. Detecting MachineAccountQuota abuse requires monitoring account creations and anomalous behaviours related to machine accounts.
Splunk Query for MachineAccountQuota Compromise Detection
Query Breakdown
Target Events:
EventCode 4741: Logs when a computer account is created.
EventCode 4720: Logs when a user account is created. This helps identify any abuse disguised as user account creation.
EventCode 4624: This event is generated when an object successfully logs on
EventCode 4724: This event is generated when an attempt is made to reset an object’s password.
Field Normalisation:
Combines
TargetUserName
andAccountName
to identify the newly created accounts.Tracks the
CallerUserName
, which is the initiator of the account creation.
Event Grouping:
Aggregates account creation events by the initiator (
CallerUserName
).Captures the number of unique accounts created (
UniqueCreatedAccounts
) and the types of events involved (EventTypes
).
Suspicious Thresholds:
Flags initiators creating more than 5 unique accounts as potentially suspicious.
Assigns "High" severity if more than 10 accounts are created in a short timeframe.
Final Output:
Displays key details for investigation:
CallerUserName: Who created the accounts.
CreatedAccounts: The accounts that were created.
EventTypes: Types of events (computer or user account creations).
SuspiciousActivity: Risk level based on the volume of account creations.
Reference
Last updated