# Identity and Access

---

# Security Identifiers

_Peios / Using Peios / Identity and Access_

> What a security identifier (SID) is, how to read its string form, which kinds of principal have one, and why permissions name SIDs rather than account names.

A security identifier (SID) is the value Peios uses to identify a principal: a
user, a group, a service, the machine, or a built-in identity such as
Everyone. Every permission on every object names SIDs, and every running
program carries SIDs that say who it is. When you read a permission or
diagnose a refusal, you are comparing SIDs.

## Reading a SID

A SID is binary, but tools show it as a string that starts with `S-1`:

```text
S-1-5-21-3623811015-3361044348-30300820-1013
```

The parts after `S-1` are numbers assigned by an authority. The `5` here is
the authority, and the numbers after it narrow down to one principal. The last
number is the relative identifier (RID), which tells principals apart within
the same domain. Short SIDs belong to identities that every Peios system
shares:

| SID | Identity |
|---|---|
| `S-1-5-18` | Local System, the operating system's own identity |
| `S-1-5-32-544` | The built-in Administrators group |
| `S-1-1-0` | Everyone |

These shared SIDs are called well-known SIDs. [Well-Known SIDs](/peios/using-peios/identity-and-access/well-known-sids.md)
lists the ones you meet most often.

## Names are labels

An account's name can change. Its SID doesn't. Renaming an account keeps its
SID, so every permission that names the account still applies to it. A deleted
account's SID is never given to another account, so old permissions can't
start granting access to a stranger.

For the same reason, compare SIDs rather than names when you check who has
access. Two different strings can spell the same SID, and a name only tells
you what a tool chose to display.

A SID on its own doesn't tell you what a principal can do. Group membership,
privileges, and the other details of a principal's authority come from the
[access token](/peios/using-peios/identity-and-access/access-tokens.md) it runs with.

## SIDs that aren't accounts

Some SIDs identify something other than a person or a group:

- **Service SIDs** identify one service, written by name as `SERVICE\loregd`.
  A service's programs carry its service SID as a group, so a permission can
  admit one service without admitting everything that runs as the same
  account.
- **Logon SIDs** identify one sign-in or other logon, in the form
  `S-1-5-5-X-Y`. They let a permission admit one session without admitting
  every session of the same account. See
  [Logon Sessions](/peios/using-peios/identity-and-access/logon-sessions.md).
- **Integrity labels**, in the form `S-1-16-n`, mark a level of trust. See
  [Integrity Levels](/peios/using-peios/identity-and-access/integrity-levels.md).
- **Placeholders** stand in for another identity in a permission. When a new
  object inherits a permission that names Creator Owner, for example, the new
  object's owner takes its place.

## Where SIDs are defined

The Peios Common Data Structures specification defines the
[SID format](/specifications/pcds/sid/binary-format.md) and the complete
[catalog of well-known SIDs](/specifications/pcds/sid/well-known-sids.md). It is
the authority for every assigned value.

---

# Access Tokens

_Peios / Using Peios / Identity and Access_

> What an access token holds, how a program gets one at sign-in or from its parent, the difference between primary and impersonation tokens, and why account changes don't reach running programs.

An access token is the identity a running program acts with. Each thread in a
program carries one, and every time the thread opens a file, reads a registry
key, or sends a signal, Peios checks the request against that token. The
token, not the account name a program displays, decides what the program can
do.

## What a token holds

A token holds the facts Peios needs to decide a request:

- **The user.** The security identifier (SID) of the principal the token
  represents.
- **Groups.** The SIDs of the groups the principal belongs to, and the logon
  SID of its [logon session](/peios/using-peios/identity-and-access/logon-sessions.md).
- **Privileges.** The system operations the principal can perform. See
  [Privileges](/peios/using-peios/identity-and-access/privileges.md).
- **An integrity level.** A level of trust that limits what the token can
  change. See [Integrity Levels](/peios/using-peios/identity-and-access/integrity-levels.md).
- **Defaults for new objects.** The owner and permissions that objects the
  program creates receive.

Some of these fields can be adjusted while the token is in use. A program can
turn one of its privileges on or off, or turn a group off. The identity
fields, such as the user, the set of groups, and the integrity level, can't be
changed after the token is created.

To see the token a program is using, run `token show`. See
[Inspecting Effective Identity](/peios/using-peios/identity-and-access/token.md).

## How a program gets a token

A program can copy its token or make a weaker version of it, but creating a
token for an identity is reserved for the kernel and two trusted programs,
authd and peinit. Tokens come from three places:

