In SMB on Windows, what does access-based enumeration do for a share, and how does Samba's access based share enum differ?
answer
- listing, not opening
- users see only what they may read
- a Set-SmbShare parameter with two values
- a ShareFlags bit in the TREE_CONNECT reply
- Samba filters a different list
basics
~20 sAccess-based enumeration (Set-SmbShare -FolderEnumerationMode AccessBased) stops SMB listing files and folders a user has no rights to; the default is Unrestricted. Samba's access based share enum instead hides the share itself from users without share access, using share permissions only.
solid answer
~30 sOn Windows, `Set-SmbShare -Name Finance -FolderEnumerationMode AccessBased` makes the server list only the files and folders the user has rights to; the default is `Unrestricted`, which lists entries even where the user cannot open them. At the protocol level the server sets `SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM` in the `TREE_CONNECT` response. Samba's `access based share enum` is a different filter: it hides the share from the share list for users without read or write access to it, evaluating share permissions only and not the file security descriptors. Samba's `hide unreadable` is the file-level analogue. Both are about what is listed, not what can be opened.
go deeper
Recall that the setting hides entries a user has no rights to from listings and is off by default.
Know Set-SmbShare -FolderEnumerationMode AccessBased, the ShareFlags bit it sets, and that it filters listings rather than enforcing access.
Choose the right Samba parameter for the goal (share list versus files) and weigh the listing cost of hide unreadable on large directories.
Judge whether enumeration filtering belongs in the standard share template or only on shares whose folder names are themselves sensitive.
## The problem it solves A department share such as `Finance` often holds a folder per team. With default settings a user browsing `\\files01.example.internal\Finance` can see the names of folders they cannot open. The names themselves can reveal project or personnel information, so administrators ask for the listing to be filtered too. ## Windows: FolderEnumerationMode The `New-SmbShare` and `Set-SmbShare` cmdlet pages describe the `-FolderEnumerationMode` parameter, which has two values: | Value | Behaviour | |---|---| | `Unrestricted` | SMB displays files and folders to a user even when the user lacks permission to access them. This is the default. | | `AccessBased` | SMB does not display the files and folders unless the user has rights to access them. | Microsoft states that access-based enumeration is disabled for new shares by default. You turn it on per share, and you can change a share you already have: ```powershell Set-SmbShare -Name "Finance" -FolderEnumerationMode AccessBased -Force ``` ## At the protocol level MS-SMB2 defines a share flag, `SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM` (`0x00000800`), in the `ShareFlags` field of the `TREE_CONNECT` response. Its meaning is that the server will filter directory entries based on the access permissions of the client. The specification says the server must set it when the share's `DoAccessBasedDirectoryEnumeration` property is true. In a capture, the bit tells you which shares have it on without logging in to the server. ## What it is not - **It filters what is listed.** Whether a user can open a file is still decided by the access checks, which are the subject of the share-versus-file-permission question. - **It does not replace permissions.** A folder name not appearing is a convenience and a privacy gain, not an access control. - **Microsoft's cmdlet pages describe no performance cost for the Windows setting**, so do not quote one. ## Samba: two different parameters Samba's smb.conf(5) has its own pair, and they do not behave like the Windows setting: | Samba parameter | What it hides | Default | |---|---|---| | `access based share enum` | The **share** in share enumeration, visible only to users with read or write access to it. Only share permissions are evaluated, not the security descriptors on files inside. | `no` | | `hide unreadable` | The **existence of files** the user cannot read. | `no` | The manual warns that `hide unreadable` can slow listing of large directories significantly, because Samba has to evaluate the ACLs of every directory member. Setting up a migrated Samba share therefore means picking the parameter that matches the goal. ## Testing it Test with an ordinary account such as `alice`, not an administrator: an account with rights to everything sees everything, so the filter would appear to do nothing. Browse the share before and after, and compare what is listed. Remember that the filter depends on the account's own rights on each entry, so a folder whose ACL is wrong will be shown to the wrong people either way; access-based enumeration surfaces ACL mistakes more quickly, because folders vanish from a user's view when a group is missing from the list. ## Putting it into a change plan 1. Decide whether the goal is hiding *files and folders inside* a share or hiding *which shares exist* to a user. 2. On Windows, set `AccessBased` per share and re-test with an ordinary account. 3. On Samba, use `access based share enum` for the share list and `hide unreadable` for entries, and test with a large folder before enabling the latter. 4. Keep the permission review separate: listing filters do not change who can open what.
- A packet capture shows a TREE_CONNECT response from a Windows server. How can you tell from it that access-based enumeration is on for that share?Look at the `ShareFlags` field: `SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM` is `0x00000800`. MS-SMB2 says the server sets it when the share's access-based enumeration property is on, and that the flag means directory entries are filtered by the client's permissions.
- You want users to stop seeing which Samba shares exist unless they can use them. Which parameter, and what does it ignore?`access based share enum = yes` on the share. Per smb.conf(5) it shows the share only to users with read or write access to it, evaluating share permissions only and ignoring the security descriptors on files inside the share.
- Access-based enumeration blocks users from opening files they can't list
- AccessBased is the default FolderEnumerationMode on a new share
- Samba's access based share enum filters files inside a share
- Hiding names in listings replaces the need for folder permissions
- The setting is a server-wide switch rather than a per-share one