Hello @fengchun chen ,
I reproduced your scenario on Windows 11 Enterprise (10.0.26200), pipe created from D:(A;;GRGW;;;WD) via ConvertStringSecurityDescriptorToSecurityDescriptorW + CreateNamedPipeW(PIPE_ACCESS_DUPLEX), then read back, and grouped the findings below by what was observed, what the documentation states, and what I'd recommend.
What I observed
Input SD (before create) : D:(A;;GWGR;;;WD) mask = 0xC0000000
GetKernelObjectSecurity : O:LAD:(A;;0x12019f;;;WD) mask = 0x0012019F
GetSecurityInfo(SE_KERNEL_OBJECT) : O:LAD:(A;;0x12019f;;;WD) mask = 0x0012019F
Client handle with FILE_READ_DATA only -> GetKernelObjectSecurity fails, ERROR_ACCESS_DENIED (5)
CreateNamedPipeW with READ_CONTROL OR'ed into dwOpenMode -> ERROR_INVALID_PARAMETER (87)
0x0012019F == FILE_GENERIC_READ (0x120089) | FILE_GENERIC_WRITE (0x120116)
-
GetKernelObjectSecuritysucceeds on theCreateNamedPipeWserver handle and returns exactly the same security descriptor asGetSecurityInfo(SE_KERNEL_OBJECT). - The
GR/GWgeneric bits are not retained. The ACE mask read back isFILE_GENERIC_READ | FILE_GENERIC_WRITE; the mapping happens once, when the SD is assigned to the object at creation. - A handle without
READ_CONTROLcannot read the DACL.
What the documentation states
- Named Pipe Security and Access Rights names
GetSecurityInfo/SetSecurityInfoas the functions for a named pipe's security descriptor. It also states that aPIPE_ACCESS_DUPLEXserver handle carriesFILE_GENERIC_READ | FILE_GENERIC_WRITE | SYNCHRONIZE, both of which includeREAD_CONTROL(which is why it cannot be added todwOpenModeexplicitly). - GetKernelObjectSecurity is documented generically for "a kernel object"; named pipes are not called out. Its Remarks give the handle requirements:
READ_CONTROLfor owner/group/DACL,ACCESS_SYSTEM_SECURITY(withSE_SECURITY_NAMEenabled) for the SACL. -
GR=GENERIC_READ,GW=GENERIC_WRITE(ACE Strings). Generic rights map to object-specific rights through the object type'sGENERIC_MAPPING(ACCESS_MASK, Generic Access Rights); for files and named pipes,GENERIC_READ -> FILE_GENERIC_READ,GENERIC_WRITE -> FILE_GENERIC_WRITE. - The routine that builds the SD for a new object takes that mapping as input: SeAssignSecurityEx (
GenericMapping- "mapping between each generic right to object-specific rights"); user-mode equivalent CreatePrivateObjectSecurity. - Not stated anywhere: that
GetKernelObjectSecurityis supported specifically for named pipes, or that a read-back will always return the expanded object-specific mask rather than generic bits. The behavior above is consistent and long-standing, but there is no sentence guaranteeing it.
What I recommend
- API: use
GetSecurityInfo(hPipe, SE_KERNEL_OBJECT, ...)as the documented, supported call for named pipes.GetKernelObjectSecurityworks and gives the same result, but I would not cite it as the supported API in a compliance context. - Mask comparison: normalize both sides through the file/pipe generic mapping so the test is correct regardless of which representation is returned:
GENERIC_MAPPING gm = { FILE_GENERIC_READ, FILE_GENERIC_WRITE, FILE_GENERIC_EXECUTE, FILE_ALL_ACCESS };
ACCESS_MASK expected = GENERIC_READ | GENERIC_WRITE; // from your SDDL
MapGenericMask(&expected, &gm); // -> 0x0012019F
ACCESS_MASK actual = ace->Mask;
MapGenericMask(&actual, &gm); // no-op if already specific
// compare expected == actual
- Security note: on named pipes
FILE_APPEND_DATAandFILE_CREATE_PIPE_INSTANCEare the same bit, soGWgranted toWD(Everyone) also lets anyone create additional pipe instances. The named-pipe documentation recommends granting individual rights instead ofFILE_GENERIC_WRITE. - Formal guarantee: if you need a written statement beyond documented mapping + observed behavior for a compliance deliverable, open a Microsoft support case, or file documentation feedback on the
GetKernelObjectSecurity/ named-pipe pages asking that named pipes be explicitly called out.
Hope these information help. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.
Thank you.