- **At boot,** the kernel creates the token for the operating system's own
  identity, Local System. The service manager, peinit, starts with it.
- **At sign-in,** authd, the authentication service, checks your credentials
  against policy and creates a token for you. The program you signed in
  through, such as the console or the desktop, starts your session with it.
- **For a service,** peinit gives the service's first program the token for
  the service's account.

After that, a new program inherits a copy of its parent's token. Running
another program file keeps the same token, unless the file is marked to run
at a lower integrity level. So everything started from your desktop or your
shell runs with the identity you signed in with.

## Primary and impersonation tokens

A program's own token is its primary token, and its threads share it. A
thread can also take on another token for a while, which is called
impersonation. A service uses impersonation to act for a client: it handles
the client's request with the client's identity, so the request can do only
what the client could do. When the thread stops impersonating, it returns to
the primary token.

A new program never inherits impersonation. It starts with its parent's
primary token.

## Account changes and running programs

A token records the account as it was when the token was created. Changing an
account afterward, for example adding it to a group, disabling it, or
changing its privileges, doesn't change tokens that already exist. Programs
already running keep their previous access.

To pick up a change, start a new sign-in. To stop a running session, end it:
[Inspecting and Ending Sessions](/peios/using-peios/local-accounts/logonse.md) covers the
command and what it reaches.

The kernel's [token model](/kernel/internals/kacs/tokens/the-token-model.md)
describes every field and operation.

---

# Privileges

_Peios / Using Peios / Identity and Access_

> What a privilege allows, how machine policy rather than group membership assigns privileges, the states a privilege has on a token, and the privileges you meet most often.

A privilege lets a program perform a system operation that has no object to
put a permission on: shutting down the machine, setting the clock, or loading
a kernel module. Permissions live on objects, and privileges live on the
program asking. Some privileges also let a program reach objects in ways their
permissions alone wouldn't allow, such as reading a file for a backup.

## Policy assigns privileges

Privileges come from machine policy, not from who you are. Belonging to the
Administrators group gives an account no privilege by itself. When you sign
in, authd reads the policy under `Machine\Generic\Authn\Policy`, combines the
privileges granted to your account and to each of your groups, and puts the
result in your [access token](/peios/using-peios/identity-and-access/access-tokens.md).

The policy that Peios ships gives every account a small set of privileges
and gives Administrators many more, such as `SeShutdownPrivilege` and
`SeBackupPrivilege`. It deliberately gives no one the privileges that create
or install tokens. [Granting Access](/peios/using-peios/authentication/granting-access.md)
explains the policy and how to change it.

A token keeps the privileges it was created with. A change to policy reaches
only tokens created after it, so sign in again to pick it up.

## Privilege states

A privilege on a token is in one of these states:

- **Present.** The token has the privilege. A privilege can't be added to a
  token after it is created.
- **Enabled.** The privilege is in effect. A program can use a privilege only
  while it is both present and enabled. authd creates tokens with every
  granted privilege enabled.
- **Removed.** The privilege is gone from the token for good. Removing a
  privilege can't be undone, unlike turning it off.

A program that needs a privilege only for a moment can turn it off when it is
done, or remove it, so a later mistake can't use it.

## Common privileges

These are the privileges you are most likely to see in a token or a policy:

| Privilege | Allows |
|---|---|
| `SeChangeNotifyPrivilege` | Passing through directories without permission to each one. Every account has it. |
| `SeShutdownPrivilege` | Shutting down or rebooting the machine |
| `SeRemoteShutdownPrivilege` | Shutting down or rebooting from a remote session, in addition to `SeShutdownPrivilege` |
| `SeBackupPrivilege` | Reading any object for a backup, whatever its permissions |
| `SeRestorePrivilege` | Writing any object to restore a backup, whatever its permissions |
| `SeTakeOwnershipPrivilege` | Taking ownership of any object |
| `SeSecurityPrivilege` | Reading and changing an object's audit settings |
| `SeSystemtimePrivilege` | Changing the system clock |
| `SeImpersonatePrivilege` | Acting for a client with the client's identity |
| `SeManageVolumePrivilege` | Mounting and managing volumes |
| `SeLoadDriverPrivilege` | Loading and unloading kernel modules |
| `SeDebugPrivilege` | Inspecting and attaching to any process, whatever its permissions |
| `SeTcbPrivilege` | Operations reserved for the system's most trusted components |

Privilege names are case-sensitive: write them exactly as shown.

