How it works
A group managed service account (gMSA) is a service account whose password nobody sets. The domain derives a long random password, changes it on a fixed interval, and gives it to the hosts that run the service whenever they ask. That makes a gMSA immune to guessing and to Kerberoasting. The remaining weakness is the delivery: something has to be allowed to fetch the password.
The fetch is an LDAP read of the constructed attribute msDS-ManagedPassword on the gMSA object. The domain controller does not store this value; it builds it for each request. Before it does, it checks two things:
- The connection must be encrypted (LDAPS, or LDAP with signing and sealing).
- The requester's token must be granted read access by the security descriptor stored in
msDS-GroupMSAMembership. PowerShell shows this descriptor asPrincipalsAllowedToRetrieveManagedPassword. Despite the name it is not a member list, and groups in it are evaluated with all their nested members.
The value returned is a binary structure (MSDS-MANAGEDPASSWORD_BLOB) that holds the current password, the previous password where one is retained, and the intervals until the next change. The account's NT hash and AES keys follow from the password, so whoever holds the blob can authenticate as the gMSA with NTLM or Kerberos.
That gives an attacker several ways in:
- Compromise an authorized reader. Usually the readers are the computer accounts of the service hosts. SYSTEM on one of those hosts can read the password with the computer account. If a user or a user group is on the list, compromising that user is enough.
- Join a reader group. Whoever can change the membership of a group on the list changes who can read the password, without touching the gMSA.
- Rewrite the list. Write access to
msDS-GroupMSAMembership, or control of the gMSA object's access control list (GenericAll, GenericWrite, WriteDACL, owner), lets a principal add itself. - Stale readers. Hosts that no longer run the service but were never removed, including computer accounts an attacker can take over.
Standalone managed service accounts (sMSA) work differently. An sMSA is bound to one computer, and the directory has no readable password attribute for it. The secret is held by that host, so reading it means administrator access on the host and extraction from its LSA secrets, as described in SAM, LSA secrets and cached credentials. The same host-side copy exists for a gMSA on every host that runs its service.
Prerequisites
- A domain account or computer account that is, or can become, an authorized reader of the target gMSA, by one of the paths above.
- LDAP access to a writable domain controller over an encrypted connection.
- For the result to matter: a gMSA with useful rights. Many are local administrators on their servers, some hold delegation rights or sit in privileged groups, which makes them an over-permissioned service account.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Find gMSAs and their readers
Any domain user can list the accounts and the retrieval list:
Get-ADServiceAccount -Filter * -Properties PrincipalsAllowedToRetrieveManagedPassword, memberOf, servicePrincipalName |
Select-Object Name, PrincipalsAllowedToRetrieveManagedPassword, memberOf, servicePrincipalName
Resolve each group on the list to its nested members, and check who can write to the gMSA object and to those groups.
2. Become a reader, if not one already
With write access to the retrieval list, add a controlled principal. Set-ADServiceAccount replaces the whole list, so keep the existing entries or the service loses access and the change becomes obvious:
$gmsa = Get-ADServiceAccount -Identity svc-web -Properties PrincipalsAllowedToRetrieveManagedPassword
Set-ADServiceAccount -Identity svc-web -PrincipalsAllowedToRetrieveManagedPassword `
($gmsa.PrincipalsAllowedToRetrieveManagedPassword + 'CN=alice,CN=Users,DC=corp,DC=example,DC=com')
With control of a group that is on the list, add a member instead. The new membership applies to tokens issued after the change, so start a new logon session before reading.
Add-ADGroupMember -Identity 'Web-Servers' -Members alice
3. Read the password
From Linux, gMSADumper reads every blob the account can access and prints the hashes; NetExec does the same with its --gmsa option, which uses LDAPS automatically.
python3 gMSADumper.py -u alice -p '<password>' -d corp.example.com
python3 gMSADumper.py -k -d corp.example.com -l dc01.corp.example.com
nxc ldap 192.0.2.10 -u alice -p '<password>' --gmsa
From Windows, GMSAPasswordReader reads the blob for one account and converts it to hashes for reuse:
.\GMSAPasswordReader.exe --AccountName svc-web
DSInternals decodes a blob that was read with the ActiveDirectory module:
$gmsa = Get-ADServiceAccount -Identity svc-web -Properties 'msDS-ManagedPassword'
ConvertFrom-ADManagedPasswordBlob -Blob $gmsa.'msDS-ManagedPassword'
On a host that runs the service, the gMSA secret is also present in the LSA secrets. NetExec can turn such a value, once extracted, into the account's hash with --gmsa-decrypt-lsa, and match a secret to its account with --gmsa-convert-id.
4. Authenticate as the gMSA
.\Rubeus.exe asktgt /user:svc-web$ /rc4:<nt_hash> /domain:corp.example.com /ptt
nxc smb 192.0.2.20 -u 'svc-web$' -H <nt_hash>
Impact
The attacker becomes the service account: its group memberships, its local administrator rights on servers, its access to databases and file shares, and any delegation configured for it. This is credential theft from the directory itself, without touching the hosts that run the service.
The password stays valid until the next scheduled change, 30 days by default, and ordinary rotation does not revoke a reader that is still on the list: after each change it simply reads the new password. An attacker who also holds the forest's KDS root key does not need the list at all, which is the Golden gMSA attack.
OPSEC and artifacts
- Reading as an approved host. A read made with the computer account of a service host is exactly what normal operation looks like, and rules that exclude computer accounts do not see it. This is the quiet path, and it needs SYSTEM on that host first.
- Reading as a user. Where the gMSA object has an audit entry for
msDS-ManagedPassword, each read writes event 4662 with the reader and the attribute. A user account reading a gMSA password from a workstation stands out. Without that audit entry, no read is logged for anyone. - Changing the list. A write to
msDS-GroupMSAMembershipis logged as event 5136 where directory changes are audited, and the change stays visible on the object until someone restores it. Replacing the list instead of extending it also breaks the service, which gets noticed faster than any alert. Operators who restore the original value afterwards leave a second 5136. - Changing a group. Adding a member to a reader group writes a group membership event for that group, several steps away from the gMSA. Defenders who watch only the gMSA object miss it.
- Tool defaults. gMSADumper and
nxc --gmsaask for every gMSA the account can read. One account reading all gMSA passwords within a second is a pattern no service host produces. - Using the account. A TGT request for the gMSA (event 4768) or a network logon by it (event 4624) from an address that is not one of its service hosts is the trace that remains whatever the read looked like. An RC4 request made with the NT hash also differs from the AES requests that the real hosts make.
Detection
- Audit and alert on reads. Add an audit entry for Read Property on
msDS-ManagedPasswordto gMSA objects and enable Audit Directory Service Access. Event 4662 then carries the attribute's GUIDe362ed86-b728-0842-b27d-2dea7a9df218inPropertieswith access mask0x10. The gMSA Password Read detection rules alert on readers that are not computer accounts. - Watch the retrieval list. Event 5136 with
AttributeLDAPDisplayNamemsDS-GroupMSAMembership, and changes to the gMSA's security descriptor. A list change followed by a read from a new principal is the takeover pattern. - Watch the reader groups. Treat groups on a retrieval list as sensitive and alert on membership changes, as the privileged group membership rules do for built-in groups.
- Baseline where each gMSA signs in from. A gMSA authenticates from a small, fixed set of hosts. Anything else deserves an alert.
- Review exposure. For every gMSA, list the effective readers with nesting resolved, compare them with the hosts that run the service, and remove retired hosts.
// gMSA password reads by accounts that are not computers
WindowsEvent
| where Channel == "Security" and EventID == 4662
| extend Actor = tostring(EventData.SubjectUserName),
Target = tostring(EventData.ObjectName),
Properties = tostring(EventData.Properties),
Mask = tostring(EventData.AccessMask)
| where Properties has "e362ed86-b728-0842-b27d-2dea7a9df218" and Mask == "0x10"
| where Actor !endswith "$"
| project TimeGenerated, Computer, Actor, Target
A successful 4662 shows an authorized read. It says nothing about what the reader did with the value, and a missing event means nothing where the audit entry is absent.
Mitigation
- Put only the service hosts on the retrieval list. Use the computer accounts, or one dedicated computer group per gMSA, and never user accounts or general-purpose groups. The gMSA guide shows the setup.
- Protect the hosts like the account. A server that may read a gMSA password belongs to the same tier as everything the gMSA can reach.
- Control who can change the list and the reader groups. Review write access to each gMSA object, to
msDS-GroupMSAMembershipand to the membership of every group on a list, and remove non-administrative principals. - Give the gMSA only what the service needs. Keep gMSAs out of Domain Admins and other privileged groups; see how to secure Active Directory service accounts.
- Remove readers when hosts are retired, and delete gMSAs that no service uses.
- Audit reads and list changes on gMSA objects; the audit policy guide covers the domain controller side.
- After an unexplained read, remove the reader, restore the list and the access control list, and treat the gMSA as compromised until its password has changed. If that cannot wait, replace the account with a new gMSA.
Detection rules for this attack
Log events to collect
FAQ
Who can read a gMSA password?
The principals named in the account's PrincipalsAllowedToRetrieveManagedPassword setting, which Active Directory stores as a security descriptor in msDS-GroupMSAMembership. A domain controller builds the password blob only for a requester whose token matches that descriptor. Groups count, including nested ones, so the real reader population is often larger than the list suggests.
Is a gMSA not supposed to be safe from password theft?
A gMSA is safe from guessing: its password is long, random and rotated by the domain, so Kerberoasting it is pointless. It is not safe from being read. The hosts that run the service must be able to fetch the password, and anything that can act as one of those hosts, or that was added to the list, fetches it the same way.
How long does a stolen gMSA password work?
Until the domain rotates it, which happens every 30 days by default. Removing the reader from the list stops future reads but does not change the password already taken. Where waiting is not acceptable, move the service to a new gMSA and delete the old one.
Can a standalone managed service account be read the same way?
No. A standalone managed service account has no msDS-ManagedPassword attribute; that attribute is defined for the gMSA class. Its password is kept by the single computer it is bound to, so an attacker needs administrator access to that host and reads it from the host's LSA secrets.
References
- Unsecured Credentials, T1552 (MITRE ATT&CK)
- Group Managed Service Accounts overview (Microsoft Learn)
- MS-ADTS: msDS-ManagedPassword processing rules
- MS-ADTS: MSDS-MANAGEDPASSWORD_BLOB
- ms-DS-GroupMSAMembership attribute (Microsoft Learn)
- gMSADumper (micahvandeusen)
- DSInternals: ConvertFrom-ADManagedPasswordBlob
- NetExec: Dump gMSA
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.