2.7 SDDL Text Codec

The SDDL codec converts between the binary wire forms and their human-readable SDDL text (MS-DTYP §2.5.1). This is a pure-userspace facility — the kernel speaks only binary — so it lives entirely in libpeios. All four entries use the two-call protocol (cap == 0 to probe) and fail with EINVAL on malformed input.

ssize_t peios_sddl_parse_sd(void *out, size_t cap, const char *sddl);
ssize_t peios_sddl_format_sd(char *out, size_t cap, const void *sd, size_t sd_len);
  • peios_sddl_parse_sd parses SDDL text (for example "O:SYG:BAD:(A;;FA;;;BA)") into self-relative SD wire bytes.
  • peios_sddl_format_sd renders SD wire bytes back to a NUL-terminated SDDL string (length excludes the NUL, so allocate len + 1).

These are the friendliest way to construct a descriptor when you have one written down — parse the string rather than assembling ACEs by hand — and the friendliest way to log or display one.

2.7.1 Conditional expressions #

Callback ACEs carry a conditional expression as compiled "artx" bytecode. The codec converts between that bytecode and its SDDL expression text:

ssize_t peios_sddl_parse_condition(void *out, size_t cap, const char *expr);
ssize_t peios_sddl_format_condition(char *out, size_t cap, const void *artx, size_t len);
  • peios_sddl_parse_condition compiles an expression such as @User.Title == "PM" into the bytecode you place in a callback ACE's app_data.
  • peios_sddl_format_condition renders bytecode back to text (with no outer parentheses), length excluding the NUL.

So the round trip for a conditional ACE is: write the condition as text → peios_sddl_parse_condition → put the bytecode in peios_ace_spec.app_data with a callback ACE type → add it to an ACL builder.

2.7.2 Input limits and malformed data #

Conditional expressions have a maximum tree depth of 128. Each comparison, existence check, membership test, logical operator, or composite operand adds one level; scalar operands add none. For example, a comparison has depth one, and adding 127 negations reaches the limit. Long && and || chains also count because each operator adds a level to the resulting tree.

Text parsing also limits nested parentheses, negations, and composite braces to 128 levels along any one parsing path. Delimiters inside string literals do not count. These limits apply when parsing conditional ACEs inside a descriptor as well as when converting a standalone condition. The bytecode decoder applies the same tree limit, including nested composite operands.

Inputs beyond either limit fail with EINVAL; simplify the expression before retrying. The C functions return -1 and leave the output buffer untouched.

GUID fields require ASCII hexadecimal digits in the standard hyphenated form. Malformed Unicode GUID text fails with EINVAL. When reading resource claims, the codec checks that the complete value-offset table fits inside the supplied bytes before allocating storage for its entries. An impossible or truncated table also fails with EINVAL.

2.7.3 Descriptor text and omitted components #

Sections use O:<sid>G:<sid>D:<acl>S:<acl>. Each is optional but can appear only once. Formatting orders them as owner, group, DACL, and SACL.

D: is an empty, present DACL. D:NO_ACCESS_CONTROL and an omitted DACL encode the absent-DACL state. The marker can accompany ACL flags but not ACEs. The same representation rule applies to SACL absence. The formatter can omit an absent ACL unless flags need preserving, and uses D:NO_ACCESS_CONTROL for an otherwise empty descriptor.

These rules describe a complete supplied descriptor. In a tool that queried only selected components, an omitted section can instead mean "not queried." Formatting cannot recover missing components. Do not use matching partial SDDL strings as proof of complete descriptor equality or as a full backup.

An ACE has six semicolon-separated fields, or seven for a payload:

(type;flags;rights;object_guid;inherit_object_guid;account_sid;payload)

Object GUID fields apply to object ACEs; supplying them for other types is an error. Callback payloads carry conditions, and resource-attribute payloads carry claims. For example, O:SYG:SYD:(A;OICI;GA;;;SY) names SYSTEM as owner and group and grants SYSTEM generic-all with object/container inheritance. This explains the string; it does not select a suitable policy for every object.

2.7.4 ACL control flags #

FlagMeaning
PProtected. The ACL does not inherit from its parent.
AIAuto-inherited. The ACL was produced by inheritance propagation.
ARAuto-inherit required. Requests that propagation be applied.

2.7.5 ACE type codes #

CodeACE type
AAccess allowed
DAccess denied
AUSystem audit
OAAccess allowed, object
ODAccess denied, object
OUSystem audit, object
XAAccess allowed, callback — carries a condition
XDAccess denied, callback — carries a condition
XUSystem audit, callback — carries a condition
ZAAccess allowed, callback object
ZDAccess denied, callback object
ZUSystem audit, callback object
ALSystem alarm — continuous auditing
OLSystem alarm, object
XLSystem alarm, callback — carries a condition
ZLSystem alarm, callback object
MLMandatory label — the integrity level
TLProcess trust label
RAResource attribute — carries a claim
SPScoped policy identifier
FLAccess filter — carries a condition

