Below is a compact “cheat-sheet” on the topic Microsoft usually calls “anonymous (null-session) enumeration” on Windows machines ‑– what it is, why it matters, and how you can check / disable it.
1. What is “anonymous enumeration” on Windows?
| Term | Short explanation |
|---|
| Anonymous / null session | A network connection to the special IPC$ share that supplies no username or password. |
| Enumeration | Using that connection to call legacy APIs (e.g., NetUserEnum, NetShareEnum) to list users, groups, shares, registry keys, etc. |
| Why it exists | Backward-compatibility with pre-Active-Directory software and some management tools created in the NT 4.0 era. |
If the feature is left enabled, an unauthenticated attacker on the same network can obtain:
- Local user and group names (SAM database)
- Domain users / groups (if the machine is a domain controller and not hardened)
- List of shared folders and some registry information
This is extremely useful for password-guessing, social-engineering, or privilege-escalation attacks.
2. Key Microsoft “security option” settings
You’ll see these two policy names in Local/Domain Group Policy →
Computer Configuration → Windows Settings → Security Settings → Local Policies → Security Options:
| GUI policy | Registry value | Meaning (simplified) |
|---|
| “Network access: Do not allow anonymous enumeration of SAM accounts and shares” | HKLM\SYSTEM\CurrentControlSet\Control\Lsa\RestrictAnonymous = 1 | Block enumeration of users / shares, but still let null sessions reach named pipes that explicitly allow “Everyone” access. |
| “Network access: Do not allow anonymous enumeration of SAM accounts and shares (SAMBA)” (sometimes shown as “No access without explicit anonymous permissions”) | HKLM\SYSTEM\CurrentControlSet\Control\Lsa\RestrictAnonymous = 2 and RestrictAnonymousSAM = 1 | The strictest mode: anonymous users get no access at all unless an ACL specifically grants it. |
Value 0 (RestrictAnonymous = 0) = legacy / least secure (“null sessions fully allowed”).
Since Windows Server 2003 SP1 and Windows XP SP2, the default is at least 1; modern releases often default to 2 on domain controllers.
3. How to check your current setting
Command line (requires admin):
# Show current LSA keys
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' |
Select-Object RestrictAnonymous, RestrictAnonymousSAM
Or in a hardening scan:
secedit /export /cfg c:\tmp\secpol.cfg
findstr /i "RestrictAnonymous" c:\tmp\secpol.cfg
4. How to disable (harden) anonymous enumeration
- Local or Domain GPO → enable
“Network access: Do not allow anonymous enumeration of SAM accounts and shares”
(and, ideally, the stricter variant).
- After changing, run
gpupdate /force or reboot.
- Optionally close other null-session vectors:
• Disable/secure named pipes like browser, spoolss, samr.
• Enable SMB signing.
• Block TCP 139/445 from untrusted networks with a firewall.
5. Testing the result
Try a null session from another machine:
net use \\TARGET\ipc$ "" /user:""
net view \\TARGET
If hardening is successful you should receive “Access is denied” or “System error 5”.
Tools like enum.exe, rpcclient -U "" TARGET, or Nmap --script smb-enum* will also fail.
6. Side-effects / compatibility notes
• Very old apps that relied on null sessions (mostly NT 4.0 era) might break.
• If you must keep anonymous access for a specific pipe/share, leave RestrictAnonymous = 1 and tighten ACLs just on that object.
• Modern Windows, AD, and SMB 3.0-based products work fine with anonymous enumeration disabled.
TL;DR
Anonymous (null-session) enumeration is a legacy Windows feature that lets anyone list users, groups, and shares without logging in. In the vast majority of modern environments you should set:
‣ RestrictAnonymous = 2
‣ RestrictAnonymousSAM = 1
via Group Policy to eliminate that exposure.