A privilege doesn't override every protection. `SeBackupPrivilege` and
`SeRestorePrivilege` apply only when a program asks for backup or restore
access explicitly. Neither they nor `SeDebugPrivilege` bypass Process
Integrity Protection, which guards trusted processes and the objects labeled
for them.

The kernel's [privilege catalog](/kernel/internals/kacs/privileges/privilege-catalogue.md)
is the complete list, with each privilege's exact effect.

---

# Logon Sessions

_Peios / Using Peios / Identity and Access_

> What a logon session records, how it relates to the tokens that share it, the logon types that describe how a session began, and what ending a session does.

A logon session records one occasion on which Peios established an identity:
you signing in at the console, an SSH connection, or a service starting. Every
access token belongs to exactly one logon session, and every token copied from
it shares the same session. Knowing which session a program belongs to tells
you how its identity was established, and lets you end everything that came
from one sign-in together.

A logon session is separate from a terminal's session and from a desktop
session: the word "session" names different things in each.

## What a session records

authd creates the logon session before it creates the first token for it. The
session records:

- the user's security identifier (SID);
- the logon type, which says how the session began;
- the time it was created;
- an identifier that is unique while the machine is running.

The session's logon SID, in the form `S-1-5-5-X-Y`, comes from that
identifier and is placed in the groups of every token in the session. A
permission can name the logon SID to admit one session without admitting the
account's other sessions. The identifier can recur after the machine
restarts, so don't use it as a lasting record of an account.

A session lasts as long as any token that belongs to it.

## Logon types

The logon type describes the situation, not the account: one account can
have sessions of several types at once.

| Logon type | Session begins when |
|---|---|
| `Interactive` | Someone signs in at the machine's console |
| `RemoteInteractive` | Someone signs in from another computer, over SSH or to a desktop in a browser |
| `Network` | A program on another computer authenticates to use a service here |
| `NetworkCleartext` | As `Network`, marked as using a credential that was sent unencrypted |
| `NewCredentials` | A program keeps its identity on this machine, marked as using other credentials for connections to other computers |
| `Batch` | A scheduled job starts |
| `Service` | A service starts |

Every SSH connection is `RemoteInteractive`, including a single command run
without a terminal. The names of the two variants describe their purpose, not
what happened: `NetworkCleartext` doesn't prove that credentials crossed the
network unencrypted, and `NewCredentials` doesn't make Peios forward
credentials anywhere.

Sign-in policy can permit or refuse each logon type for an account; see
[Granting Access](/peios/using-peios/authentication/granting-access.md).

## Ending a session

Ending a logon session stops the programs whose primary token belongs to it.
authd asks them to stop, then forces them. A program elsewhere that holds a
copy of one of the session's tokens keeps the session alive, so ending it
doesn't revoke every use of its identity. The Local System and service
sessions can't be ended this way.

[Inspecting and Ending Sessions](/peios/using-peios/local-accounts/logonse.md) describes the
`logonse` command.

---

# Integrity Levels

_Peios / Using Peios / Identity and Access_

> How integrity levels rank the trust of programs and objects, the five standard levels, and how the integrity check stops a less trusted program from changing a more trusted object.

An integrity level ranks how far Peios trusts a program or an object. Every
access token has one, and objects can carry one. Before Peios reads an
object's permissions, it compares the two levels. A program at a lower level
can't change an object at a higher level, even if the object's permissions
would otherwise allow it. A program handling untrusted input can therefore
run at a low level, so that a fault in it can't change the system's own files
and settings.

## The levels

Five levels are standard:

| Level | Value | Used for |
|---|---|---|
| Untrusted | 0 | Code in a sandbox |
| Low | 4096 | Services handling untrusted input |
| Medium | 8192 | Ordinary sign-ins and most services |
| High | 12288 | Administrators |
| System | 16384 | The kernel, peinit, and the system's most trusted services |

A level is written as a security identifier (SID) in the form `S-1-16-n`,
where *n* is the value. Peios compares the numbers, so a value between two
standard levels is valid too.

Your sign-in gets its level from machine policy. A token is Medium by default,
and the policy that Peios ships gives Administrators High. A token's level
can't be changed after it is created. A program file can be marked to run at
a lower level than its parent, but nothing raises a running program's level.

## The integrity check

Each object can carry a label with its level. An object without a label is
treated as Medium.

By default, a program can read an object at a higher level but can't write to
it. A label can also stop a lower-level program from reading the object or
running it. The integrity check comes before the object's permissions, and it
can only take access away: a permission can't grant what the integrity check
refuses. Rights that come from a privilege aren't removed by it.

