cryptod Reference

cryptod compiles Machine\System\Cryptography into the policy file that libpcrypto reads, and records what processes report of their weak cryptography. Its configuration is documented by regman, and its records by evman.

Service #

PropertyValue
Servicecryptod
Program/usr/sbin/cryptod
IdentityService: its own SID, S-1-5-80-2691053820-547492864-353945177-641201782-1210658655
PrivilegesSeChangeNotifyPrivilege, SeAuditPrivilege
ReadinessNotify, once it has published the policy and is listening
Event rootcryptod

cryptod must run as its own service SID. Processes trust a policy copy only if SYSTEM or that SID owns it, and a file cryptod writes is owned by its token's user.

Files and sockets #

PathWhat it is
/run/cryptod/policyThe current policy
/var/state/cryptod/policyThe policy kept across reboots, for processes that start before cryptod
/run/cryptod/reportWhere processes report, a SOCK_SEQPACKET socket everyone can connect to
/run/cryptod/postureWhere the posture is served, a SOCK_STREAM socket for SYSTEM and Administrators
/usr/share/peios-crypto/algorithms.tsvEvery graded entry, which cryptod checks policies against

A process reads /run/cryptod/policy, then /var/state/cryptod/policy, then uses Peios's defaults: refuse only the floor, warn below C, FIPS ignored, exceptions allowed to override refusal. It moves to the next if a copy is absent or can't be used, and reports why.

cryptod writes each copy whole: to a new file beside it, which it gives the copy's descriptor, then renames over the copy. Each copy's descriptor is protected, grants full access to SYSTEM and cryptod, and grants reading to Everyone, S-1-15-2-1 and S-1-15-2-2, so that confined applications can read it too. Both directories grant the same readers traversal.

algorithms.tsv has one line per entry: its identifier, its grade or floor, and 1 or 0 for whether FIPS 140-3 approves it, separated by tabs. cryptod doesn't start without it.

Trusting a copy #

A process uses a copy only if its descriptor shows that nobody but SYSTEM and cryptod could have written it:

  • Its owner is SYSTEM or cryptod's SID.
  • It has a DACL. A copy with none lets everyone change it.
  • No entry of the DACL grants anyone else a right that could change the file: writing or appending data, writing extended attributes or attributes, deleting it, changing its descriptor or owner, or a generic or maximum-allowed right that includes them. Entries that deny, and entries that only pass to children, are ignored.

The check fails closed. A descriptor over 4 KiB, or an entry granting CREATOR OWNER a right to change the file, is refused as insecure, even where it would be harmless. A process that refuses a copy reports copy-insecure.

The policy file #

The file is version 1 of a binary format, at most 1 MiB less one byte. Integers are big-endian. A process reads the whole file before using any of it, and refuses a file of another version.

FieldSizeMeaning
Magic8 bytesPEIOSCPL
Version21
Reject below1A grade: 0 for U, then 1 to 4 for D to A
Warn below1A grade, as above
Flags10x01 reject non-FIPS, 0x02 warn non-FIPS, 0x04 exceptions can override refusal
Exception count2The number of exceptions that follow

Each exception follows in turn:

FieldSizeMeaning
Name1-byte length, then the nameOwner.Purpose
Flags10x01 warn about its use
ProgramSecurity2-byte length, then the descriptorA self-relative security descriptor
Entry count2The number of entries that follow
Entrieseach a 1-byte length, then the identifierSuch as md5.hmac

cryptod resolves Exceptions\Enabled, WarnByDefault and WarnAlways as it compiles, so the file holds only what applies. It leaves out exceptions it dropped. A process ignores an entry it doesn't grade, and any entry on the floor.

Reports #

A process connects to /run/cryptod/report, sends one datagram, and closes. It doesn't wait, and doesn't retry: a report that can't be sent is lost. A datagram has four fields:

FieldSizeMeaning
Kind11 warned, 2 exception used, 3 policy copy unusable
Problem1For kind 3, why; otherwise 0
Entry1-byte length, then the identifierFor kinds 1 and 2; otherwise empty
Exception1-byte length, then the nameFor kind 2; otherwise empty

The problems are 1 unreadable, 2 insecure, 3 malformed, 4 an unknown version, and 5 the process's token unreadable.

cryptod takes the sender's identity from the connection: the user of the token the kernel captured at connect, and the process ID. Nothing in the datagram names the sender. cryptod discards a datagram that libpcrypto couldn't have sent, such as one naming an entry it doesn't grade.

Rates #

cryptod relays at most 512 reports at once from each user, then 8 a second. It writes its records at up to 80 a second, below the lowest rate KMES allows a process without SeTcbPrivilege, and queues up to 4096 records when more arrive. A full queue drops its oldest standard record to make room, and turns a record away only when everything it holds is essential. The posture counts what's turned away.

Posture #

Connecting to /run/cryptod/posture returns one MessagePack map, then the connection closes. It describes the policy in force, and what's been used since cryptod started:

KeyValue
policyThe thresholds, flags, and exceptions in force; dropped, the exceptions dropped and why; defaults; and last-failure, a compile that failed since, or nil
fipsrequested; approved-mode, always false while the module isn't validated; reasons; and exceptions-admitting-non-fips
useOne map per user SID: the exceptions it used, by entry, and the entries it was warned about, each with a count of reports
turned-awayCounts of reports rate-limited, unattributed, and invalid, and overflow: what didn't fit the queue or a table

The posture is held in memory, so it starts again when cryptod restarts. Its tables are bounded, at 4096 users and 256 exceptions each.

Edit this page