Security Identifier


Security Identifier is a unique, immutable identifier of a user account, user group, or other security principal in the Windows NT family of operating systems. A security principal has a single SID for life, and all properties of the principal, including its name, are associated with the SID. This design allows a principal to be renamed without affecting the security attributes of objects that refer to the principal.

Overview

Windows grants privileges and access to resources based on access control lists. Each entry on the list defines one SID and a set of permissions for that SID. When a user logs into a PC, Windows generates an access token that contains the user SID, the group SIDs to which the user account belongs, and the user privilege level. When a user requests access to a resource, its ACL is checked against the user's access token to permit or deny particular action on a particular object.

Structure

The human-readable representation of a SID is a string that starts with "S-" and consists of several dash-separated numbers. For example, "S-1-5-21-3623811015-3361044348-30300820-1013" could be a user account's SID. The following table explains the components of this example SID.
ComponentExampleExplanation
HeaderSIdentifies the string as a SID
Revision level1The version number of the SID specification., "1" is the only valid number.
Authority5See below
Subauthorities21-3623811015-3361044348-30300820In this example, "21" indicates a "domain" subauthority. The following 96-bit ID is a domain identifier.
Relative ID 1013Uniquely identifies the principal within its subauthority group. In the context of domain accounts, RIDs greater than 1000 indicate an admin-defined principal.

Originally, SIDs were supposed to allow arbitrarily deep nesting, with each level allowed to create sub-authorities underneath itself. However, that goal was abandoned early in Windows NT development, when it was decided that it would be too unmanageable in practice; by then, however, the SID format had already been finalized and was in heavy use in the Windows code.

Identifier authority

Identifier authorities are formally defined as six-byte quantities. The identifier authority is expressed in decimal if its value is less than 232, otherwise in hexadecimal. However, while this is the behavior formally defined by Microsoft, and implemented by the relevant Windows APIs, hexadecimal identifier authorities appear to have never been used in practice. All known values fit in the least significant byte, and the other 5 bytes are always zero. Identifier authorities are stored in big-endian format, even on little-endian CPU architectures.
AuthorityFormal nameFirst introducedNotes
0Null Authoritye.g., "Nobody"
1World Authoritye.g., well-known groups such as "Everyone".
2Local Authoritye.g., flag SIDs like "CONSOLE LOGON"
3Creator Authority
4Non-unique Authority
5NT AuthorityManaged by the NT security subsystem. There are many sub-authorities such as "BUILTIN" and every Active Directory Domain
6Site Server AuthorityWindows XP
7Internet Site AuthorityWindows XP
8Exchange AuthorityWindows XP
9Resource Manager AuthorityWindows Server 2003
10Passport Authority
11Microsoft Account AuthorityWindows 8
12Azure Active DirectoryWindows 10
15App Package Authority Windows Server 2012All capability SIDs begin at S-1-15-3. By design, a capability SID does not resolve to a friendly name. The most commonly used capability SID is S-1-15-3-1024-1065365936-1281604716-3511738428-1654721687-432734479-3232135806-4053264122-3456934681
16Mandatory Label AuthorityWindows VistaUsed as part of Mandatory Integrity Control
17Scoped Policy ID Authority
18Authentication Authority
19Process Trust Authority-

Domain SIDs

SIDs that start with "S-1-5-21" are noticeably longer than most other SIDs. Their general format is: S-1-5-21--, where is in the form of <32-bit>-<32-bit>-<32-bit>.
The Domain ID uniquely identifies a Windows domain. The RID specifies a principal within that domain.
If the RID portion is greater than 1000, the resulting SID pertains an admin-defined user account, user group, or computer account, e.g., S-1-5-21-3361044348-303008203623811015-1001. The name of this account could be anything, e.g., Domain.local\JaneDoe.
If the RID portion is smaller than 1000, the resulting SID pertains a predefined user account or user group. For example, RID 500 identifies the controversial "Administrator" user account while RID 512 pertains the "Domain Admins" group.

Machine SIDs

Machine SIDs are variety of domain SIDs with a 96-bit domain ID but no RID. Their general format is: S-1-5-21-, where is in the form of <32-bit>-<32-bit>-<32-bit>.
The machine SID is stored in the SECURITY hive of the Windows Registry, more specifically at HKEY_LOCAL_MACHINE\SECURITY\SAM\Domains\Account. This key has two values: F and V. The latter is a raw binary value that has the machine SID embedded within it at the end of its data.
The machine SID is stored in a raw-bytes form in the registry. To convert it into the more common numeric form, one interprets it as three, little endian, 32-bit integers, converts them to decimal, and add hyphens between them.
Raw form 2E,43,AC,40,C0,85,38,5D,07,E5,3B,2B
Split the bytes into 3 groups of four octets2E,43,AC,40 - C0,85,38,5D - 07,E5,3B,2B
Reverse the order of bytes in each group40,AC,43,2E - 5D,38,85,C0 - 2B,3B,E5,07
Convert each group into decimal1085031214 - 1563985344 - 725345543
Add the machine SID prefixS-1-5-21-1085031214-1563985344-725345543

Service SIDs

Service SIDs are a feature of service isolation, introduced in Windows Vista and Windows Server 2008. Any service with the "unrestricted" SID-type property will have a service-specific SID added to the access token of the service host process, allowing permissions for a single service to be managed without necessitating the creation of service accounts.
Each service SID is a local, machine-level SID that has the general form of S-1-5-80-. To generate , Windows copies the service name, converts all characters to uppercase, and calculates the SHA-1 digest of said uppercase name. This digest becomes the . The sc.exe command can be used to generate this special SID value; for example, given the "dnscache" service:

C:\>sc query
NAME: dnscache
SERVICE SID: S-1-5-80-859482183-879914841-863379149-1145462774-2388618682

Therefore, the "dnscache" service can be referred to as either NT SERVICE\dnscache or S-1-5-80-859482183-879914841-863379149-1145462774-2388618682. Since a Service SID is determined exclusively by the service name, the value of the SID for a given service is always the same across all machines wherever the service runs.

Duplicated SIDs

A common method of mass-producing Windows PCs is to install Windows on a template machine, and duplicate its disk sector by sector to other identical machines. As a result, these mass-produced machines are identical in every respect, including their SIDs.
Microsoft engineer Mark Russinovich is the creator of a utility called NewSID, the purpose of which is to solve "The SID Duplication Problem." Microsoft has retired the utility on November 2, 2009, because, Mark and the Windows security team have concluded that duplicate SIDs do not pose any problem whatsoever.