Fix SDDL SID alias table missing ten aliases Windows resolves (Fixes #133) - #136
Merged
Conversation
…133) SDDLToSID was populated from the MS-DTYP 2.5.1.1 sid-token table and was missing three of its rows, so SDDL using them failed to parse in both ACE trustee position and inside SID(...) in a conditional expression: AC S-1-15-2-1 All Application Packages UD S-1-5-84-0-0-0-0-0 User Mode Drivers WR S-1-5-33 Write Restricted Code AC in particular appears in the default DACL of many Windows objects, so descriptors collected from real systems failed rather than degrading. Seven further aliases are resolved by Windows but absent from the MS-DTYP table. Their values were read from the 67-entry alias table in sechost.dll (Windows Server 2025) at .data RVA 0x99f30, whose record layout is alias at +0x02, RID at +0x18 and a SID-prefix template selector at +0x1c. The template decode was validated against 19 aliases with independently known SIDs before being trusted on these: AS S-1-18-1 Authentication Authority Asserted Identity SS S-1-18-2 Service Asserted Identity HO S-1-5-32-584 BUILTIN\\User Mode Hardware Operators SH S-1-5-32-585 BUILTIN\\OpenSSH Users AP S-1-5-21-0-0-0-525 Protected Users KA S-1-5-21-0-0-0-526 Key Admins EK S-1-5-21-0-0-0-527 Enterprise Key Admins Domain-relative entries follow the existing placeholder-domain convention in this map. EK resolves against the forest root domain on Windows rather than the local domain; that distinction is not representable while the domain is a placeholder and is noted in the map comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Closes #133Root Cause
SDDLToSIDwas transcribed from the MS-DTYP 2.5.1.1sid-tokentable and three of its rows were omitted:AC,UDandWR. Because the map is the only alias source for both the ACE trustee path and theSID(...)operand path inside a conditional expression, any SDDL string using one of them failed to parse outright.AC(ALL APPLICATION PACKAGES) is present in the default DACL of many Windows files, registry keys and directory objects, so this affected descriptors collected from real systems rather than only hand-written ones.Separately, the MS-DTYP table itself is out of date relative to Windows: seven aliases that the OS resolves have no row in it, so a map faithful to the spec is still incomplete against real input.
Fix Description
Ten entries added to
SDDLToSID, grouped with the existing comment structure (well-known, BUILTIN, domain-relative), plus a new group for the application-package and asserted-identity authorities.The three MS-DTYP omissions are straightforward. The seven undocumented values were not guessed: they were read out of the alias table Windows itself walks —
sechost.dll(Windows Server 2025),.dataRVA0x99f30, 67 entries of stride0x68, with the alias at record+0x02, the RID at+0x18and a SID-prefix template selector at+0x1c. Before trusting that decode on the unknown aliases it was validated against 19 aliases whose SIDs are independently known (WD,SY,BA,AC,AU,AN,IU,LS,NS,CO,CG,OW,HI,ME,SI,LW,DA,SA,EA), with zero mismatches.Domain-relative additions follow the placeholder-domain convention already used in this map (
S-1-5-21-0-0-0-<rid>) rather than introducing a second representation.One deliberate non-change: on Windows,
EKresolves against the forest root domain, not the local domain (its table entry uses a different template selector, the same one asSA,EAandRO). That distinction cannot be represented while the domain portion is a placeholder, so it is recorded in a comment instead of encoded. It matters for any future change that resolves a real domain SID, because expanding a forest-root alias against the local domain yields a different, valid-looking principal instead of an error — a wrong answer rather than a failure.How Verified
Runtime, before the fix — each alias inside a conditional expression:
Runtime, after the fix — all ten resolve, in both operand and trustee position:
The trustee line also shows the derived reverse map resolving the new SIDs back to their aliases.
Repository suite —
go test ./...green;gofmt -lclean on both changed files;go vetreports nothing.Test Coverage
Added — in
sddl/sid/sid_test.go:TestSDDLAliases_MSDTYPCoverage— asserts every one of the 61sid-tokenentries from MS-DTYP 2.5.1.1 resolves. This is the regression guard for the actual bug and fails onAC,UD,WRwithout the fix.TestSDDLAliases_WindowsExtras— pins all ten added aliases to their exact SIDs and checks the reverse mapping round-trips.TestSDDLAliases_NoDuplicateSIDs— guards the derivedSIDToSDDL: two aliases sharing a SID string would make the reverse map depend on Go map iteration order. It passes today and prevents a future addition from silently introducing that nondeterminism.Scope of Change
sddl/sid/sid.go,sddl/sid/sid_test.goRisk and Rollout
Additive only — the change can make previously failing input parse, and cannot change the result of input that already parsed. Safe to merge without staged rollout.
Notes
sddl/sddl_functions_test.gois flagged bygofmt -lonmainalready; it is untouched here to keep the diff to the fix.Two properties of the Windows alias table found while sourcing these values are recorded in #133 and not acted on here:
CYis duplicated in that table (two identical entries), andCNis absent from the 67-entry table, appearing only in a separate 15-entry domain-RID table at RVA0x99910.CNis already present and correct in this map.Filed alongside this from the same investigation: #134 (SDDL ACE types
TL/FLunusable) and #135 (the two undocumented conditional-expression tokens0xfc/@TOKEN.and0xa3/&).