## Integrity and process trust

Integrity levels are a property of the token, so they follow the identity a
program acts with. Process Integrity Protection is a separate mechanism that
follows the program itself, based on the signature of its program file. See
[Process Trust](/peios/using-peios/application-boundaries/process-trust.md).

The kernel documents [mandatory integrity control](/kernel/internals/kacs/access-check/mandatory-integrity-control.md)
in full.

---

# Identity and Authority

_Peios / Using Peios / Identity and Access_

> Distinguish account records, runtime tokens, authentication sessions, and permission decisions.

An account record describes a principal. Authentication establishes which
principal is requesting a sign-in. A token carries the runtime identity and
authority used by a thread. An access decision combines that token with the
object, requested operation, and applicable policy. None of these steps is
interchangeable with the others.

## A name is not a grant

A security identifier (SID) identifies a principal. Resolved names are labels;
compare parsed binary identities rather than names or a domain prefix. A SID
alone does not reveal group membership, privileges, integrity, or whether an
account is signed in. Different accepted text spellings can represent the
same parsed SID; formatting differences alone do not establish inequality.

Use [PCDS's SID reference](/specifications/pcds/sid/binary-format.md) for encoding
and the [well-known catalog](/specifications/pcds/sid/well-known-sids.md) for
assigned identities. Avoid maintaining another numeric catalog in application
documentation.

For policy, distinguish the intended audience: Authenticated Users is not
Everyone, a service identity is not every process of its hosting account,
and a logon SID identifies one authentication context rather than the account
across sign-ins. Creator Owner is an inheritance placeholder; Owner Rights
controls the owner's special grants on the object being checked. Integrity
and process-trust labels belong to their mandatory-policy mechanisms, not
ordinary group membership.

## Accounts become runtime tokens

[Local account records](/peios/using-peios/local-accounts/overview.md), source resolution,
and [authentication policy](/peios/using-peios/authentication/granting-access.md)
participate in sign-in. Token creation is privileged; the kernel does not
independently prove the truth of every claim a trusted creator supplies.
Changing an account record does not rewrite tokens already running.

A token carries a user SID, groups and their attributes, privileges,
integrity,
claims, restrictions, and session context. A privilege is a grant for specific
operations, not a substitute for identity. Integrity constrains categories of
access. Process Integrity Protection belongs to the executing program's PSB,
so impersonating another identity does not change program trust.

Claims are typed attributes. Token user/device claims, caller-supplied local
claims, and object resource attributes have different provenance. A missing
claim can evaluate to UNKNOWN: it does not satisfy a conditional allow and
can preserve a conditional denial. Do not substitute an empty value for
absence or treat a display label as a trusted claim. The [condition
specification](/specifications/pcds/security-descriptor/conditional-aces.md)
defines the logic.

## Follow the effective thread

A process's primary token is the default identity for its threads. A thread
handling a client can temporarily impersonate another token. Diagnose the
thread that performed the operation, not only the account displayed for the
process. Reverting returns to the primary token; it does not change the
process's program protection.

Token fields and operations are defined in the kernel's
[token model](/kernel/internals/kacs/tokens/the-token-model.md). Identity fields
cannot be arbitrarily relabeled by adjustment. Duplication, restriction,
privilege adjustment, and primary-token installation have different gates
and effects. A privilege can be disabled or removed; removal is not the same
as a reversible disable.

Fork gives the child an independent copy of the parent's primary token,
without inheriting an active impersonation. Threads share the primary token
but have independent impersonation state. Exec reverts impersonation and
normally retains the primary token, subject to the documented integrity
lowering rule. See [Token Lifecycle](/kernel/internals/kacs/tokens/token-lifecycle.md)
for installation convergence and exact transitions.

## Authentication sessions and elevation

A logon session records an authentication context shared by its tokens.
It is separate from a terminal's job-control session and from an interactive
environment scope. Do not use a boot-local session identifier as a durable
account identity or assume its value cannot recur on another boot.

A session's type records how it was created. Local console authentication,
remote SSH/GXWI sign-in, and service launch have different provenance.
The type is not a blanket access grant; token groups and specific kernel
operations give it effects. A NetworkCleartext name alone does not prove a
password traversed an unencrypted network, and NewCredentials metadata does
not implement an outbound credential broker by itself.

A linked Full/Limited pair is a kernel mechanism available to a trusted
broker. It does not establish that every interactive sign-in uses a pair,
that a consent interface exists, or that the caller can install its partner.
The role can remain after the active link disappears. Use the
[linked-token reference](/kernel/internals/kacs/tokens/linked-tokens-and-elevation.md)
and the actual broker's documented workflow.

Ending a session coordinates its processes; it does not revoke every token
handle held elsewhere. Token expiration metadata is not a kernel access-check
timer. Follow [Inspecting and Ending Sessions](/peios/using-peios/local-accounts/logonse.md)
for the supported command and its completeness limits.

## Privilege state and operation authority

A token can have a privilege present but disabled. Enabling a present
privilege is different from adding one; permanently removed privileges cannot
be re-enabled on that token. Enabled-by-default state is a creation property,
and the used bit records exercise rather than a timestamped use history.
Consult the [privilege model](/kernel/internals/kacs/privileges/the-privilege-model.md)
and [adjustment rules](/kernel/internals/kacs/tokens/token-adjustment.md) before
interpreting or changing those states.

Some privileges gate kernel operations directly, some contribute rights in
AccessCheck, some are interpreted by services, and some names are reserved.
A name in a catalog does not prove enforcement by every component. Backup and
restore contributions require the relevant intent as well as enabled
privileges; the object manager's actual open/update path supplies its own
context. PIP, confinement, and central policy can still constrain grants.
Removing privileges and adding restricting SIDs are separate reductions.

---

# Diagnosing an Access Refusal

_Peios / Using Peios / Identity and Access_

> Combine the failing operation, effective caller, object policy, and recorded evidence before proposing a correction.

A refusal can be the intended policy working. Start with evidence from the
failed operation; a token dump or an isolated allow ACE cannot explain every
possible access decision.

## Gather the actual request

1. Record the operation, time, message, and exact error or exit status.
   Identify the process, failing thread, and managing service where known.
2. Identify the object and requested rights. Keep a registry key separate
   from its value name. Distinguish a link from its target and an open from
   an operation using an already-open handle.
3. Inspect the relevant effective token with existing authority. Preserve
   target selectors and the observation time: impersonation can have ended
   before inspection. Without a target, a tool usually observes itself.
4. Read the descriptor components available to that caller. Mark unreadable
   or undisplayed components as unknown, not empty.
5. Correlate recorded evidence and its collection limits. After a reviewed
   correction, repeat the original operation in its intended context.

An application can request more rights than its visible action suggests.
Capture the exact mask when diagnostics provide it. Rights on an existing
handle reflect the earlier open; today's descriptor does not reconstruct
that earlier decision.

## Choose a supported view

| Question | Read-only starting point | Limit |
|---|---|---|
| Process identity | `token show --pid PID --all` | Primary token, not necessarily the failing thread's effective token. |
| Impersonating thread | `token show --pid PID --tid TID --all` | Consecutive live queries cannot reconstruct an earlier token. |
| Present/enabled privileges | `token privs --pid PID` | Presence does not prove enablement, intent, or successful use. |
| Program protection | `logonse psb --pid PID` | PSB summary, not the process's security descriptor. |
| Session context | `logonse list` and `logonse show ID` | Can fall back to an incomplete visible-process view. |
| File descriptor policy | `sd show PATH --all` | Owner, group, DACL, and label subset; not a complete SACL export. |
| Registry descriptor | `reg sd KEY`, with `--sacl` when authorized | Default output omits SACL policy. |
| Recorded attempt | Event Viewer or `evctl` | Reader rights, collection, query scope, retention, and transport can limit evidence. |

For files, `sd` follows a named symlink unless its documented no-follow
option is selected. Inspect the same object the application meant to use.
Token pseudo-files provide handles, not text to print with `cat`.
[Token inspection](/peios/using-peios/identity-and-access/token.md) and
[process-security inspection](/peios/using-peios/identity-and-access/inspecting-process-security.md)
explain their separate access gates.

## Rehearse within the tool's limits

For an identified file and process, a read rehearsal is:

```sh
sd check ./report.txt read --pid PID --explain
```

Adapt the file, rights, and PID to the failed request. This does not perform
the file operation. A tool failure is different from a completed denied
check. The process selector does not reproduce every thread impersonation,
local claim, backup/restore intent, object mapping, or PIP context.
It also does not test an existing handle's rights.

An allowed rehearsal is therefore not proof that the application must
succeed. If the results differ, compare inputs and timing before changing
policy. A developer can use the [SDK request
reference](/peios/developing-for-peios/sdk-reference/sdk-access/the-request.md) for inputs the operator tool cannot
supply, and its [checking guide](/peios/developing-for-peios/sdk-access-control/checking-access.md)
for the advisory result's limits.

## Review the relevant policy

| Evidence | Review |
|---|---|
| Identification-level impersonation token | Whether the client conveyed authority and the server was admitted to use it. |
| Mandatory-integrity refusal | Token integrity/mandatory policy, the applicable object label, and requested mapped rights. |
| Process-trust refusal | Calling PSB, target trust label, and intended signed interface; impersonation does not raise PIP. |
| Missing privilege contribution | Present versus enabled state and required operation intent. |
| DACL refusal | Ordered ACEs, enabled/deny-only SIDs, conditions, inheritance-only flags, and owner-rights suppression. |
| Restricted-token narrowing | The independent restricting SID view and any retained privilege grants. |
| Confinement narrowing | The intended confinement identity/capabilities and resource policy. |
| Central-policy narrowing | Effective policy, applicability, resource attributes, and recovery behavior; staged mismatches are separate evidence. |

MIC, PIP, privilege contributions, and narrowing occur in a defined pipeline.
Do not assume one label mismatch or one matching ACE explains the whole mask.
The [kernel access-check reference](/kernel/internals/kacs/access-check/overview.md)
is authoritative for ordering. Object-manager and service checks can also
reject an operation outside that pipeline.

## Interpret recorded evidence

`kacs.audit.access.checked` can record the subject, object, requested and
granted masks, and reasons. Auditing depends on policy; userspace checks
also have audit-authority requirements. One check can produce several records.
A successful `MAXIMUM_ALLOWED` result does not prove a particular bit was
granted. Inspect the returned mask.

Use [Finding Missing Records](/peios/using-peios/reading-records/finding-missing-records.md)
before interpreting an empty search. Raw KMES inspection is a transport probe,
not historical proof. Preserve refused inspections, missing inputs, and
changed-state uncertainty in the report to the application or policy owner.
A narrower intended grant or corrected caller behavior should follow that
review; broad permission changes are not a diagnostic substitute.

---

# Interpreting Audit Evidence

_Peios / Using Peios / Identity and Access_

> Read access and privilege records without confusing a logged observation with authorization or complete history.

Use audit evidence to reconstruct a particular operation. Start with its
process instance, effective subject, object, requested rights, result, and
observation interval. Preserve the original record before translating SIDs
or event fields into display names.

## Identify the trigger

| Trigger | What the record establishes |
|---|---|
| Access audit ACE | A matching SACL rule observed an access check and outcome. |
| Continuous alarm ACE | An operation overlapped the audit mask retained on its handle. |
| Token object-access policy | The checked token required a success or failure record, even without a matching SACL ACE. |
| Privilege-use policy | A privilege contributed rights, with success or failure determined after the narrowing passes. |
| Central policy diagnostic | A SACL could not be evaluated or staged and effective policy differed. |

Audit rules do not grant or deny access. Their success and failure flags
select observations. Conditional audit expressions that are UNKNOWN use the
conservative audit behavior; ordinary conditional allow rules differ.
An inherit-only ACE is a template for children, not an immediate observation
rule on the parent.

Continuous records identify the operation-time subject, which can differ from
the opener after impersonation or descriptor transfer. Their stored audit mask
comes from the open. Changing the object's SACL does not turn every existing
handle into a fresh open with the replacement mask.

## Preserve the limits of attribution

The token ID, authentication ID, process GUID, and PID identify different
things. Resolve names as annotations; do not replace original SIDs. A process
can act with an impersonation token, and a single logon session can contain
many tokens. Cross-boot correlation needs boot context.

A userspace AccessCheck record is an advisory check of caller-supplied data,
not proof that the kernel opened that object. Its userspace-attestation marker
matters. On that syscall path, SACL-generated records require the emitter's
enabled audit privilege; token-policy and other event families have separate
rules. The [kernel audit
reference](/kernel/internals/kacs/access-check/auditing-in-accesscheck.md)
defines these distinctions and the [event
schemas](/kernel/internals/kacs/auditing/event-families-and-delivery.md)
define the fields. Absent object information must remain unknown.

Do not treat a privilege-use record as proof that removing that privilege
would have denied the operation. Backup and restore accounting can record a
contribution even where the DACL independently permits access. Maximum-access
queries also differ from concrete operation requests.

## Check delivery before drawing conclusions

A required event-construction or delivery failure can fail an audited call;
auditing is not universally best-effort. Transport buffering, loss,
persistence, retention, and query permissions are separate stages. Neither
a successful call nor an empty event query establishes a complete history.

Collect both the event and any loss or ingestion diagnostics for the same
interval. Check query scope and retention, and distinguish an inaccessible
field from an absent field. Follow the
[event evidence workflow](/peios/using-peios/reading-records/saving-evidence.md) for collection
and the raw event catalog for schema interpretation. A sequence gap alone in
a filtered view is not proof of loss.

---

# Inspecting Effective Identity

_Peios / Using Peios / Identity and Access_

> Use token views to distinguish runtime authority from account records.

`token` exposes the identity and authority carried by running processes and
threads. It is a diagnostic tool for questions that a user name or numeric
group list cannot answer.

## Choose the identity being observed

A process has a primary token. A thread can have an impersonation token that
supplies its effective identity. A peer-token query observes identity captured
on a connected socket, which is another distinct target.

Reading another process's token requires the appropriate access. Knowing a
process number or a socket descriptor does not bypass that check.

Use an explicit selector when diagnosing another program:

```sh
token show --pid PID --all
token groups --pid PID
token privs --pid PID
token stats --pid PID
token show --pid PID --tid TID --all
```

Replace the process and thread IDs with identified targets. The process view
selects its primary token; the thread view matters for impersonation.
`--self` is the default, `--real` selects the caller's primary token, and
`--peer SOCK_FD` selects captured identity on a connected socket. A peer query
is not a lookup of whatever identity its process happens to use afterward.

Preserve the selector, time, token ID, and modification ID with observations.
Use `--json` for structured output and the documented raw-SID/label display
choices when comparing identities. These queries do not authorize mutation.

## Read more than the user name

Token state includes security identifiers (SIDs), group attributes,
privileges, integrity, and logon information. A deny-only group can deny
access without granting it, even when its friendly name matches an ordinary
membership elsewhere.

The logon-session identifier and the interactive-environment scope are
separate fields. Changing a scope is not the same operation as moving a token
into a different authenticated logon session.

Field commands also expose integrity, logon context, claims, capabilities,
origin/source, and creation defaults. Apply the same target selector to each.
A default DACL concerns new objects, not the descriptor of every existing
object. `show --all` means all supported query classes, not every internal
field. Absence of an internal field from the output does not establish its
value; the kernel's query reference owns that boundary.

Full or Limited elevation type can outlive the active link. `token linked`
queries a counterpart where one exists and is accessible; a role alone is
not evidence that elevation is available. The privilege used bit is not a
timestamped record of each exercise.

## Compare observations carefully

Token comparison reports selected identity, group, and privilege state. Equal
and different comparisons can both succeed: the status indicates whether the
queries worked, not whether the tokens matched.

Thread enumeration can race with thread exits or access changes. A failed row
makes the result incomplete and is reported rather than silently removed.
Multiple queries are consecutive observations, not one atomic snapshot of all
token state.

## Derived tokens remain controlled objects

Restriction, duplication, adjustment, and impersonation have different
purposes. A restriction limits an existing authority; it does not grant a new
one. Creating or installing identity requires the corresponding privilege and
is not a normal way to switch users.

`token(1)` defines target selection, comparison output, thread failures, and
the mutation interfaces. Use the normal authentication workflow when your goal
is signing in rather than testing a token mechanism.

## Refused and partial views

A cross-process token query needs process-query rights, PIP dominance, and
query access to the token. Own-process `/proc` query-only token paths have a
special rule; direct self-open APIs still check the token descriptor.
Do not generalize one surface's self-access exception to every operation.

Process walks cannot enumerate all tokens held only by file descriptors.
A missing target, denied query, and invalid request are different failures;
none is a successfully read empty token. Token pseudo-files are handles, not
text files. SDK users should follow the [opening
reference](/peios/developing-for-peios/sdk-reference/sdk-tokens/opening-and-creating-tokens.md) and
[query protocol](/peios/developing-for-peios/sdk-reference/sdk-tokens/query.md).

---

# Inspecting Process Security

_Peios / Using Peios / Identity and Access_

> Read a process's protection and hardening without confusing a visible summary with control rights.

Use `logonse psb --pid PID` to inspect a process's protection, mitigation
mask, and Process GUID. Replace `PID` with the current process number.
Omitting mutation options leaves those settings unchanged.

## Inspect and correlate

1. Identify the current process and its workload. Record its Process GUID
   when correlating historical events; a PID can be reused.
2. Read its PSB with `logonse psb --pid PID` or Task Manager. Limited query
   access can expose the protection level even when detailed inspection or
   process control is refused.
3. Inspect the primary token to identify the process's account and session.
   Inspect the particular thread's effective token if impersonation matters.
4. Read the process descriptor using the supported SDK surface when the
   question is who can act on it. The DACL and SACL have different access
   requirements; a limited PSB read is not permission to read both.
5. Correlate current state with stored events. Separate reads can observe
   different moments and do not constitute an atomic security snapshot.

The kernel's [process ABI](/kernel/userspace/native/kacs/generated-process-and-psb-abi.md)
defines rights and mitigation bits. The [PSB
reference](/kernel/internals/kacs/process-security/psb-fields.md) explains their
meaning. Do not infer an exact grant from a token or protection label alone;
the target object and requested operation also matter.

## Read a refusal accurately

PSB inspection needs limited query rights and does not require PIP dominance.
Detailed inspection and process-control operations have stronger checks.
Impersonation changes identity without changing the caller's PIP, and
`SeDebugPrivilege` does not bypass that protection.

A self-targeted PSB read is supported, but that does not mean every operation
on one's own process succeeds. Reading the SACL still has its own authority
requirement. Missing fields and access errors are not empty permissions.

## Changes over time

PIP follows the executable at exec, so it can change while PID and Process
GUID stay the same. Mitigations only become stricter and persist across exec.
A thread can install or revert impersonation, and token adjustments or
process-descriptor edits can change other inspection results.

Adding `--mitigations MASK` requests a permanent hardening change. It is not
an inspection option or a way to gain control rights. Read `logonse(1)` and
the mitigation reference before using it; failure to activate a requested
protection must not be reported as success.

---

# Well-Known SIDs

_Peios / Using Peios / Identity and Access_

> The built-in security identifiers you meet most often in tokens and permissions, with their string forms and what each one matches.

Well-known security identifiers (SIDs) name identities that every Peios system
shares, such as Everyone or the Administrators group. They appear in tokens
and in permissions on every machine with the same value. This page lists the
ones you meet most often. The
[well-known SID catalog](/specifications/pcds/sid/well-known-sids.md) in the
Peios Common Data Structures specification is the complete list.

## Accounts and groups

These SIDs identify built-in accounts and groups:

| SID | Name | Identifies |
|---|---|---|
| `S-1-5-18` | Local System (SYSTEM) | The operating system itself, with the highest level of trust |
| `S-1-5-19` | Local Service | A built-in account for services that need little authority |
| `S-1-5-20` | Network Service | A built-in account for services that authenticate to other machines |
| `S-1-5-32-544` | Administrators | The built-in administrators group |
| `S-1-5-32-545` | Users | The built-in group of ordinary accounts |
| `S-1-5-32-546` | Guests | The built-in guests group |
| `S-1-5-32-551` | Backup Operators | The built-in group for backup and restore |
| `S-1-5-7` | Anonymous | A caller whose identity isn't known |

## Broad groups

These SIDs match many principals at once:

| SID | Name | Matches |
|---|---|---|
| `S-1-1-0` | Everyone | Every principal, including Anonymous |
| `S-1-5-11` | Authenticated Users | Every principal that has authenticated, which excludes Anonymous |
| `S-1-5-4` | Interactive | Principals that signed in interactively |
| `S-1-5-14` | Remote Interactive | Principals that signed in from another computer; they also carry Interactive |
| `S-1-5-2` | Network | Principals that authenticated over the network |
| `S-1-5-3` | Batch | Principals running a scheduled job |
| `S-1-5-6` | Service | Principals running as a service |

## Placeholders and patterns

These SIDs stand in for another identity or follow a pattern:

| SID | Name | Meaning |
|---|---|---|
| `S-1-3-0` | Creator Owner | In an inherited permission, replaced by the new object's owner |
| `S-1-3-4` | Owner Rights | Replaces the rights an object's owner has automatically |
| `S-1-5-5-X-Y` | Logon SID | One logon session; see [Logon Sessions](/peios/using-peios/identity-and-access/logon-sessions.md) |
| `S-1-5-80-...` | Service SID | One service, written by name as `SERVICE\<service-name>` |
| `S-1-16-n` | Integrity label | An integrity level; see [Integrity Levels](/peios/using-peios/identity-and-access/integrity-levels.md) |
| `S-1-0-0` | Nobody | No principal |
