# 5.5 ACE Ordering

_Peios Specifications / PCDS / Security Descriptor_

> Canonical DACL order and why it is load-bearing — first-writer-wins means position decides the outcome — plus the ordering rules for a SACL.

The order of ACEs in a DACL determines the outcome of AccessCheck. AccessCheck
walks the DACL from first ACE to last, and the first-writer-wins principle
means each bit is decided at most once. ACE ordering is semantically
load-bearing.

## 5.5.1 Canonical ordering

Tools that author SDs SHOULD produce canonically-ordered DACLs. KACS MUST NOT
reject non-canonical DACLs — it evaluates whatever order it receives — but
non-canonical ordering can produce results that contradict administrative
intent.

The canonical order is:

1. **Explicit deny ACEs** — deny rules placed directly on this object (not
   inherited).
2. **Explicit allow ACEs** — allow rules placed directly on this object.
3. **Inherited deny ACEs** — deny rules inherited from parent objects (nearest
   parent first).
4. **Inherited allow ACEs** — allow rules inherited from parent objects.

Within each category, object-type ACEs (those scoped to a specific property
GUID) SHOULD be ordered after whole-object ACEs.

This ordering guarantees: explicit rules override inherited rules, denials
override allows at the same level, and whole-object rules override
property-scoped rules.

KACS kernel paths that evaluate, store, query, or set caller-supplied DACLs
MUST preserve the caller-supplied ACE order. KACS MUST NOT canonicalise those
DACLs by reordering deny ACEs, allow ACEs, whole-object ACEs, or object-type
ACEs.

When KACS constructs a file DACL by combining an explicit source DACL with an
inherited source DACL, it MUST emit the explicit ACE sequence before the
inherited ACE sequence. Within each sequence, KACS MUST preserve the
source-relative ACE order. This recombination rule is not a general canonical
sorting step.

## 5.5.2 SACL ordering

SACLs do not have a canonical ordering requirement. Audit ACEs are evaluated
independently (each matching ACE generates its own audit event). The mandatory
label ACE, resource attribute ACEs, and scoped policy ID ACEs are located by
type scan, not by position.
