MachineAccountQuota (Rise of the Unwanted Machines)
To everyone attending the Veeam Summit, have a great one! I'm sad I'm missing it but hope to be there for the next one.
Right, back to this vulnerability.
By default, Active Directory has a setting enabled that allows a standard domain user to create up to 10 computer objects in the domain. This is due to the ‘ms-DS-MachineAccountQuota’ attribute in AD. Allowing standard users to join computer objects to the domain can be exploited by attackers to escalate privileges in a domain.
When a new computer object is added, it is by default added to the Domain Computers Security group, which then inherits the privileges that have been assigned to that group. This can then be used to interact with the domain, user objects, and other systems and services in the domain.
This can also be used as part of another compromise, KrbRelayUp, to perform privilege escalation.
Mitigations
- Prevent users from adding new devices to the domain by setting the `ms-DS-MachineAccountQuota` attribute in Active Directory to zero. Only those who need to, i.e., IT staff, should be able to add a new device when required.
- The Domain Computers Security group should not be a member of privileged security groups to prevent malicious actors from escalating their privileges.
- Additionally, the security group should not have write privileges to any objects in AD to prevent the gain or control of other AD objects.
- Enable LDAP signing for Domain Controllers, which also helps mitigate against KrbRelayUp. https://learn.microsoft.com/en-us/troubleshoot/windows-server/active-directory/enable-ldap-signing-in-windows-server
Monitoring
The following Event IDs should be monitored on Domain Controllers:
- 4624 - Object successfully logged on. Can be correlated with Event ID 4741.
- 4724 - Generated when an attempt is made to reset an object's password. If generated at or near the same time as Event ID 4741, a compromise has occurred.
- 4741 - Computer object created in Active Directory. If created by a 'normal' user, there is a chance a compromise has occurred.