2.7.6 ACE flag codes #

CodeMeaning
CIContainer inherit — child containers receive it.
OIObject inherit — child objects receive it.
NPNo propagate — children receive it, grandchildren do not.
IOInherit only — it does not apply to the object carrying it.
IDInherited — this ACE arrived by propagation.
SAAudit successful access.
FAAudit failed access.

2.7.7 Rights codes #

CodeRight
GAGeneric all
GRGeneric read
GWGeneric write
GXGeneric execute
CodeRight
SDDelete
RCRead control — read the descriptor
WDWrite DACL
WOWrite owner
CodeMaskRight
FA0x001F01FFAll file access
FR0x00120089File read
FW0x00120116File write
FX0x001200A0File execute
CodeMaskRight
KA0x000F003FAll key access
KR0x00020019Key read
KW0x00020006Key write
KX0x00020019Key execute
CodeRight
CCCreate child
DCDelete child
LCList children
SWSelf write
RPRead property
WPWrite property
DTDelete tree
LOList object
CRControl access
CodePolicy
NWNo write up
NRNo read up
NXNo execute up

2.7.8 Absolute SID aliases #

CodeSIDPrincipal
WDS-1-1-0Everyone
ANS-1-5-7Anonymous
IUS-1-5-4Interactive
NUS-1-5-2Network logon
SUS-1-5-6Service
RCS-1-5-12Restricted code
WRS-1-5-33Write-restricted code
PSS-1-5-10Principal self
EDS-1-5-9Enterprise domain controllers
AUS-1-5-11Authenticated Users
SYS-1-5-18Local System
LSS-1-5-19Local Service
NSS-1-5-20Network Service
ACS-1-15-2-1All application packages
CodeSIDPrincipal
COS-1-3-0Creator Owner
CGS-1-3-1Creator Group
OWS-1-3-4Owner rights
CodeSIDPrincipal
LWS-1-16-4096Low integrity
MES-1-16-8192Medium integrity
MPS-1-16-8448Medium-plus integrity
HIS-1-16-12288High integrity
SIS-1-16-16384System integrity
CodeSIDPrincipal
BAS-1-5-32-544Administrators
BUS-1-5-32-545Users
BGS-1-5-32-546Guests
PUS-1-5-32-547Power users
AOS-1-5-32-548Account operators
SOS-1-5-32-549Server operators
POS-1-5-32-550Printer operators
BOS-1-5-32-551Backup operators
RES-1-5-32-552Replicator
RUS-1-5-32-554Pre-Windows 2000 compatible access
RDS-1-5-32-555Remote desktop users
NOS-1-5-32-556Network configuration operators
MUS-1-5-32-558Performance monitor users
LUS-1-5-32-559Performance log users
ISS-1-5-32-568IIS users
CYS-1-5-32-569Cryptographic operators
ERS-1-5-32-573Event log readers
CDS-1-5-32-574Certificate service DCOM access
RAS-1-5-32-575RDS remote access servers
ESS-1-5-32-576RDS endpoint servers
MSS-1-5-32-577RDS management servers
HAS-1-5-32-578Hyper-V administrators
AAS-1-5-32-579Access control assistance operators
RMS-1-5-32-580Remote management users

2.7.9 Context-sensitive codes #

CodeAs a rightAs an accountElsewhere
WDWrite DACLEveryone
RCRead controlRestricted code
AUAuthenticated UsersACE type: system audit
RARDS remote access serversACE type: resource attribute
FAAll file accessACE flag: audit failed access
SDDelete

2.7.10 Numeric masks and canonical formatting #

An entirely ASCII-digit rights field is an unsigned decimal mask. Leading zeros remain decimal; signs, non-ASCII digits, overflow beyond 4294967295, and mixing decimal text with mnemonic codes are rejected. Hexadecimal uses 0x and consumes the rest of the field, so it can follow mnemonic rights only as the final portion. FRFX0x6 combines file read/execute with the two additional bits.

The formatter prefers composite masks and does not preserve every accepted spelling. KX has the same mask as KR; one spelling is emitted. Directory object codes share bits with other vocabularies, so outside mandatory-label ACEs formatting can use hexadecimal rather than guess an object class. Mandatory-label masks use their label vocabulary. Unknown ACE types fail formatting instead of silently disappearing.

XL and ZL are Peios callback-alarm extensions and are not portable Windows ACE codes. Domain-relative aliases such as DA and machine-relative LA cannot resolve without a base SID; the codec rejects them with an explanation. Use an explicit full SID. BUILTIN aliases are absolute despite their names. The null SID and protected-process integrity SID have no short alias.

A displayed f in the sd command's rights summary is that command's shorthand, not the SDDL grammar or a hexadecimal nibble. Consult the tool's manual before feeding rendered output back into a parser.

Edit this page