Introduction
Open Sesame is a trust-scoped secret and identity fabric for the desktop. It manages encrypted secret vaults with per-profile trust boundaries, provides window switching with letter-hint overlays, per-profile clipboard history, keyboard input capture, and per-profile text snippets. Everything is scoped to trust profiles that activate based on context or manual selection.
Packages
Open Sesame ships as two packages:
open-sesame (headless core) contains the sesame CLI, daemon-profile, daemon-secrets,
daemon-launcher, and daemon-snippets. It runs anywhere with systemd: desktops, servers, containers,
and VMs. This package provides encrypted vaults, secret management, environment variable injection,
application launching, and profile management without any GUI dependencies.
open-sesame-desktop (GUI layer) depends on open-sesame and adds daemon-wm, daemon-clipboard,
and daemon-input. It requires a COSMIC or Wayland desktop. This package provides the window switcher
overlay, clipboard history, and keyboard input capture.
Installing open-sesame-desktop pulls in open-sesame automatically. On a server or in a container,
install just open-sesame for encrypted secrets and application launching.
Audience
This documentation is written for:
- Contributors working on the Open Sesame codebase. The architecture and platform sections describe internal design, crate structure, IPC protocols, and implementation patterns.
- Extension authors building WASM component model extensions. The extending section covers the extension host runtime, SDK, WIT interfaces, and OCI distribution.
- Platform implementors adding support for new operating systems or compositor backends. The platform section documents the trait abstractions, factory patterns, and feature gating used across platform crates.
- Security auditors reviewing the trust model, cryptographic primitives, sandbox enforcement, and key hierarchy. The secrets, authentication, and compliance sections provide the relevant detail.
- Deployment engineers operating Open Sesame in production. The deployment and packaging sections cover systemd integration, service topology, and package structure.
Navigating the Documentation
- Architecture – internal design: crate map, daemon topology, IPC bus, data flows. Start here for a structural understanding of the system.
- Secrets – vault system: SQLCipher storage, key hierarchy, Argon2id KDF, key-encryption keys, per-profile isolation.
- Authentication – unlock mechanisms: password, SSH agent, multi-factor auth policy engine.
- Platform – OS abstraction layer: Linux (Wayland, D-Bus, evdev, systemd), macOS (Accessibility, Keychain, launchd), Windows (UI Automation, Credential Manager, Task Scheduler).
- Extending – extension system: Wasmtime host, WASI component model, WIT bindings, OCI packaging.
- Desktop – window management: compositor integration, overlay rendering, focus tracking.
- Deployment – operations: systemd units, service readiness, watchdog, packaging.
- Compliance – security posture: Landlock, seccomp, mlock, guard pages, audit logging.
For user-facing quick start instructions, CLI reference, and configuration guide, see the README.
Architecture Overview
Open Sesame is a trust-scoped secret and identity fabric for Linux, built as 21 Rust crates organized into a Cargo workspace. The system runs as seven cooperating daemons under systemd, communicating over a Noise IK encrypted IPC bus. Two Debian packages partition the daemons into a headless core suitable for servers, containers, and VMs, and a desktop layer that requires a Wayland compositor.
Crate Topology
The workspace (Cargo.toml:2-26) contains 21 crates in five layers: memory and cryptographic
foundations, shared abstractions, platform bindings, daemon binaries, and the extension system.
Foundation Layer
| Crate | Purpose |
|---|---|
core-memory | Page-aligned secure memory allocator backed by memfd_secret(2) |
core-crypto | Cryptographic primitives: AES-256-GCM, Argon2id, SecureBytes, EncryptedStore |
core-types | Shared types, error types, and event schema for the IPC bus |
Abstraction Layer
| Crate | Purpose |
|---|---|
core-config | Configuration schema, validation, hot-reload, and policy override |
core-ipc | IPC bus protocol, postcard framing, BusServer/BusClient |
core-fuzzy | Fuzzy matching (nucleo), frecency scoring, FTS5, and index abstractions |
core-secrets | Secret storage abstraction over platform keystores and age-encrypted vaults |
core-profile | Profile schema, context-driven activation, isolation contracts, and atomic switching |
core-auth | Pluggable authentication backends for vault unlock (password, SSH-agent, future FIDO2) |
Platform Layer
| Crate | Purpose |
|---|---|
platform-linux | Linux API wrappers: evdev, uinput, Wayland protocols, D-Bus, Landlock, seccomp |
platform-macos | macOS API wrappers: Accessibility, CGEventTap, NSPasteboard, Keychain, LaunchAgent |
platform-windows | Windows API wrappers: Win32 hooks, UI Automation, Credential Manager, Group Policy |
Daemon Layer
| Crate | Purpose |
|---|---|
daemon-profile | Profile orchestrator daemon: hosts IPC bus server, context evaluation, concurrent profile activation |
daemon-secrets | Secrets broker daemon: SQLCipher vaults, multi-factor unlock, profile-scoped access |
daemon-launcher | Application launcher daemon: desktop entry discovery, fuzzy search, per-profile frecency, profile-scoped launch |
daemon-snippets | Snippet daemon: per-profile snippets listed, expanded, and added over the IPC bus |
daemon-wm | Window manager daemon: Wayland overlay window switcher with letter-hint navigation |
daemon-clipboard | Clipboard history daemon: per-profile history served from SQLite |
daemon-input | Input daemon: evdev keyboard capture and XKB translation, forwarded to the overlay |
Orchestration and Extension Layer
| Crate | Purpose |
|---|---|
open-sesame | The sesame CLI binary: platform orchestration for multi-agent desktop control |
sesame-workspace | Workspace-level integration utilities shared across daemons |
extension-host | WASM extension host: wasmtime runtime, capability sandbox, extension lifecycle |
extension-sdk | Extension SDK: types, host function bindings, and WIT interfaces for extensions |
Daemon Model
The seven daemons are split across two systemd targets and two Debian packages.
Headless Daemons (package: open-sesame)
These four daemons have no GUI dependencies and run on any system with systemd: bare-metal servers, containers, VMs, and desktops alike.
| Daemon | Role |
|---|---|
| daemon-profile | The IPC bus host. Manages trust profiles, evaluates context rules (WiFi network, connected hardware), performs atomic profile switching, and hosts the BusServer that all other daemons connect to. |
| daemon-secrets | Secrets broker. Manages SQLCipher-encrypted vaults scoped to trust profiles. Delivers secrets just-in-time to authorized callers over the IPC bus. Enforces per-vault ACLs and rate limiting. |
| daemon-launcher | Application launcher. Discovers .desktop entries, maintains frecency rankings per profile, and launches applications with optional secret injection as environment variables. |
| daemon-snippets | Snippet store. Holds snippets in memory per profile and returns a trigger’s template verbatim. |
Desktop Daemons (package: open-sesame-desktop)
These three daemons require a COSMIC or Wayland compositor. The open-sesame-desktop
package depends on open-sesame, so installing it pulls in all headless daemons
automatically.
| Daemon | Role |
|---|---|
| daemon-wm | Window manager overlay. Renders the Alt+Tab window switcher with letter-hint navigation via Wayland layer-shell protocols. |
| daemon-clipboard | Clipboard history. Serves per-profile history, entry content, and clearing from SQLite; it does not capture clipboard changes. |
| daemon-input | Keyboard capture. Reads keyboard events via evdev, translates them with XKB, and forwards them to daemon-wm while the overlay holds a grab. |
Headless/Desktop Split Rationale
The split exists so that secret management, application launching, and snippet expansion
can run on headless infrastructure (CI runners, jump hosts, fleet nodes) without pulling
in Wayland, GTK, or GPU dependencies. A server running only open-sesame gets encrypted
vaults, profile-scoped secrets, and environment injection
(sesame env -p work -- aws s3 ls) with no graphical stack. A developer workstation
installs open-sesame-desktop for the full experience: window switching, clipboard
history, and keyboard shortcuts layered on top of the same headless core.
IPC Bus
All inter-daemon communication flows through a Noise IK encrypted IPC bus
implemented in core-ipc.
Hub-and-Spoke Topology
daemon-profile hosts the BusServer. Every other daemon and every sesame CLI
invocation connects as a BusClient. There is no peer-to-peer communication between
daemons; all messages route through the hub.
Noise IK Transport
The IPC bus uses the Noise IK handshake pattern from
the snow crate (Cargo.toml:89). In the IK pattern the initiator (client) knows
the responder’s (server’s) static public key before the handshake begins. This provides
mutual authentication and forward secrecy on every connection. Messages are framed with
postcard (Cargo.toml:65) for compact binary serialization and deserialized into
core-types::EventKind variants.
Ephemeral CLI Connections
The sesame CLI binary does not maintain a long-lived connection. Each CLI invocation
opens a Noise IK session to daemon-profile, sends one or more EventKind messages,
receives the response, and disconnects. The CLI has no persistent state and can be
invoked from scripts, cron jobs, or CI pipelines without session management.
Message Flow Example
A sesame secret get -p work aws-access-key invocation follows this path:
sesameCLI opens a Noise IK session todaemon-profile.daemon-profileauthenticates the client and routes the secret-get request todaemon-secrets.daemon-secretsverifies the caller’s clearance against the vault ACL, decrypts the value from the SQLCipher store, and returns it as aSensitiveBytespayload.daemon-profileforwards the response to the CLI.- The CLI writes the secret to stdout and exits.
All secret material in transit is encrypted by the Noise session. All secret material
at rest in daemon memory is held in ProtectedAlloc pages backed by memfd_secret(2)
(see Memory Protection).
Daemon Topology
graph TD
subgraph "open-sesame (headless)"
DP[daemon-profile<br/><i>IPC bus host, profiles</i>]
DS[daemon-secrets<br/><i>vault broker</i>]
DL[daemon-launcher<br/><i>app launch, frecency</i>]
DN[daemon-snippets<br/><i>snippet expansion</i>]
end
subgraph "open-sesame-desktop (GUI)"
DW[daemon-wm<br/><i>window switcher overlay</i>]
DC[daemon-clipboard<br/><i>clipboard history</i>]
DI[daemon-input<br/><i>keyboard capture</i>]
end
CLI[sesame CLI<br/><i>ephemeral connections</i>]
DS -->|BusClient| DP
DL -->|BusClient| DP
DN -->|BusClient| DP
DW -->|BusClient| DP
DC -->|BusClient| DP
DI -->|BusClient| DP
CLI -.->|ephemeral BusClient| DP
subgraph "Foundation Crates"
CM[core-memory]
CC[core-crypto]
CT[core-types]
CI[core-ipc]
CF[core-config]
CZ[core-fuzzy]
CSE[core-secrets]
CP[core-profile]
CA[core-auth]
end
subgraph "Platform Crates"
PL[platform-linux]
end
subgraph "Extension System"
EH[extension-host]
ES[extension-sdk]
end
DP --> CI
DP --> CP
DP --> CF
DP --> CT
DS --> CSE
DS --> CC
DS --> CM
DL --> CZ
DL --> CF
DW --> PL
DC --> PL
DI --> PL
CI --> CT
CI --> CM
CC --> CM
CSE --> CC
CA --> CC
EH --> ES
Crate Dependency Highlights
- Every daemon depends on
core-ipc(for bus connectivity) andcore-types(for theEventKindprotocol schema). core-ipcdepends oncore-memorybecause Noise session keys are held inProtectedAlloc.core-cryptodepends oncore-memorybecauseSecureByteswrapsProtectedAllocfor key material.- The three desktop daemons (
daemon-wm,daemon-clipboard,daemon-input) depend onplatform-linuxfor Wayland protocol bindings, evdev access, and compositor integration. core-secretsdepends oncore-cryptofor vault encryption andcore-authdepends oncore-cryptofor key derivation during authentication.- The
extension-hostcrate useswasmtime(Cargo.toml:164) with the component model and pooling allocator for sandboxed WASM extension execution.
Security Boundaries
Each daemon runs as a separate systemd service with:
- Landlock filesystem restrictions (
platform-linux,landlockcrate atCargo.toml:136) limiting each daemon to only the filesystem paths it needs. - seccomp syscall filtering (
platform-linux,libseccompcrate atCargo.toml:137) restricting each daemon to a minimal syscall allowlist. - Noise IK mutual authentication on every IPC connection, preventing unauthorized processes from joining the bus.
- ProtectedAlloc secure memory for all key material, with
memfd_secret(2)removing secret pages from the kernel direct map (see Memory Protection).
See Also
- Memory Protection – secure memory allocator internals
- IPC Protocol – Noise IK handshake, framing, and message schema
- Sandbox Model – Landlock and seccomp configuration
- Profile Trust Model – profile isolation contracts
Memory Protection
All secret-carrying types in Open Sesame are backed by core-memory::ProtectedAlloc,
a page-aligned secure memory allocator that uses memfd_secret(2) on Linux 5.14+ to
remove secret pages from the kernel direct map entirely. This page documents the
allocator internals, the memory layout, the fallback path, and the type hierarchy
built on top of it.
ProtectedAlloc Memory Layout
Every ProtectedAlloc instance maps a contiguous region of virtual memory containing
five sections: three PROT_NONE guard pages, one read-only metadata page, and one or
more read-write data pages. The layout is defined in core-memory/src/alloc.rs:31-32
where OVERHEAD_PAGES is set to 4 (guard0 + metadata + guard1 + guard2), and data
pages are sized to fit the 16-byte canary plus the requested user data length.
mmap'd region (mmap_total bytes)
+------------+------------+------------+---------------------------+------------+
| guard pg 0 | metadata | guard pg 1 | data pages ... | guard pg 2 |
| PROT_NONE | PROT_READ | PROT_NONE | PROT_READ | PROT_WRITE | PROT_NONE |
+------------+------------+------------+---------------------------+------------+
^ ^ ^ ^ ^
| | | | |
mmap_base +1 page +2 pages +3 pages +3 pages
(metadata) (data_region) +data_region_len
(guard2)
Detail of data pages (right-aligned user data):
|<------------- data_region_len (data_pages * page_size) ------------->|
+-------------------+-----------+--------------------------------------+
| padding | canary | user data |
| (filled 0xDB) | 16 bytes | (user_len bytes) |
+-------------------+-----------+--------------------------------------+
^ ^ ^ ^
data_start canary_ptr user_data guard page 2
(PROT_NONE)
Byte-Level Sizes
Given a system page size P (typically 4096) and a requested allocation of N bytes:
| Component | Formula | Example (N=32, P=4096) |
|---|---|---|
data_pages | ceil((16 + N) / P) | 1 |
data_region_len | data_pages * P | 4096 |
mmap_total | (4 + data_pages) * P | 20480 (5 pages) |
padding_len | data_region_len - 16 - N | 4048 |
The padding is filled with 0xDB (PADDING_FILL, alloc.rs:29), matching
libsodium’s garbage fill convention.
Guard Pages
Three guard pages are set to PROT_NONE via mprotect(2)
(alloc.rs:422-434). Any read or write to a guard page triggers an
immediate SIGSEGV:
- guard0 (
mmap_base): prevents underflow from adjacent lower-address allocations. - guard1 (
mmap_base + 2*P): separates the read-only metadata page from the writable data region. Prevents metadata corruption from data-region underflow. - guard2 (
mmap_base + 3*P + data_region_len): the trailing guard page. Because user data is right-aligned within the data region, a buffer overflow of even one byte hits this page immediately.
Right-Alignment
User data is placed at the end of the data region (alloc.rs:455):
#![allow(unused)]
fn main() {
let user_data_ptr = data_start.add(data_region_len - user_len);
}
This right-alignment means a sequential buffer overflow crosses from user
data directly into the trailing guard page (guard2), triggering SIGSEGV
on the first out-of-bounds byte. Without right-alignment, an overflow
would silently write into unused padding within the same page before
reaching the guard.
Metadata Page
The metadata page (alloc.rs:438-451) stores allocation bookkeeping at
fixed offsets, then is downgraded to PROT_READ:
| Offset | Size | Content |
|---|---|---|
| 0 | 8 bytes | mmap_total (total mapped size) |
| 8 | 8 bytes | Data region offset from mmap_base |
| 16 | 8 bytes | User data offset from mmap_base |
| 24 | 8 bytes | user_len (requested allocation size) |
| 32 | 8 bytes | data_pages count |
| 40 | 16 bytes | Copy of the process-wide canary |
The metadata page is restored to PROT_READ|PROT_WRITE during Drop
(alloc.rs:688-694) so it can be volatile-zeroed before munmap.
memfd_secret(2) Backend
The preferred allocation backend on Linux is memfd_secret(2), invoked
via raw syscall 447 (alloc.rs:130,335). This syscall, available since
Linux 5.14, creates an anonymous file descriptor whose pages are:
- Removed from the kernel direct map: the pages are not addressable
by any kernel code path, including
/proc/pid/memreads,process_vm_readv(2), kernel modules, and DMA engines. - Invisible to ptrace: even
CAP_SYS_PTRACEcannot read the page contents. - Implicitly locked: the kernel does not swap
memfd_secretpages to disk. No explicitmlock(2)is needed.
The syscall requires CONFIG_SECRETMEM=y in the kernel configuration.
To check whether a running kernel has this enabled:
zgrep CONFIG_SECRETMEM /proc/config.gz
# or
grep CONFIG_SECRETMEM /boot/config-$(uname -r)
Probe and Caching
The allocator probes for memfd_secret availability once at process
startup via probe_memfd_secret() (alloc.rs:125-188) and caches the
result in a OnceLock<bool> (alloc.rs:45). The probe sequence:
- Call
syscall(447, 0)to create a secret fd. - If
fd < 0, log anERROR-level security degradation and cachefalse. - If
fd >= 0, close the fd immediately and cachetrue.
Allocation Sequence
The memfd_secret_mmap() function (alloc.rs:333-372) performs the full
allocation:
syscall(447, 0)– create the secret fd.ftruncate(fd, size)– set the mapping size.mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)– map the pages.MAP_SHAREDis required formemfd_secret.close(fd)– the mapping persists after the fd is closed.
Fallback: mmap(MAP_ANONYMOUS)
On kernels without memfd_secret support (Linux < 5.14 or
CONFIG_SECRETMEM disabled), the allocator falls back to
mmap(MAP_ANONYMOUS|MAP_PRIVATE) (alloc.rs:380-398). This fallback
applies two additional protections that memfd_secret provides
implicitly:
mlock(2)(alloc.rs:495): locks the data region pages into RAM, preventing the kernel from swapping them to disk. Ifmlockfails withENOMEM(theRLIMIT_MEMLOCKlimit is exceeded), the allocator logs aWARN-level security degradation but continues (alloc.rs:498-511). Ifmlockfails with any other errno, allocation fails withProtectedAllocError::MmapFailed.madvise(MADV_DONTDUMP)(alloc.rs:482): excludes the data region from core dumps. This is Linux-specific.
The fallback is a security degradation: pages remain on the kernel
direct map and are readable via /proc/pid/mem by any process running
as the same UID. An ERROR-level audit log is emitted by both
probe_memfd_secret() (alloc.rs:147-161) and core_memory::init()
(core-memory/src/lib.rs:83-91) when operating in fallback mode. The
log message explicitly states that fallback mode does not meet
IL5/IL6, STIG, or PCI-DSS requirements (lib.rs:88).
Canary Verification
Each ProtectedAlloc instance places a 16-byte canary (CANARY_SIZE,
alloc.rs:25) immediately before the user data region. The canary value
is a process-wide random generated once from getrandom(2) (on Linux,
alloc.rs:56) or getentropy(2) (on macOS, alloc.rs:67) and cached
in a OnceLock<[u8; 16]> (alloc.rs:39).
Placement
The canary is written at user_data_ptr - 16 (alloc.rs:457-464). A
copy is also stored in the metadata page at offset 40 (alloc.rs:446).
Constant-Time Verification on Drop
During ProtectedAlloc::drop() (alloc.rs:636-720), the canary is
verified before any cleanup:
-
The 16 bytes at
canary_ptrare read as a slice (alloc.rs:641-642). -
They are compared to the global canary using
fixed_len_constant_time_eq()(alloc.rs:613-624). This function XORs each byte pair into an accumulator and reads the result throughread_volatileto prevent the compiler from short-circuiting the comparison:#![allow(unused)] fn main() { fn fixed_len_constant_time_eq(a: &[u8], b: &[u8]) -> bool { if a.len() != b.len() { return false; } let mut acc: u8 = 0; for (x, y) in a.iter().zip(b.iter()) { acc |= x ^ y; } let result = unsafe { std::ptr::read_volatile(&acc) }; result == 0 } } -
If the comparison fails, an
ERROR-level audit log is emitted and the process aborts viastd::process::abort()(alloc.rs:656). The process aborts rather than continuing with potentially compromised key material.
Canary corruption indicates a buffer underflow, heap corruption, or use-after-free in secret-handling code.
Volatile Zeroize
After canary verification passes, the entire data region (not just the
user data portion) is volatile-zeroed via volatile_zero()
(alloc.rs:627-632):
#![allow(unused)]
fn main() {
fn volatile_zero(ptr: *mut u8, len: usize) {
let slice = unsafe { std::slice::from_raw_parts_mut(ptr, len) };
slice.zeroize();
std::sync::atomic::compiler_fence(std::sync::atomic::Ordering::SeqCst);
}
}
The zeroize crate (Cargo.toml:85) performs volatile writes that the
compiler cannot elide. The compiler_fence(SeqCst) (alloc.rs:631)
provides an additional barrier preventing reordering of the zeroize with
the subsequent munmap. This zeroes the canary, the 0xDB padding, and
the user data before the pages are returned to the kernel.
Drop Sequence
The full Drop implementation (alloc.rs:636-720) proceeds in order:
- Canary check – constant-time comparison, abort on corruption.
- Volatile-zero the data region –
data_region_lenbytes starting atdata_region. - munlock (fallback only) – unlock data pages (
alloc.rs:665). - MADV_DODUMP (fallback only, Linux) – re-enable core dump
inclusion for the zeroed pages (
alloc.rs:675). - Zero metadata page – restore
PROT_READ|PROT_WRITE, volatile-zero (alloc.rs:686-695). - munmap – release the entire mapping back to the kernel
(
alloc.rs:700).
Type Hierarchy
Three types build on ProtectedAlloc to provide ergonomic secret
handling at different layers of the system.
SecureBytes (core-crypto/src/secure_bytes.rs)
SecureBytes is the primary vehicle for cryptographic key material:
master keys, vault keys, derived keys, and KEKs. It wraps a
ProtectedAlloc with an actual_len field to support empty values
(backed by a 1-byte sentinel allocation, secure_bytes.rs:55-56).
Key properties:
from_slice(&[u8])(secure_bytes.rs:73-81): copies directly into protected memory with no intermediate heap allocation. This is the preferred constructor.new(Vec<u8>)(secure_bytes.rs:51-63): accepts an ownedVec, copies into protected memory, then zeroizes the sourceVecon the unprotected heap. The doc comment (secure_bytes.rs:37-44) explicitly notes the brief heap exposure and recommendsfrom_slicewhen possible.into_protected_alloc()(secure_bytes.rs:107-120): zero-copy transfer of the innerProtectedAllocto a new owner. UsesManuallyDropto suppress theSecureBytesdestructor andptr::readto move the allocation out. TheProtectedAllocis never copied or re-mapped.Clone(secure_bytes.rs:124-129): creates a fully independentProtectedAllocwith its own guard pages, canary, and mlock. Both original and clone zeroize independently on drop.Debug(secure_bytes.rs:146-148): redacted output showing only byte count (SecureBytes([REDACTED; 32 bytes])), never contents.
SecureBytes does not implement Serialize or Deserialize. Secrets
must be explicitly converted to SensitiveBytes before crossing a
serialization boundary.
SecureVec (core-crypto/src/secure_vec.rs)
SecureVec is a password input buffer designed for character-by-character
collection in graphical overlays where the full password length is not
known in advance. It pre-allocates a fixed-size ProtectedAlloc (512
bytes for for_password(), secure_vec.rs:14,61) and provides UTF-8
aware push_char/pop_char operations.
Key properties:
- No reallocation: the buffer is fixed-size.
push_charpanics if the buffer is full (secure_vec.rs:118-122). The 512-byte limit accommodates passwords up to approximately 128 four-byte Unicode characters (secure_vec.rs:13). - Lazy allocation:
SecureVec::new()(secure_vec.rs:43-48) creates an empty instance withinner: Noneand no mmap.for_password()orwith_capacity()triggers the actualProtectedAlloc. - UTF-8 aware pop:
pop_char()(secure_vec.rs:133-160) scans backwards to find multi-byte character boundaries (checking the0xC0continuation mask) and zeroizes the removed bytes in-place before adjusting the cursor. clear()(secure_vec.rs:199-208): zeroizes all written bytes and resets the cursor without deallocating, allowing buffer reuse for sequential vault unlocks.- Double zeroize on drop:
Drop(secure_vec.rs:217-229) zeroizes written bytes beforeProtectedAlloc::dropperforms its own volatile-zero of the entire data region.
SensitiveBytes (core-types/src/sensitive.rs)
SensitiveBytes is the wire-compatible type for secret values in
EventKind IPC messages. It wraps a ProtectedAlloc and implements
Serialize/Deserialize for postcard framing.
Key properties:
- Zero-copy deserialization path: the custom
SensitiveBytesVisitor(sensitive.rs:112-146) implementsvisit_bytes(sensitive.rs:123-125) which receives a borrowed&[u8]from the deserializer and copies directly into aProtectedAlloc. When postcard performs in-memory deserialization, this path avoids any intermediate heapVec<u8>. - Fallback deserialization path:
visit_byte_buf(sensitive.rs:129-132) handles deserializers that provide owned bytes. TheVec<u8>is copied into protected memory and immediately zeroized. - Sequence fallback:
visit_seq(sensitive.rs:136-145) handles deserializers that encode bytes as a sequence ofu8values. The collectedVec<u8>is zeroized after copying. from_protected()(sensitive.rs:57-62): accepts aProtectedAllocandactual_lendirectly, enabling zero-copy transfer fromSecureBytes.- Serialization (
sensitive.rs:95-99): callsserializer.serialize_bytes()directly from the protected memory slice. postcard reads the slice without copying. Debug(sensitive.rs:160-163): redacted output ([REDACTED; 32 bytes]).
Zero-Copy Lifecycle
The three types form a zero-copy pipeline for secret material:
- A vault key is derived by
core-cryptoand stored asSecureBytes(inProtectedAlloc). - When the key must cross the IPC bus,
SecureBytes::into_protected_alloc()transfers theProtectedAlloctoSensitiveBytes::from_protected()with no heap copy and no re-mapping. SensitiveBytesserializes directly from theProtectedAllocpages into the Noise-encrypted IPC frame.- On the receiving end, postcard’s
visit_bytespath deserializes directly into a newProtectedAlloc.
At no point does plaintext key material exist on the unprotected heap,
provided the from_slice constructor path is used rather than
SecureBytes::new(Vec<u8>).
init_secure_memory() Pre-Sandbox Probe
The core_memory::init() function (core-memory/src/lib.rs:58-107)
must be called before the seccomp sandbox is applied. It performs a probe
allocation of 1 byte (lib.rs:68) which triggers probe_memfd_secret()
internally, caching whether syscall 447 is available. If this probe ran
after seccomp activation, the raw syscall would be killed by the filter.
The function also reads RLIMIT_MEMLOCK via getrlimit(2)
(lib.rs:62-65) and logs it alongside the security posture:
- memfd_secret available:
INFO-level log withbackend = "memfd_secret"and therlimit_memlock_bytesvalue (lib.rs:71-78). - memfd_secret unavailable:
ERROR-level log withbackend = "mmap(MAP_ANONYMOUS) fallback"and remediation instructions (lib.rs:83-91). - Probe allocation failure:
ERROR-level log warning that all secret-carrying types will panic on allocation (lib.rs:95-103).
The function is idempotent (lib.rs:57). The OnceLock values for
CANARY, PAGE_SIZE, and MEMFD_SECRET_AVAILABLE (alloc.rs:39,42,45)
ensure that the probe syscall, the getrandom call, and the sysconf
call each execute exactly once per process regardless of how many times
init() is called.
Guard Page SIGSEGV Test Methodology
The guard page tests (core-memory/tests/guard_page_sigsegv.rs) use a
subprocess harness pattern because the expected outcome is process death
by signal, which cannot be caught within a single test process.
Test Structure
Each test case consists of a parent test and a child harness:
- Parent test (e.g.,
overflow_hits_trailing_guard_page,guard_page_sigsegv.rs:58-62): spawns the test binary targeting the harness function by name via--exact, with a gating environment variable__GUARD_PAGE_HARNESS. - Child harness (e.g.,
overflow_harness,guard_page_sigsegv.rs:66-83): checks the environment variable, allocates aProtectedAllocviafrom_slice(b"test"), performs a deliberate out-of-boundsread_volatile, and callsexit(1)if the read succeeds (which it must not). - Signal assertion (
assert_signal_death,guard_page_sigsegv.rs:25-53): the parent verifies the child was killed bySIGSEGV(signal 11) orSIGBUS(signal 7), handling both direct signal death (ExitStatusExt::signal()) and the 128+signal exit code convention used by some platforms.
Test Cases
| Test | Action | Expected Signal |
|---|---|---|
overflow_hits_trailing_guard_page | Reads one byte past ptr.add(len) (guard_page_sigsegv.rs:78) | SIGSEGV (11) |
underflow_hits_leading_guard_page | Reads one page before ptr via ptr.sub(page_size) (guard_page_sigsegv.rs:112) | SIGSEGV (11) or SIGBUS (7) |
The overflow test validates right-alignment: because user data is flush
against guard page 2, the very first out-of-bounds byte lands on a
PROT_NONE page. The underflow test reads backward past the canary and
padding into guard page 1 (between metadata and data region).
The environment variable gate (guard_page_sigsegv.rs:67) ensures that
when the test binary is run normally (without __GUARD_PAGE_HARNESS
set), the harness functions return immediately without performing any
unsafe operations.
Platform Support Summary
| Platform | Backend | Protection Level |
|---|---|---|
Linux 5.14+ with CONFIG_SECRETMEM=y | memfd_secret(2) | Full: pages removed from kernel direct map |
Linux < 5.14 or without CONFIG_SECRETMEM | mmap(MAP_ANONYMOUS) + mlock + MADV_DONTDUMP | Degraded: pages on direct map, audit-logged |
| Non-Unix | Compile-time stub | ProtectedAlloc::new() returns Err(Unsupported) |
The non-Unix stub (core-memory/src/lib.rs:111-182) exists solely so
the crate compiles in workspace-wide cargo check runs. All methods on
the stub panic or return errors; no secrets can be handled on unsupported
platforms.
See Also
- Architecture Overview – crate topology and daemon model
- IPC Protocol – Noise IK transport that carries
SensitiveBytespayloads - Sandbox Model – Landlock and seccomp filters applied after
init_secure_memory()
IPC Bus Protocol
The core-ipc crate implements the inter-process communication protocol used by all Open Sesame
daemons and the sesame CLI.
Bus Architecture
The IPC bus uses a star topology. daemon-profile hosts a BusServer that binds a Unix domain
socket at $XDG_RUNTIME_DIR/pds/bus.sock. All other daemons and the sesame CLI connect to this
socket as BusClient instances.
The server accept loop (BusServer::run in server.rs) listens for incoming connections, extracts
UCred credentials via SO_PEERCRED, enforces a same-UID policy (rejecting connections from
different users), and spawns a per-connection handler task. Each connection performs a mandatory
Noise IK handshake before any application data flows.
Per-connection state is tracked in ConnectionState, which holds:
- The daemon’s
DaemonId(set on first message) - A registry-verified daemon name (
verified_name, from Noise IK handshake) - An outbound
mpsc::Sender<Vec<u8>>channel (capacity 256) SecurityLevelclearance- An optional
TrustVectorcomputed at connection time
An atomic u64 counter assigns monotonically increasing connection IDs. Each connection runs three
stages in handle_connection:
- Accept and identify.
noise::Connection::serverperforms the handshake;identifylooks the client’s static key up in the registry and logs the outcome. Connection state is registered only after the handshake succeeds, so no frame is routed to a connection before a transport exists to encrypt it. - Serve.
servemultiplexes encrypted reads (routed throughroute_frame) and writes of the frames routed to the connection. - Close.
closeremoves the connection’s state and daemon name. Unanswered requests are marked disconnected until their TTL expires.
Clients and the server share one noise::Connection type (transport, buffered reader, buffered
writer), constructed by Connection::client or Connection::server.
On BusServer::drop, the socket file is removed from the filesystem.
Noise IK Handshake
All socket connections use the Noise Protocol Framework with the IK pattern:
Noise_IK_25519_ChaChaPoly_BLAKE2s
The primitives are:
- X25519 Diffie-Hellman key agreement
- ChaCha20-Poly1305 authenticated encryption (AEAD)
- BLAKE2s hashing
The IK pattern means the initiator (connecting daemon) transmits its static key encrypted in the first message, and the responder’s (bus server’s) static key is pre-known to the initiator. This provides mutual authentication in a single round-trip (2 messages).
From the initiator (client) perspective:
- Write message 1 to responder (ephemeral key + encrypted static key)
- Read message 2 from responder (responder’s ephemeral key)
- Transition to transport mode with forward-secret keys
From the responder (server) perspective:
- Read message 1 from initiator (contains initiator’s ephemeral + encrypted static)
- Write message 2 to initiator (contains responder’s ephemeral)
- Transition to transport mode with forward-secret keys
The handshake has a 5-second timeout (HANDSHAKE_TIMEOUT) to prevent denial-of-service via slow
handshake. The snow crate provides the Noise implementation.
Prologue Binding
The Noise prologue cryptographically binds OS-level transport identity to the encrypted channel.
Both sides construct an identical prologue from UCred credentials:
PDS-IPC-v1:<lower_pid>:<lower_uid>:<higher_pid>:<higher_uid>
Canonical ordering is by PID (lower PID first), ensuring both sides produce identical bytes regardless of which side is the server. If either side has incorrect peer credentials (e.g., due to spoofing), the prologue mismatch causes the Noise handshake to fail cryptographically.
PeerCredentials are obtained via:
extract_ucred(): callsUnixStream::peer_cred()(usesSO_PEERCREDon Linux) to get the remote peer’s PID and UID.local_credentials(): callsrustix::process::getuid()andstd::process::id()for the local process.
In-process subscribers (BusServer::register, used by daemon-profile for its own host channel)
perform no handshake and carry no peer credentials.
Encrypted Transport
After handshake completion, NoiseTransport wraps a snow::TransportState and provides chunked
encrypted I/O.
Noise transport messages are limited to 65535 bytes. The maximum plaintext per Noise message is
65519 bytes (65535 minus the 16-byte AEAD tag). Application frames up to 16 MiB
(MAX_FRAME_SIZE = 16 * 1024 * 1024) are chunked into multiple Noise messages.
Encrypted Frame Wire Format
[4-byte BE chunk_count] (length-prefixed, plaintext)
[length-prefixed encrypted chunk 1]
[length-prefixed encrypted chunk 2]
...
[length-prefixed encrypted chunk N]
Each chunk is individually encrypted by snow::TransportState::write_message and written via the
length-prefixed framing layer. The chunk count header is transmitted in the clear because it is not
sensitive and the reader needs it to know how many chunks to expect.
Zero-length payloads send one empty encrypted chunk. On the read path, the reassembled payload is
validated against MAX_FRAME_SIZE, and the intermediate decrypt buffer is zeroized via
zeroize::Zeroize.
A 200 KiB payload requires approximately 4 chunks (200 * 1024 / 65519). The maximum number of chunks for a 16 MiB payload is validated on read to reject fabricated chunk counts.
Mutual Exclusion
snow::TransportState requires &mut self for both encrypt and decrypt. Both the server and client
use tokio::select! to multiplex reads and writes in a single task rather than splitting into
separate reader/writer tasks with a Mutex. The Mutex approach would deadlock because the reader
would hold the lock while awaiting socket I/O, starving the writer.
Decrypted postcard buffers on the server side and plaintext outbound buffers on the client side are zeroized after processing, as they may contain serialized secret values.
Framing Layer
The framing layer (framing.rs) provides two independent services.
Serialization
encode_frame and decode_frame convert between typed Rust values and postcard byte payloads:
encode_frame<T: Serialize>(value) -> Vec<u8>: callspostcard::to_allocvec.decode_frame<T: DeserializeOwned>(payload) -> T: callspostcard::from_bytes.
These are symmetric: decode_frame(encode_frame(v)) == v.
Wire I/O
write_frame and read_frame add and strip a 4-byte big-endian length prefix for socket transport:
write_frame(writer, payload): writes[4-byte BE length][payload], then flushes.read_frame(reader) -> Vec<u8>: reads the 4-byte length, validates againstMAX_FRAME_SIZE(16 MiB), then reads the payload.
The length prefix is a wire-only concern. Internal channels (bus routing, BusServer::publish,
subscriber mpsc channels) carry raw postcard payloads without it.
Socket wire format: [4-byte BE length][postcard payload]
Frames with a length exceeding MAX_FRAME_SIZE are rejected on read to prevent out-of-memory
conditions from malformed or malicious length prefixes.
Message Envelope
Every IPC message is wrapped in Message<T> (message.rs). The current wire version is 5
(WIRE_VERSION = 5).
| Field | Type | Description |
|---|---|---|
wire_version | u8 | Wire format version, always serialized first. |
msg_id | Uuid (v7) | Unique message identifier, time-ordered. |
correlation_id | Option<Uuid> | Links a response to its originating request’s msg_id. |
sender | DaemonId | Sender daemon identity (UUID v7, dmon- prefix). |
timestamp | Timestamp | Dual-clock timestamp: monotonic_ns since the sender started, and wall_ms since the Unix epoch (None when the sender’s clock reads before the epoch). |
payload | T | The event or request payload (typically EventKind). |
security_level | SecurityLevel | Access control level for routing decisions. |
verified_sender_name | Option<String> | Server-stamped name from Noise IK registry lookup. |
origin_installation | Option<InstallationId> | v3: sender’s installation identity. |
agent_id | Option<AgentId> | v3: sender’s agent identity. |
trust_snapshot | Option<TrustVector> | v3: trust assessment at message creation time. |
expects_response | bool | v4: the sender waits for a correlated response (BusClient::request). |
MessageContext carries per-client identity state so Message::new() can populate all fields. A
minimal context requires only a DaemonId; v3 fields default to None.
The bus stamps verified_sender_name from authenticated connections in route_frame() and as
daemon-profile for host announcements in BusServer::publish(). Caller-supplied values are
overwritten. None indicates an unregistered client. Postcard uses positional encoding, so all
Option fields must always be present on the wire; skip_serializing_if is deliberately not used.
Message::new() generates a UUID v7 for msg_id (time-ordered), leaves correlation_id at None,
and sets expects_response to false. The with_correlation(id) builder method sets the
correlation for response messages; expecting_response() marks a request whose sender waits for its
response.
Clearance Model
SecurityLevel Enum
SecurityLevel (core-types/src/security.rs) classifies message sensitivity for bus routing. The
variants, ordered from lowest to highest by their derived Ord:
| Level | Description |
|---|---|
Open | Visible to all subscribers including extensions. |
Internal | Visible to authenticated daemons only. This is the default. |
ProfileScoped | Visible only to daemons holding the current profile’s security context. |
SecretsOnly | Visible only to the secrets daemon. |
Because SecurityLevel derives PartialOrd and Ord, clearance comparisons use standard Rust
ordering: Open < Internal < ProfileScoped < SecretsOnly.
ClearanceRegistry
ClearanceRegistry (registry.rs) maps X25519 static public keys ([u8; 32]) to DaemonClearance
entries:
#![allow(unused)]
fn main() {
pub struct DaemonClearance {
pub name: String,
pub security_level: SecurityLevel,
pub generation: u64,
}
}
The generation counter increments on every key change (rotation or crash-revocation). It is used
by two-phase rotation to detect concurrent revocations.
The registry is populated by daemon-profile at startup from per-daemon keypairs. It is wrapped in
RwLock<ClearanceRegistry> inside ServerState to allow runtime mutation.
After the Noise IK handshake, the server reads the client’s static public key with
Connection::remote_static_key() (which calls TransportState::get_remote_static()). The Noise IK
pattern guarantees the remote static key is available after handshake. The 32-byte key is looked up
in the registry:
- Found: the connection receives the registered name and clearance level.
- Not found: the connection is treated as an ephemeral client with
SecretsOnlyclearance.
The registry supports rotate_key(old, new) (removes old entry, inserts new with incremented
generation), revoke(pubkey) (removes and returns the entry), register_with_generation (for
revoke-then-reregister flows), and find_by_name (linear scan, acceptable for fewer than 10
daemons).
Routing Enforcement
route_frame() decodes the frame, admits it (admit: identity binding and sender clearance under
one lock acquisition), binds the daemon name on DaemonStarted (bind_name), stamps the verified
identity, and delivers the frame as a response (deliver_response) or as a request or broadcast
(broadcast). It enforces two clearance rules:
- Sender clearance: A daemon may only emit messages at or below its own clearance level. If
conn.security_clearance < msg.security_level, the frame is rejected and anAccessDeniedresponse is sent back to the sender. - Recipient clearance: When broadcasting, the server skips subscribers whose
security_clearanceis below the message’ssecurity_level.
Sender Identity Verification
On the first message from a connection, route_frame() records the self-declared DaemonId.
Subsequent messages must use the same DaemonId. A change mid-session is treated as an
impersonation attempt: the frame is dropped and an AccessDenied response is returned.
The server stamps verified_sender_name onto every routed message by re-encoding it after registry
lookup. If the connection’s trust_snapshot field is not set on the message, the server also stamps
the connection-level TrustVector. This re-encode adds serialization overhead on every routed
frame, but for a local IPC bus with fewer than 10 daemons the cost is negligible (microseconds per
frame).
Ephemeral Clients
Clients whose static public key is not in the ClearanceRegistry receive
SecurityLevel::SecretsOnly clearance. This applies to the sesame CLI and any other transient
tool.
Ephemeral clients are still authenticated: the same-UID check and Noise IK handshake both apply.
They simply lack a pre-registered identity in the registry. The audit log records these connections
as ephemeral-client-accepted events with the client’s X25519 public key and PID/UID.
Key Management
Key generation, persistence, and tamper detection are implemented in noise_keys.rs.
Keypair Generation
generate_keypair() produces an X25519 static keypair via snow::Builder::generate_keypair(). Both
the public and private keys are 32 bytes. The returned ZeroizingKeypair wrapper guarantees private
key zeroization on drop (including during panics), since snow::Keypair has no Drop
implementation. ZeroizingKeypair::into_inner() transfers ownership using mem::take to zero the
wrapper’s copy.
Filesystem Layout
Keys are stored under $XDG_RUNTIME_DIR/pds/:
| File | Permissions | Content |
|---|---|---|
bus.pub | 0644 | Bus server X25519 public key (32 bytes). |
bus.key | 0600 | Bus server private key (32 bytes). |
bus.checksum | default | BLAKE3 keyed hash (32 bytes). |
keys/<daemon>.pub | 0644 | Per-daemon public key (32 bytes). |
keys/<daemon>.key | 0600 | Per-daemon private key (32 bytes). |
keys/<daemon>.checksum | default | Per-daemon BLAKE3 keyed hash (32 bytes). |
The keys/ directory is set to mode 0700 to prevent local users from enumerating registered
daemons.
Atomic Writes
Private keys are written atomically: the key is written to a .tmp file with 0600 permissions set
at open time via OpenOptionsExt::mode, fsynced, then renamed to the final path. This prevents a
window where the key file exists with default (permissive) permissions. The write is performed
inside tokio::task::spawn_blocking to avoid blocking the async runtime.
Tamper Detection Checksums
Each keypair has an accompanying .checksum file containing
blake3::keyed_hash(public_key, private_key) – a BLAKE3 keyed hash using the 32-byte public key as
the key and the private key as the data. On read, the checksum is recomputed and compared to the
stored value. A mismatch produces a TAMPER DETECTED error with instructions to delete the affected
files and restart daemon-profile.
This detects partial corruption or partial tampering (e.g., private key replaced but checksum file untouched). It does not prevent an attacker with full filesystem write access from replacing all three files (private key, public key, checksum) with a self-consistent set. That threat model requires a root-of-trust outside the filesystem such as TPM-backed attestation.
Missing checksum files (from older installations) produce a warning rather than an error, for backward compatibility.
Key Rotation
The ClearanceRegistry supports runtime key rotation via rotate_key(old_pubkey, new_pubkey),
which atomically removes the old entry and inserts the new one with the same name and clearance
level but an incremented generation counter.
The rotation protocol uses KeyRotationPending and KeyRotationComplete events:
daemon-profilegenerates a new keypair for the target daemon, writes it to disk, and broadcastsKeyRotationPendingwith the new public key and a grace period.- The target daemon calls
BusClient::handle_key_rotation, which reads the new keypair from disk, verifies the announced public key matches what is on disk (detecting tampering), reconnects to the bus with the new key, and re-announces viaDaemonStarted. - On reconnection, if the server detects a
DaemonStartedfrom a verified name that already has an active connection, it evicts the stale old connection and registers the new one inname_to_conn.
connect_with_keypair_retry supports crash-restart scenarios where daemon-profile may have
regenerated a daemon’s keypair. Each retry re-reads the keypair from disk with exponential backoff.
Request-Response Correlation
The bus supports three message routing patterns.
Request-Response (Unicast Reply)
Request payloads have one owner in the bus routing contract. The bus unicasts each request to the
unique authenticated connection for that owner with sufficient clearance, including requests
published without waiting for a reply. Missing, ambiguous, or unavailable owners produce an explicit
refusal. ConfigStatusRequest names its target daemon.
When expects_response is set, route_frame() records the request ID, originating connection,
expected responder, and send time. A duplicate pending ID is refused without replacing its original
route. Requests that do not wait for replies and ordinary broadcasts create no entries. Each
insertion first forgets requests older than PENDING_REQUEST_TTL (2 minutes, longer than any client
request timeout), so requests whose answer never arrives do not accumulate. When a response arrives
(identified by having a correlation_id), the server checks the authenticated responder and the
allowed response variant before consuming the matching entry. Configuration status replies must also
name the requested daemon. Request ownership, response variants, and response classification share
the contract table in core-ipc/src/rpc.rs, which retains no request secrets. Invalid answers
preserve the pending route for a valid answer. Valid answers are delivered only to the originating
connection. Responses to expired, unknown, or disconnected requests are never broadcast.
On the client side, BusClient::request() marks the message with expecting_response(), registers
a oneshot::channel waiter keyed by msg_id, sends the message, and awaits the response with a
caller-specified timeout. If the timeout expires, the waiter is cleaned up and a typed Timeout
error is returned.
Confirmed RPC
The server provides register_confirmation(correlation_id, responder, request, mpsc::Sender), which
returns a fallible RAII ConfirmationGuard; duplicate registration is refused. When a correlated
response matching the registered ID, authenticated responder, and request’s response schema arrives
at route_frame(), the route is consumed and the stamped frame is sent to the confirmation channel,
and also to the requesting connection when one waits for it. A dropped confirmation or response
frame (full channel) is logged. The ConfirmationGuard deregisters the route on drop, preventing
stale entries from accumulating if the caller times out or encounters an error. Cleanup identifies
the particular registration, so delayed cleanup cannot delete a replacement route reusing the ID.
Host-to-secrets confirmations name daemon-secrets as responder; external profile transition requests
remain owned by daemon-profile.
Pub-Sub Broadcast
Messages without a correlation_id that are neither requests nor responses are broadcast to all
connected subscribers whose security_clearance meets or exceeds the message’s security_level.
The sender’s own connection is excluded to prevent feedback loops. The same echo-suppression applies
to BusServer::publish() for in-process subscribers (it decodes the frame to extract the sender
DaemonId and skips matching connections). Host publication accepts announcements only: malformed
frames, request and response payloads, correlated frames, response-waiting frames, and mismatched
envelope/security arguments are dropped. Host RPCs use named unicast and confirmation routes; host
replies use validated pending routes.
Named Unicast
The server maintains a name_to_conn: HashMap<String, u64> mapping, populated when route_frame()
processes DaemonStarted events from connections with a verified_sender_name.
send_to_named(daemon_name, frame) resolves the daemon name to a connection ID for O(1) unicast
delivery without broadcasting.
Socket Path Resolution
socket_path() in transport.rs resolves the platform-appropriate socket path:
| Platform | Path |
|---|---|
| Linux | $XDG_RUNTIME_DIR/pds/bus.sock |
| macOS | ~/Library/Application Support/pds/bus.sock |
| Windows | \\.\pipe\pds\bus |
On Linux, XDG_RUNTIME_DIR must be set; its absence is a fatal error.
Socket Permissions
The bus server applies defense-in-depth permissions on bind:
- The socket file is set to mode
0700. - The parent directory is set to mode
0700.
The real security boundary is UCred UID validation (the same-UID check in the accept loop), but
restrictive filesystem permissions harden against misconfigured XDG_RUNTIME_DIR permissions.
See Also
- Protocol Evolution – forward compatibility and wire versioning
- Memory Protection – zeroization and secret handling
Protocol Evolution
This page documents how the Open Sesame IPC protocol is versioned and how its schema changes. The governing rule: every binary on a bus is built from one compilation unit and deployed together, so there is exactly one wire format at a time and no decode path for any other.
One Format, No Compatibility Decode
The schema is the EventKind enum in core-types/src/events.rs, carried in the Message<T>
envelope of core-ipc/src/message.rs. Neither has a compatibility path:
EventKindhas no catch-all variant. A discriminant the decoder does not know is a decode error, not a silently ignored event.- No field carries
#[serde(default)]. A message missing a field is a decode error, not a message completed with defaults.
A bus where one binary is older than another is a deployment fault, and it fails loudly at the first
message rather than misinterpreting one. core-types tests pin both properties:
an_unknown_variant_is_a_decode_error (JSON and postcard) and a_missing_field_is_a_decode_error.
Postcard Encoding Properties
The IPC bus uses postcard for all serialization. Its encoding is what makes the rule above
necessary.
Externally-Tagged Enums
EventKind uses serde’s default externally-tagged representation; postcard does not support
adjacently tagged enums (#[serde(tag = "...", content = "...")]). Postcard encodes the variant as
a varint index, followed by the variant’s fields in declaration order. A variant is identified by
its position in the enum.
Positional Field Encoding
Postcard encodes struct and variant fields positionally, by declaration order, not by name. Every
field is always serialized: an Option field is written as its None tag, never skipped
(skip_serializing_if would shift every later field). A decoder built from other source reads a
different sequence of fields; the wire version and the single compilation unit exist so that this
never happens on a running bus.
Wire Version Field
Message<T> begins with wire_version: u8, the WIRE_VERSION constant of message.rs (currently
5), stamped by Message::new(). The source documents the contract:
WIRE FORMAT CONTRACT:
Fields in positional order:
wire_version,msg_id,correlation_id,sender,timestamp,payload,security_level,verified_sender_name,origin_installation,agent_id,trust_snapshot(v3),expects_response(v4).Every binary on a bus is built from one compilation unit and deployed together; there is no decode path for other versions.
The version records envelope and payload schema generations:
- v2: 8 fields (
wire_versionthroughverified_sender_name). - v3: 11 fields (adds
origin_installation,agent_id,trust_snapshot). - v4: 12 fields (adds
expects_response: the bus records a pending request only for a sender that waits for its response). - v5: configuration status requests and responses, revision-bearing
ConfigReloaded, explicit inventory errors in status responses, andPolicyUnavailablesecret denials. The envelope retains its twelve fields.
There is no version negotiation and no version-conditional decoding: every daemon on a bus runs the same version.
Changing the Schema
Any change to EventKind or Message<T> (a variant added, removed, or reordered; a field added,
removed, reordered, or retyped) changes the wire format. The procedure is the same for all of them:
- Make the change in
core-typesorcore-ipc. - For an
EventKindvariant, add or update its arm in theimpl_event_debug!invocation at the bottom ofevents.rs. The macro is exhaustive, so a missing arm is a compile error. A variant carrying secret material goes in thesensitivesection with its secret fields markedREDACTED; every other variant goes in thetransparentsection. - Increment
WIRE_VERSIONfor every wire schema change, including payload changes. UpdateMessageContextwhen a new envelope field is populated by the sender. - Rebuild and deploy every binary together.
Sensitivity Redaction
The Debug implementation of EventKind is generated by impl_event_debug!, which separates
sensitive variants from transparent ones. The sensitive variants are SecretGetResponse (value),
SecretSet (value), and FactorSubmit (key_material): their secret-bearing fields render as
[REDACTED; N bytes]. The secret bytes themselves travel in SensitiveBytes, whose own Debug is
redacted and whose storage is protected memory.
What a Deployment Must Change Together
Because there is one wire format, these change only by rebuilding and redeploying every binary:
EventKindvariants and their fields.- The
Message<T>envelope. - The framing layer (length-prefix format, encryption chunking).
- The Noise handshake parameters.
See Also
- IPC Bus Protocol – transport, framing, and routing details
Sandbox Model
Every daemon but daemon-launcher runs inside three layers of containment on Linux: Landlock
(filesystem, sockets, scopes), seccomp-bpf (system calls and socket families), and systemd unit
hardening. Each daemon is granted what its work needs and nothing else. Every daemon runs under the
strongest sandbox the running kernel enforces: Landlock’s rights and scopes are requested
best-effort, so a newer kernel tightens the sandbox and an older one runs with its own subset,
reported at startup and by sesame status --doctor. seccomp and the unit hardening apply on every
kernel, and a sandbox that cannot be built or applied (a rule that cannot be opened, a failed system
call) is fatal.
Process Hardening
Before the sandbox, every daemon calls platform_linux::security::harden_process()
(PR_SET_DUMPABLE(0): no ptrace attach by other processes of the user, no core dump content;
RLIMIT_CORE 0) and apply_resource_limits() (RLIMIT_NOFILE 4096). These log a failure and
continue; Landlock and seccomp are the boundary.
Applying the Sandbox
core_daemon::sandbox::apply(layout, rules, seccomp) applies Landlock, then seccomp. It runs in
main while the process has exactly one thread, before the async runtime, the configuration
watcher, or any other thread starts, so every thread of the daemon is inside the sandbox: a second
thread is an error, not a partial sandbox. Everything a daemon opens afterwards (the bus, Wayland,
its keys, the vaults) is reached through a rule. core_types::init_secure_memory() probes
memfd_secret before the sandbox, and memfd_secret stays in every allowlist.
Landlock
platform-linux/src/sandbox.rs holds the one Landlock ruleset definition; each daemon supplies only
its rules, derived from core_layout::Layout by the rule functions of core-daemon/src/sandbox.rs,
so the granted paths and the paths the daemon opens are one derivation.
Coverage: Every Right the Kernel Enforces
The ruleset requests every access right and scope of Landlock ABI 10 (Linux 7.2) under
CompatLevel::BestEffort, the compatibility model of the kernel’s Landlock documentation (“Backward
and forward compatibility”) and of the landlock crate: the kernel enforces the rights of its own ABI
and the rest are dropped. The daemons therefore run on every kernel, and inherit each protection a
newer kernel adds without a change to the code. restrict_self reports the result: fully enforced,
partially enforced, or not enforced (no Landlock).
What a kernel does not enforce is a core_types::SandboxProtection, found by building a
HardRequirement ruleset of that protection’s rights alone (nothing is created in the kernel and
nothing is restricted):
| Protection | Rights | Linux |
|---|---|---|
Filesystem | AccessFs of ABI 1 | 5.13 |
Reparenting | Refer | 5.19 |
Truncation | Truncate | 6.2 |
Tcp | BindTcp, ConnectTcp | 6.7 |
DeviceIoctl | IoctlDev | 6.10 |
Scopes | abstract Unix sockets, signals | 6.12 |
PathnameSockets | ResolveUnix | 7.1 |
Udp | BindUdp, ConnectSendUdp | 7.2 |
A daemon on a kernel that lacks some logs landlock: partially enforced at warning level with each
missing protection and its consequence, and continues; without Landlock it logs
landlock: not enforced and continues under seccomp and its unit. sesame status --doctor platform
reports the same: platform.kernel carries the release and the enforcement
(7.2.15, Landlock fully enforced), and passes with no protection missing or warns naming each
missing one with the Linux release that enforces it.
Floor: [global.sandbox] require
A protection named in require (the table’s names in kebab case: filesystem, reparenting,
truncation, tcp, device-ioctl, scopes, pathname-sockets, udp) is a floor:
[global.sandbox]
require = ["filesystem", "scopes", "pathname-sockets"]
On a kernel that does not enforce one, every sandboxed daemon refuses to start with an error naming
each unmet protection, before anything is restricted, and platform.kernel fails, naming the floor
and what the kernel lacks of it. On a kernel that meets it, the floor’s rights are requested as
CompatLevel::HardRequirement and every other right best-effort (the landlock crate’s pattern for a
minimum with opportunistic additions). An unknown name fails the configuration load, listing the
accepted ones. The floor is read when a daemon starts; a reload does not re-sandbox a running
daemon.
PathnameSockets is the one whose absence opens a path out of the sandbox. Below ABI 9, Landlock
does not mediate connect(2) or addressed sendmsg(2) to a pathname Unix socket, so a sandboxed
process reaches every socket it can name: the session D-Bus bus among them, where
org.freedesktop.systemd1 (StartTransientUnit) runs any command outside the sandbox. Under
systemd, InaccessiblePaths=-%t/bus removes the session bus socket from each sandboxed unit’s mount
namespace on every kernel (see systemd Unit Hardening); a daemon started
outside its unit has only Landlock. With ResolveUnix handled, a socket is reachable only under a
rule granting it (FsAccess::ReadWriteFile on the socket, FsAccess::ReadWrite on its directory).
Scopes
On a kernel that enforces them (Linux 6.12), every daemon runs with both scopes: it cannot connect
to an abstract-namespace Unix socket created outside its domain (Xwayland and some session buses
listen on abstract addresses), and it cannot signal a process outside it. Abstract sockets cannot be
granted by a rule; every socket a daemon uses is a pathname socket (the user service manager’s
NOTIFY_SOCKET is $XDG_RUNTIME_DIR/systemd/notify).
Rules
| Rule function | Grants |
|---|---|
ipc_client_rules | <runtime>/pds/keys (read), <runtime>/pds/bus.endpoint (read), <runtime>/pds/bus.sock (connect) |
config_rules(access) | ~/.config/pds with access; read-only access to the declared deployment root /nix/store, system policy directory /etc/pds, and SESAME_CONFIG_READ_ROOTS |
notify_rules | The systemd notification socket, when it is a filesystem socket that exists |
ssh_agent_rules | Every SSH agent socket candidate ($SSH_AUTH_SOCK, ~/.ssh/agent.sock) and its directory, and, for a symlink, its resolved target and the target’s directory |
wayland_rules | The Wayland compositor socket |
system_bus_rules | The system D-Bus socket of Layout::system_bus_socket ($DBUS_SYSTEM_BUS_ADDRESS, one unix:path= address, or /var/run/dbus/system_bus_socket) |
No rule function grants the session D-Bus bus, and no daemon is granted it. The platform keyring
factor of the overlay’s inline unlock is read by daemon-launcher (KeyringUnlockRequest), outside
the sandboxes.
Configuration grants do not follow startup symlink targets to infer authority. A deployment that
rotates symlinks outside the built-in roots declares its stable parent directories in
SESAME_CONFIG_READ_ROOTS before startup (platform path-list syntax; colon-separated on Linux).
Entries must be absolute and contain no parent traversal. Each entry grants its whole tree. Roots
must exist when the sandbox is installed; adding a root requires restart. Replacing a configuration
symlink neither expands authority nor pins access to its previous generation.
A rule for a path that does not exist yet (the vaults before sesame init) is skipped: Landlock
denies every path outside the ruleset, so a skipped rule grants less. A path whose existence cannot
be determined is an error. On a non-directory inode (a socket, a file), directory-only rights are
masked off before the rule is added.
FsAccess::ReadOnly grants Execute, ReadFile, and ReadDir (the landlock crate’s
AccessFs::from_read). It does not grant IoctlDev: Landlock records the ioctl right of a
character or block device when the device is opened and refuses every driver ioctl without it
(EACCES), except the few the kernel always permits (FIOCLEX, FIONBIO, and the file-system
queries). A daemon that opens devices inside its sandbox and identifies them by ioctl is granted
them with FsAccess::ReadDevice, ReadOnly plus IoctlDev.
| Daemon | Rules |
|---|---|
| daemon-profile | config_rules(ReadWrite), <runtime>/pds (read-write: it binds the bus socket and writes the keys and endpoint), notify_rules; with the desktop feature system_bus_rules (the Wi-Fi monitor) and, in a Wayland session, wayland_rules (the focus monitor) |
| daemon-secrets | ipc_client_rules, config_rules(ReadWrite) (vault databases, salts, metadata), notify_rules |
| daemon-wm | ipc_client_rules, wayland_rules, config_rules(ReadOnly) (vault salts and enrollments for inline unlock), ssh_agent_rules, notify_rules; ~/.cache/open-sesame (read-write: MRU stack); read: ~/.config/cosmic (the COSMIC theme, opened only where its config directories exist), user data, /etc/fonts, /usr/share/fonts, /lib, /nix/store, /proc, /usr/share, /usr/share/X11/xkb. No DRI or GPU paths: rendering is wl_shm |
| daemon-clipboard | ipc_client_rules, config_rules(ReadOnly), notify_rules, wayland_rules, ~/.cache/open-sesame (read-write: history database) |
| daemon-input | ipc_client_rules, config_rules(ReadOnly), notify_rules; /dev/input (ReadDevice: evdev identifies keyboards with EVIOCG* ioctls); read: /sys/class/input, /sys/devices (evdev metadata) |
| daemon-snippets | ipc_client_rules, config_rules(ReadOnly), notify_rules |
daemon-launcher
daemon-launcher applies neither Landlock nor seccomp: both are inherited across fork and exec
and would confine every application it launches. Its boundary is bus authentication (Noise IK). It
is also the broker of the platform keyring factor for daemon-wm, serving KeyringUnlockRequest only
from the bus-verified sender daemon-wm: the request unlocks a vault without the user.
seccomp-bpf
apply_seccomp loads a libseccomp filter whose default action kills the process
(SECCOMP_RET_KILL_PROCESS): killing a thread would leave the daemon running without it, and an
error return would let a compromised process probe the allowlist. A system call through another
architecture’s ABI also kills the process (set_act_badarch), which closes socketcall(2)
multiplexing and 32-bit entry points. The filter is synchronized onto every thread (TSYNC). The
kernel records each kill (type=SECCOMP) when kill_process is listed in
/proc/sys/kernel/seccomp/actions_logged.
socket and socketpair are admitted only with AF_UNIX as their family (argument 0): every
socket a daemon opens is Unix-domain, so no daemon creates a network, netlink, packet, or vsock
socket. io_uring is in no allowlist, so it cannot create sockets around the filter.
Every allowlist is core_daemon::sandbox::BASE_SYSCALLS (file I/O, memory, mremap, with which
glibc’s realloc grows an mmap-backed allocation, threads, the tokio event
loop and timers, nanosleep and clock_nanosleep, with which coherent configuration readers back
off while a transaction publishes, Unix sockets, signals, inotify, memfd_secret, getrandom,
getcwd, which backtrace capture of an error report makes, and mlock/munlock: SQLCipher locks
its private heap at the first database use and unlocks it in its atexit shutdown, inside the
sandbox, as does ProtectedAlloc without memfd_secret) plus the calls of the daemon’s own work.
Work that needs more than the base only once, before the sandbox, is done before it: daemon-input
compiles its XKB keymap before the sandbox, so neither the XKB data nor libxkbcommon’s
real-versus-effective ID check (getgid, getegid) is granted afterwards.
core_layout::file::write publishes with tempfile’s persist, which renames through rustix: the
call is renameat (renameat2 on riscv64), never rename. daemon-profile is the sandboxed daemon
that publishes files (its keys, the bus endpoint, configuration transactions).
| Daemon | Calls beyond the base |
|---|---|
| daemon-profile | bind, listen, accept4 (bus server); unlink, renameat, chmod, fchmod, fchown, flock, fsync, fdatasync (owner-only files written atomically); getresuid, getresgid, getgid, getegid (D-Bus credentials); writev, readv, readlinkat, uname, memfd_create, sched_yield, timerfd_create, timerfd_settime, timerfd_gettime |
| daemon-secrets | pwrite64, fallocate, flock, fsync, fdatasync, rename, unlink (SQLCipher); writev, readv, readlinkat, uname |
| daemon-wm | flock, rename, unlink, chmod, fchmod, fsync, fdatasync (MRU stack); getresuid, getresgid, getgid, getegid; statfs, fstatfs, memfd_create, mlock2, mremap, writev, readv, readlinkat, uname, accept4, bind, listen, sched_yield, sched_get_priority_max, timerfd_create, timerfd_settime, timerfd_gettime, sysinfo (Wayland and SCTK runtime) |
| daemon-clipboard | flock, fsync, fdatasync (SQLite) |
| daemon-input | none |
| daemon-snippets | none |
platform-linux/src/sandbox.rs tests each property in a child process, since both layers last for
the process’s life, and expects of each kernel what it enforces: an ungranted pathname socket is
refused where PathnameSockets is enforced and reachable where it is not, a granted one is
reachable, an abstract socket outside the domain is refused where Scopes is enforced, the status
apply_landlock returns is the one the kernel’s gaps predict, and socket(AF_INET) kills the
process while AF_UNIX is admitted. A table test checks that the protections name every requested
right exactly once. tests/protocol_validation.sh runs every daemon of a build through its
lifecycle under an isolated root, each as a transient user service under the [Service] sandboxing
of its shipped unit (the read-only mounts included), checks that each reports the enforcement the
doctor predicts, and fails on any seccomp kill the kernel records for them. CI installs the built
.deb, .rpm, and .pkg.tar.zst in their distributions’ systemd containers
(scripts/docker/verify-install.sh) and fails unless every headless daemon runs under its installed
unit; no release is tagged or published otherwise.
systemd Unit Hardening
Each daemon is a systemd user service (contrib/systemd/), Type=notify (daemon-profile
Type=notify-reload) with WatchdogSec=30, NoNewPrivileges=yes, LimitCORE=0, and
LimitMEMLOCK=64M.
The six sandboxed daemons also set, as a second layer over the in-process filters:
| Directive | Effect |
|---|---|
ProtectSystem=strict, ProtectHome=read-only | The file system is read-only except the unit’s ReadWritePaths |
RestrictAddressFamilies=AF_UNIX | systemd’s socket family filter, the same as the in-process rule |
SystemCallArchitectures=native | Only the native system call ABI |
InaccessiblePaths=-%t/bus | The session D-Bus socket is absent from the daemon’s mount namespace |
For a user service, the mount namespace options imply PrivateUsers= and require unprivileged user
namespaces. daemon-secrets also sets PrivateNetwork=yes.
daemon-launcher sets no mount namespace options: they would apply to every application it launches
(systemd-run --user --scope children share its namespace). It sets ProtectKernelTunables,
ProtectControlGroups, LockPersonality, RestrictSUIDSGID, SystemCallArchitectures=native, and
KillMode=process so launched applications survive a launcher restart. It sets nothing that drops
the capability bounding set (CapabilityBoundingSet, ProtectClock, ProtectKernelModules,
ProtectKernelLogs): a user manager drops it only with CAP_SETPCAP in the service’s user
namespace, which kernel.apparmor_restrict_unprivileged_userns=1 (Ubuntu 24.04’s default) denies,
failing the start with 218/CAPABILITIES; every launched application would inherit it; and an
unprivileged user holds none of those capabilities in the initial user namespace.
Daemon Matrix
| Daemon | Landlock | seccomp | Session D-Bus | Network sockets | Unit mount namespace |
|---|---|---|---|---|---|
| daemon-profile | Y | Y | - | - | Y |
| daemon-secrets | Y | Y | - | - (and PrivateNetwork) | Y |
| daemon-wm | Y | Y | - | - | Y |
| daemon-clipboard | Y | Y | - | - | Y |
| daemon-input | Y | Y | - | - | Y |
| daemon-snippets | Y | Y | - | - | Y |
| daemon-launcher | - | - | Y (systemd-run, keyring broker) | Y (launched applications) | - |
Profile Trust Model
Trust profiles are the fundamental isolation boundary in Open Sesame. Every scoped resource – secrets, clipboard content, frecency data, snippets, audit entries, and launch configurations – is partitioned by trust profile.
TrustProfileName Validation
The TrustProfileName type in core-types/src/profile.rs enforces
strict validation at construction time. It is impossible to hold an
invalid TrustProfileName value after construction.
Invariants:
- Non-empty.
- Maximum 64 bytes.
- Must start with an ASCII alphanumeric character:
[a-zA-Z0-9]. - Body characters restricted to:
[a-zA-Z0-9_-]. - Not
.or..(path traversal prevention). - No whitespace, path separators, or null bytes.
Invalid characters produce a detailed error message including the byte
value and position:
"trust profile name contains invalid byte 0x{b:02x} at position {i}".
These rules make the name safe for direct use in filesystem paths without additional sanitization.
Filesystem mappings:
| Resource | Path pattern |
|---|---|
| SQLCipher vault | vaults/{name}.db |
| BLAKE3 KDF context | "pds v2 vault-key {name}" |
| Frecency database | launcher/{name}.frecency.db |
TrustProfileName implements TryFrom<String> and TryFrom<&str>,
returning Error::Validation on failure. It serializes transparently
(via #[serde(transparent)]) as a plain string and deserializes with
validation. All boundary-facing code – CLI argument parsers, IPC
message handlers, config file loaders – validates at entry.
Profile Scoping
Each trust profile isolates the following resources:
| Resource | Isolation mechanism |
|---|---|
| Secrets | Per-profile SQLCipher vault file. Vault keys are derived via BLAKE3 KDF with profile-specific context strings. |
| Clipboard | Cross-profile clipboard access is denied and logged as AuditAction::IsolationViolationAttempt. |
| Frecency | Per-profile SQLite database for launch frecency ranking. Profile switch in daemon-launcher triggers engine.switch_profile(). |
| Extensions | Extension data is scoped per profile via IsolatedResource::Extensions. |
| Window list | Window management state is scoped per profile via IsolatedResource::WindowList. |
| Audit | Audit entries record which profile was involved in each operation via ProfileId fields. |
| Launch profiles | Launch profile definitions live under profiles.<name>.launch_profiles in configuration. |
The IsolatedResource enum in core-profile/src/lib.rs defines the
five isolatable resource types: Clipboard, Secrets, Frecency,
Extensions, WindowList. It is serialized with
#[serde(rename_all = "lowercase")] for configuration and audit log
entries.
Profile State Machine
Each profile has an independent lifecycle state, represented by the
ProfileState enum:
- Inactive: vault closed, no secrets served.
- Active(ProfileId): vault open, serving secrets.
- Transitioning(ProfileId): activation or deactivation in progress.
Multiple profiles may be active concurrently. There is no global “active
profile” singleton – the system supports simultaneous active profiles
with independent vaults. The active_profiles set in daemon-profile is
a HashSet<TrustProfileName>.
Context-Driven Activation
The ContextEngine in core-profile/src/context.rs evaluates system
signals against activation rules to determine the default profile for
new unscoped launches. Changing the default does not deactivate other
active profiles.
Context Signals
Signals that trigger rule evaluation:
| Signal | Source |
|---|---|
SsidChanged(String) | WiFi network change via D-Bus SSID monitor (platform_linux::dbus::ssid_monitor). |
AppFocused(AppId) | The focused app changed, from the compositor backend’s activation reports (platform_linux::compositor::detect_compositor). |
UsbDeviceAttached(String) | USB device insertion (vendor:product identifier). |
UsbDeviceDetached(String) | USB device removal. |
HardwareKeyPresent(String) | Hardware security key detection (e.g., YubiKey). |
TimeWindowEntered(String) | Time-based rule trigger (cron-like expression). |
GeolocationChanged(f64, f64) | Location change (latitude, longitude). |
Signal sources are spawned as long-lived tokio tasks in
daemon-profile/src/main.rs. They are conditionally compiled behind
#[cfg(all(target_os = "linux", feature = "desktop"))].
Activation Rules
Each profile’s activation configuration (ProfileActivation) contains:
- rules: a
Vec<ActivationRule>, each specifying aRuleTriggertype and a string value to match. - combinator:
RuleCombinator::All(every rule must match the signal) orRuleCombinator::Any(one matching rule suffices). - priority:
u32value. When multiple profiles match, the highest priority wins. - switch_delay_ms:
u64debounce interval in milliseconds. Prevents rapid oscillation when a signal fires repeatedly.
Evaluation Algorithm
When ContextEngine::evaluate(signal) is called:
- All profiles whose rules match the signal are collected. For
Allcombinators, every rule in the profile must match; forAny, at least one rule must match. - Candidates are sorted by priority descending.
- The highest-priority candidate is selected.
- If it is already the current default,
Noneis returned (no change). - Debounce check: if the candidate was last switched to within
switch_delay_msago,Noneis returned. - Otherwise, the default is updated, the switch time is recorded, and
the new
ProfileIdis returned.
Rule matching is type-strict: an Ssid trigger only matches
SsidChanged signals, an AppFocus trigger only matches AppFocused
signals, and so on. Mismatched trigger/signal pairs always return false.
Default Profile
The default profile determines which trust profile is used for new
unscoped launches (launches without an explicit --profile flag). It
is set by:
- Configuration:
global.default_profilein the config file, loaded at startup. - Context engine: automatic switching based on runtime signals overrides the config default.
- Hot reload: when config changes are detected by
ConfigWatcher, the context engine is rebuilt with the new default and thedefault_profile_nameis updated. Theconfig_profile_nameslist is also refreshed so thatsesame profile listreflects added or removed profiles.
Default profile changes are:
- Audited via
AuditAction::DefaultProfileChanged. - Broadcast on the IPC bus as
EventKind::DefaultProfileChanged. - Reported by
sesame status.
Profile Inheritance
There is no profile inheritance in the current implementation. Each
trust profile is an independent, self-contained configuration with its
own launch profiles, vault, and isolation boundaries. Cross-profile
interaction is limited to qualified tag references (e.g., work:corp)
in launch profile composition, which merge environment at launch time
without merging the profile definitions themselves.
Workspace Conventions
Open Sesame enforces a deterministic directory layout for source code repositories. Git remote URLs
are parsed into canonical filesystem paths following the convention
{root}/{user}/{server}/{namespace...}/{repo}.
Canonical Path Convention
Every repository maps to a unique filesystem path:
/workspace/{user}/{server}/{namespace...}/{repo}
For example:
| Remote URL | Canonical path |
|---|---|
https://github.com/scopecreep-zip/open-sesame | /workspace/alice/github.com/scopecreep-zip/open-sesame |
git@github.com:braincraftio/k9.git | /workspace/alice/github.com/braincraftio/k9 |
https://gitlab.com/Group/SubGroup/Project | /workspace/alice/gitlab.com/group/subgroup/project |
The root is $SESAME_WORKSPACE_ROOT when set, otherwise settings.root in workspaces.toml
(default /workspace). WorkspaceLayout in sesame-workspace/src/config.rs is the single owner of
root and user resolution: an existing root is canonicalized, so a symlinked root and its target
produce the same paths and the same link keys.
URL Parsing
convention::parse_url and convention::parse_clone_input in sesame-workspace/src/convention.rs
accept:
| Form | Example |
|---|---|
| HTTPS | https://github.com/org/repo[.git], https://host:8443/group/sub/repo |
| SCP-style SSH | git@github.com:org/repo.git |
ssh:// | ssh://git@host:2222/org/repo.git, ssh://git@[::1]/org/repo |
| Shorthand (clone only) | org/repo (default server), server.tld/org/repo |
Parsing is strict:
- A port must be a valid
u16; a bad port, or anything other than:portafter a bracketed IPv6 address, is anInvalidUrlerror. - Query strings, fragments, and null bytes are rejected.
- An HTTPS URL that carries credentials (
https://user:token@host/...) is rejected; credentials come from a git credential helper. Every URL printed in an error has its userinfo replaced by***(net::redact_credentials). http://URLs log a warning about cleartext transport.
Clone Targets
parse_clone_input returns a CloneInput with a RemoteTarget and a WorkspaceCoordinate:
RemoteTarget::Repository(RemoteEndpoint): a cloneable repository, in the transport, port, user, and spelling supplied.RemoteTarget::Organization { host, namespace }: a URL with no repository component (https://github.com/ScopeCreep-zip); only--projectclones it, through the forge API.
The coordinate’s WorkspaceKind is:
Repository(RepoDir): a regular or member repository.WorkspaceRepository: a repository whose placement equals the placement ofsettings.workspace_repo(defaultworkspace); it is placed at the namespace directory itself, which then holds its member repositories as siblings inside its working tree.Organization: the namespace directory of an organization URL.
Cloning a workspace repository into an existing namespace directory initializes the repository
around the existing content. With or without --force, it refuses when the workspace repository
tracks paths inside an existing member repository directory, and lists them. Without --force it
also refuses to overwrite existing files.
Remote Spelling and Placement
Identity types form two vocabularies with a one-way mapping:
| Vocabulary | Types | Case |
|---|---|---|
| Remote (forge-facing) | GitHost, NamespacePath, RepositoryName, RemoteIdentity, RemoteEndpoint | Preserved as given |
| Placement (filesystem-facing) | WorkspaceUser, NamespaceDir, RepoDir, WorkspaceCoordinate | Lowercase by construction |
- Clone URLs render the remote spelling. Explicit URLs are never rewritten; case-sensitive servers
(
git daemon,git-http-backend, bare repositories over SSH) receive exactly the path supplied. - Placement is derived from remote identity through
WorkspaceCoordinate::from_remote_*. Every spelling of one remote (NixOS/NixPkgs,nixos/nixpkgs) resolves to one directory (github.com/nixos/nixpkgs) on every filesystem. No mapping from placement back to remote exists. - Server names are lowercased (
GITHUB.COMbecomesgithub.com). - One
.gitURL suffix, in any case, is stripped from repository names.
Because placement is lowercase, remotes that differ only in case share a directory.
sesame workspace clone adopts an existing repository only when its origin is exactly the
requested remote identity (host, namespace, and repository spelling; transport and port do not
matter). A different origin at the same placement is a PlacementConflict error naming both
remotes, and an existing directory that is not a repository root is refused before git runs.
Directory names read from disk are parsed strictly: a name that is not canonical (NixOS,
GitHub.com) is a NonCanonical error, never a silent normalization. Before any clone or workspace
setup, WorkspaceLayout::checked_path rejects a canonical path when a sibling differing only in
case already exists (CaseConflict).
Component validation rejects:
| Condition | Rejection reason |
|---|---|
| Empty component | Empty directory name. |
Leading . (user, namespace segment) | Hidden directories are never forge user or namespace identifiers. |
Exactly . or .. | Path traversal attack. |
Contains / or \ | Path separator embedded in component. |
| Contains null byte | Null byte injection. |
| Non-ASCII characters | Lowercase placement must be length-preserving and collision-free. |
| Exceeds 255 bytes | Filesystem component length limit (ext4, btrfs). |
| Leading/trailing whitespace | Filesystem ambiguity. |
Repository names permit a leading . because forges host repositories such as .github and
.dotfiles; github.com/org/.github maps to /workspace/{user}/github.com/org/.github. A
repository name whose placement is .git (.git, .GIT, .git.git) is rejected as reserved: it
would resolve to the namespace directory’s own git metadata, which is the workspace repository.
Layout Discovery
Repository Detection
git::git_marker in sesame-workspace/src/git/marker.rs is the only repository detector. It
classifies a directory by its .git entry through gix::discover::is_git:
.git entry | Marker | Role in the layout |
|---|---|---|
| Absent | Absent | Namespace directory, if it leads to a repository |
| Repository git directory | Repository | Repository root |
Gitfile to <main>/.git/worktrees/<id> | LinkedWorktree | Repository root, placed like a clone |
Gitfile into an ancestor’s .git/modules/... | Submodule | Content of the superproject, never layout |
A symlinked .git is rejected, and an invalid one is an error.
The Layout Walk
layout::walk in sesame-workspace/src/layout.rs is the single traversal that discovery and
normalization both consume. It visits each directory under {root}/{user} once:
- A directory outside any repository is a namespace directory only when some directory below it is a
repository root. Trees that lead to no repository (
Notes/Meeting Docs,Archive/) are not layout at any depth and are never reported or renamed. - A repository root whose direct children include member repositories (repository roots or linked worktrees, not submodules) is a workspace root. Inside its working tree only directories that are, or lead to, member repositories are layout; everything else is the workspace repository’s own content.
- Any other repository root is a leaf; its contents are not walked.
- Nested workspace roots are treated identically by discovery and normalization.
- Symlinks are never followed. A symlink at layout level, and an unreadable directory inside workspace content, is recorded as skipped (path and reason) instead of failing the walk; symlinks inside workspace content are that repository’s content and are not recorded. An unreadable layout directory is an issue.
- Directory names are held as
OsString; a non-UTF-8 layout name is reported with its real path.
discover::discover_workspaces parses every layout directory name strictly into a
DiscoveredWorkspace { path, coordinate, linked_profile }. Entries it cannot place are
DiscoveryIssue { path, error }: non-canonical names, case variants of the user directory,
undecodable server directories, repositories with no namespace, and non-UTF-8 names. Skipped entries
are listed separately.
sesame workspace list
sesame workspace list prints the placed entries grouped by server and namespace. Workspace
repositories are rows of their own namespace group, and the group header is tagged (workspace).
Issues go to stderr as ! <path>: [<kind>] <error>, followed by the number of skipped entries. Only
NonCanonical and CaseConflict issues suggest sesame workspace normalize; every other issue
names its own cause.
--format json prints one document:
{
"workspaces": [
{
"path": "...",
"server": "github.com",
"namespace": "org",
"repo": "repo",
"kind": "repository"
}
],
"issues": [{ "path": "...", "kind": "case-conflict", "message": "...", "normalizable": true }],
"skipped": [{ "path": "...", "reason": "symlink not followed" }]
}
kind is repository or workspace. Discovery never places an organization, since an organization
has no directory of its own to discover.
--stale takes the units the LAST column prints: m (minutes), h, d, w, mo (30 days),
y (365 days).
Exit status: 0 when every layout entry was placed; 1 when any entry could not be placed (the listing is still printed) or on any other error.
Normalization
sesame workspace normalize (dry run) and sesame workspace normalize --apply bring existing
directories to their canonical names, using the same layout walk:
- The user directory is the first step: a case variant (
Alice) is renamed to the canonical user (alice). - Server, namespace, repository, and member-path directories follow, top down. Repository contents, submodule checkouts, and trees that lead to no repository are never renamed.
- A directory whose canonical name is held by a different directory, or claimed by an earlier rename in the same pass, is a collision and is never resolved automatically.
- Names that cannot be made canonical (non-UTF-8, non-ASCII, undecodable server directories) are unfixable and reported; they do not stop the pass.
- Every rename is atomic and never replaces an existing directory (
renameat2(RENAME_NOREPLACE)on Linux and Android,renameatx_np(RENAME_EXCL)on Apple platforms; no fallback to a replacing rename). A case-only rename on a case-insensitive filesystem goes through a unique temporary name and is restored if the second step fails.
Stored paths are rewritten through the renames actually performed:
- linked-worktree link files:
<admin>/gitdir, an absolute<admin>/commondir(libgit2 writes it absolute, git writes../..), and the worktree’s.gitfile; - profile links in
workspaces.tomlandworkspaces.d/*.toml, each in the file that defines it; - launch-profile
cwdanddevshellvalues inconfig.toml,config.d/*.toml, and everyprofiles/*/config.toml. Values in the read-only system policy are reported, never written.
Exit status: 0 when the layout is (or after --apply would be) fully canonical; 1 when collisions,
unfixable names, read-only policy values, or failures remain.
Workspace Configuration
workspaces.toml
The user-level workspace configuration is stored at ~/.config/pds/workspaces.toml, with
workspaces.d/*.toml fragments loaded after it. The schema is WorkspaceConfig in
core-config/src/schema_workspace.rs:
[settings]
root = "/workspace"
transport = "https"
default_server = "github.com"
workspace_repo = "workspace"
workspace_auto = "auto"
[links]
"/workspace/alice/github.com/org" = "personal"
"/workspace/alice/github.com/org/k9" = "work"
Settings fields:
| Field | Type | Default | Description |
|---|---|---|---|
root | path | /workspace | Root directory for all workspaces; $SESAME_WORKSPACE_ROOT overrides it. |
transport | https or ssh | https | Transport for shorthand clone input; explicit URLs are never rewritten. |
default_server | GitHost | github.com | Server for org/repo shorthand. |
workspace_repo | RepositoryName | workspace | Repository name placed at the namespace directory as its workspace repository. |
workspace_auto | auto, always, never | auto | Org workspace repository setup on clone (below). |
The {user} directory is not a setting: it is the account the process runs as, read from the
operating system’s user database (Layout::login_user): the entry of the effective uid on Unix
(getpwuid_r, through NSS), the process token’s account on Windows (GetUserNameW). It is the name
id -un and whoami report; $USER is not consulted, so docker exec --user, sudo -u, and
service managers place clones under the account they run as. The name is validated as a
WorkspaceUser and stored lowercase, so alice’s clones land in /workspace/alice. An account
with no name in the user database, or a name that is not a valid directory name, is an error
(WorkspaceError::LoginUser), never a substituted name.
sesame workspace init creates <root>/<user> and writes root through core_config::edit, which
edits only the file that defines the key and keeps comments and ordering; a user key left in the
file is removed.
Links section: a map from physical paths to profile names. Keys are written for the path’s
physical form (symlinks resolved, trailing separators dropped), so /a/b and /a/b/ cannot both be
keys.
Org Workspace Setup
A member clone, and --project, set up the namespace’s workspace repository through one decision:
| Namespace directory | auto | always (or --workspace-init/--workspace-update) |
|---|---|---|
| Absent | Clone it when the forge hosts one | Clone it when the forge hosts one |
| Workspace repository | Report when it is behind upstream | Fast-forward it |
| Other existing directory | Print a tip | Initialize around it with --force; without it, report the command |
never and --no-workspace skip setup. Cloning the workspace repository itself skips it, so the
requested endpoint, transport, and port are used. A setup failure is printed and does not fail the
clone that triggered it.
--project prints the number of repositories the forge listed and the number processed (the
workspace repository is excluded), and exits 1 when any repository failed to clone. On GitHub, an
owner is tried as an organization first; only a 404 falls back to the user endpoint, and rate limits
and other failures are returned.
Project discovery is public-only by default, even with GITHUB_TOKEN set. Both sesame clone and
sesame workspace clone accept --include-private with --project to include private repositories
accessible to that token. An absent or blank token is rejected before org workspace setup. API
authentication is separate from Git transport authentication; configure a Git credential helper for
private HTTPS clones.
GITHUB_TOKEN="$(gh auth token)" sesame workspace clone --project \
--include-private --include-forks --include-archived https://github.com/sesameos
Organization discovery uses type=all when private repositories are requested. User discovery
combines the user’s public listing with the authenticated private listing, restricted to the
requested owner. Both listings are paginated. Fork and archive filters still apply, and the
workspace repository remains at the organization root.
Profile Link Resolution
resolve_workspace_profile in sesame-workspace/src/config.rs resolves the physical form of a path
to a profile name:
- Exact match: the path matches a link key exactly.
- Longest component-wise prefix match: the link key with the most path components that is a
prefix of the path wins. Matching is per component, so
/orgnever matches/organic.
.sesame.toml (Local Config)
Workspace-level and repo-level configuration files (.sesame.toml) provide per-directory overrides.
The schema is LocalSesameConfig in core-config/src/schema_workspace.rs:
# /workspace/alice/github.com/org/.sesame.toml
profile = "work"
secret_prefix = "MYAPP"
tags = ["dev-rust"]
[env]
RUST_LOG = "debug"
| Field | Type | Description |
|---|---|---|
profile | Option<String> | Default trust profile for this context. |
env | BTreeMap<String, String> | Non-secret environment variables to inject. |
tags | Vec<String> | Launch profile tags to apply by default. |
secret_prefix | Option<String> | Env var prefix for secret injection (e.g., "MYAPP" causes api-key to become MYAPP_API_KEY). |
Multi-Layer Config Precedence
resolve_effective_config in sesame-workspace/src/config.rs merges configuration from all layers.
Precedence (highest to lowest):
- Repo
.sesame.toml({path}/.sesame.toml) - Workspace
.sesame.toml({root}/{user}/{server}/{namespace}/.sesame.toml) - User config links (
workspaces.toml[links]section)
A path outside the layout skips the workspace layer; a path inside the layout with a non-canonical directory is an error.
Merge semantics per field:
profile: highest-priority layer wins outright.env: all layers are merged into a singleBTreeMap. Higher-priority keys override lower-priority ones; keys unique to lower layers are preserved.tags: all layers’ tags are concatenated (workspace tags first, then repo tags).secret_prefix: highest-priority layer wins outright.
The ConfigProvenance struct tracks which layer determined each value ("user config link",
"workspace .sesame.toml", or "repo .sesame.toml").
Git Without a git Binary
Git operations use gix for cloning, discovery, and inspection, and libgit2 (git2; bundled in
Cargo builds, nixpkgs’ libgit2 in the Nix packages) for initializing a repository around existing
content and fast-forward pulls. No git CLI is executed and nothing is interpolated into a shell:
- HTTPS remotes are served by gix in-process.
- SSH remotes run the system
sshclient, which runsgit-upload-packon the server, as git does. - Local remotes (
file://or a path) are opened in-process by the remote probe and the upstream-drift check, because gix’s local transport would rungit upload-pack. A relative localoriginis taken relative to its repository. Clones and workspace remotes are built fromRemoteEndpoint, which is HTTPS or SSH only.
Clone failures are classified from gix’s typed handshake and transport errors: missing, empty, or rejected credentials (an HTTP 401 included) are reported as authentication failures with a credential-helper hint.
Cryptographic Agility
Open Sesame implements config-driven cryptographic algorithm selection
across five independent axes: key derivation (KDF), hierarchical key
derivation (HKDF), Noise IPC transport cipher, Noise IPC transport hash,
and audit log chain hash. Algorithm choices are declared in the
[crypto] section of config.toml and dispatched at runtime through
typed enum matching. No algorithm is hardcoded at call sites.
Configuration Schema
The [crypto] section of config.toml maps to CryptoConfigToml
(core-config/src/schema_crypto.rs:14), a string-based TOML
representation with six fields:
[crypto]
kdf = "argon2id"
hkdf = "blake3"
noise_cipher = "chacha-poly"
noise_hash = "blake2s"
audit_hash = "blake3"
minimum_peer_profile = "leading-edge"
These defaults are defined in the Default implementation
(schema_crypto.rs:30-38). At load time,
CryptoConfigToml::to_typed() (schema_crypto.rs:48) converts the
string values to validated enum variants in core_types::CryptoConfig
(core-types/src/crypto.rs:82). Unrecognized algorithm names produce a
core_types::Error::Config error, preventing the daemon from starting
with an invalid configuration.
Algorithm Axes
KDF: Password to Password KEK
The KDF converts a user password and the vault’s 16-byte salt into the
vault’s password key-encrypting key (KEK), the AES-256-GCM key that wraps
the vault’s master key (WrappedKey in .password-wrap). Two algorithms are
available; derive_password_key(algorithm, password, salt)
(core-crypto/src/kdf.rs) dispatches on the vault’s KdfAlgorithm.
argon2id (default, KdfAlgorithm::Argon2id):
- Algorithm: Argon2id v1.3 (hybrid mode, resists both side-channel and GPU attacks)
- Memory cost: 19,456 KiB (19 MiB)
- Time cost: 2 iterations
- Parallelism: 1 lane
- Output: 32 bytes
- Parameters follow the OWASP minimum recommendation
- Implementation:
argon2crate,Argon2::new(Algorithm::Argon2id, Version::V0x13, params)withhash_password_into
pbkdf2-sha256 (KdfAlgorithm::Pbkdf2Sha256):
- Algorithm: PBKDF2-HMAC-SHA256 (RFC 8018)
- Iterations: 600,000 (OWASP recommendation)
- Output: 32 bytes
- Implementation:
pbkdf2::pbkdf2_hmac::<Sha256>
The derived bytes are held in zeroize::Zeroizing and returned as an
EncryptionKey.
HKDF: Key Material to Per-Purpose Keys
Every other 32-byte key is derived from key material (a master key, a
vault key, a salt, a signature, or factor pieces) by
derive_key(algorithm, context, ikm) or, for a key that only encrypts,
derive_encryption_key (core-crypto/src/derive.rs), under the vault’s
HkdfAlgorithm.
blake3 (default, HkdfAlgorithm::Blake3):
- BLAKE3’s
derive_keymode with the context string, which provides extract-then-expand semantics equivalent to HKDF - Implementation:
blake3::derive_key(context, ikm)
hkdf-sha256 (HkdfAlgorithm::HkdfSha256):
- HKDF extract-then-expand per RFC 5869, no salt, the context string as
info, 32 bytes of output - Implementation:
Hkdf::<Sha256>::new(None, ikm)andexpand(context.as_bytes(), &mut key)
The context is a KeyContext, one variant per purpose; its string is
"pds v2 <purpose>", followed by the profile for a per-profile purpose:
KeyContext | Context string | Derived from | Key |
|---|---|---|---|
Vault(profile) | pds v2 vault-key <profile> | Master key | SQLCipher page key |
IpcEncryption(profile) | pds v2 ipc-encryption-key <profile> | Master key | Per-field IPC encryption key |
CombinedMasterKey(profile) | pds v2 combined-master-key <profile> | Factor pieces | Master key of an All-policy vault |
SshChallenge(profile) | pds v2 ssh-challenge <profile> | Vault salt | Challenge the SSH agent signs |
SshVaultKek(profile) | pds v2 ssh-vault-kek <profile> | Challenge signature | KEK of the SSH enrollment |
SqlCipherEntry | pds v2 entry-encryption-key | Page key | Per-entry AES-256-GCM key |
New purposes are new KeyContext variants, so every context string is
declared in one place and none can collide. Intermediate key bytes are
held in zeroize::Zeroizing; derive_key returns SecureBytes.
Noise Cipher: IPC Transport Encryption
The Noise IK protocol used for inter-daemon IPC communication supports
two cipher selections via the noise_cipher config field:
chacha-poly (default, NoiseCipher::ChaChaPoly):
- ChaCha20-Poly1305 authenticated encryption
- Constant-time on all architectures without hardware AES
- The leading-edge default for environments where AES-NI is not guaranteed
aes-gcm (NoiseCipher::AesGcm):
- AES-256-GCM authenticated encryption
- Optimal on processors with AES-NI hardware acceleration
- Required for NIST/FedRAMP compliance
The cipher selection is read from config and passed to the Noise
protocol builder at IPC bus initialization. The NoiseCipher enum is
defined in core-types/src/crypto.rs:31-37.
Noise Hash: IPC Transport Hash
The Noise protocol hash function is selected via the noise_hash
config field:
blake2s (default, NoiseHash::Blake2s):
- BLAKE2s (256-bit output, optimized for 32-bit and 64-bit platforms)
- Faster than SHA-256 on platforms without SHA extensions
- The leading-edge default
sha256 (NoiseHash::Sha256):
- SHA-256
- Required for NIST/FedRAMP compliance
- Optimal on processors with SHA-NI hardware extensions
The NoiseHash enum is defined in core-types/src/crypto.rs:43-49.
Audit Hash: Audit Log Chain Integrity
The audit log uses a hash chain where each entry’s hash covers the
previous entry’s hash, providing tamper evidence. The hash function is
selected via the audit_hash config field:
blake3 (default, AuditHash::Blake3):
- BLAKE3 (256-bit output)
- Hardware-accelerated via AVX2/AVX512/NEON where available
- The leading-edge default
sha256 (AuditHash::Sha256):
- SHA-256
- Required for NIST/FedRAMP compliance
The AuditHash enum is defined in core-types/src/crypto.rs:55-61.
At-Rest Encryption
Key wrapping and per-entry vault encryption use AES-256-GCM via the
EncryptionKey type (core-crypto/src/encryption.rs). This cipher is
not configurable — it is always AES-256-GCM regardless of the
[crypto] config section. The implementation uses the RustCrypto
aes-gcm crate.
- Key size: 32 bytes (AES-256)
- Nonce size: 12 bytes (
NONCE_LEN) - Output: ciphertext with appended 16-byte authentication tag
(
TAG_LEN) - Decrypted plaintext is returned as
SecureBytes(mlock’d, zeroize-on-drop) - The
Debugimplementation redacts key material, printing"EncryptionKey([REDACTED])"
Nonce reuse catastrophically breaks both confidentiality and
authenticity. EncryptionKey::seal is the one random-nonce path: it
draws a fresh nonce from the OS random source (random_bytes) for every
encryption. seal_wire returns nonce || ciphertext || tag in one
buffer and open_wire decrypts it.
Pre-Defined Crypto Profiles
The minimum_peer_profile config field selects a pre-defined algorithm
profile via the CryptoProfile enum
(core-types/src/crypto.rs:67-75):
leading-edge (default, CryptoProfile::LeadingEdge):
| Axis | Algorithm |
|---|---|
| KDF | Argon2id (19 MiB, 2 iterations) |
| HKDF | BLAKE3 |
| Noise cipher | ChaCha20-Poly1305 |
| Noise hash | BLAKE2s |
| Audit hash | BLAKE3 |
This profile uses modern algorithms that prioritize security margin and performance on commodity hardware without requiring specific hardware acceleration.
governance-compatible (CryptoProfile::GovernanceCompatible):
| Axis | Algorithm |
|---|---|
| KDF | PBKDF2-SHA256 (600K iterations) |
| HKDF | HKDF-SHA256 |
| Noise cipher | AES-256-GCM |
| Noise hash | SHA-256 |
| Audit hash | SHA-256 |
This profile uses exclusively NIST-approved algorithms suitable for environments subject to FedRAMP, FIPS 140-3, or equivalent governance frameworks.
custom (CryptoProfile::Custom):
Individual algorithm selection via the per-axis config fields. Allows mixing algorithms across profiles (e.g., Argon2id KDF with AES-GCM Noise cipher).
The minimum_peer_profile field names the minimum cryptographic
profile a node is to accept from federation peers. It is parsed and
validated into CryptoConfig::minimum_peer_profile: CryptoProfile
(core-types/src/crypto.rs), but nothing reads it yet: federation is
not implemented, so no peer connection is checked against it.
Config-to-Runtime Dispatch
Algorithm selection flows from config to runtime through a three-stage pipeline:
-
TOML parsing: The
[crypto]section is deserialized intoCryptoConfigToml(core-config/src/schema_crypto.rs:14), which stores all algorithm names asStringvalues. -
Validation:
CryptoConfigToml::to_typed()(schema_crypto.rs:48) converts each string to a typed enum variant viamatchstatements. Unrecognized strings produce an error. The result is acore_types::CryptoConfigstruct with typed fields (core-types/src/crypto.rs:82-90). -
Dispatch: one function per axis takes the typed enum and matches on it.
derive_password_key(algorithm, password, salt)(core-crypto/src/kdf.rs) matches onKdfAlgorithm, and every key derived from key material goes through the onematchonHkdfAlgorithmincore-crypto/src/derive.rs:#![allow(unused)] fn main() { fn derive(algorithm: HkdfAlgorithm, context: &KeyContext<'_>, ikm: &[u8]) -> Zeroizing<[u8; 32]> { let context = context.string(); match algorithm { HkdfAlgorithm::Blake3 => Zeroizing::new(blake3::derive_key(&context, ikm)), HkdfAlgorithm::HkdfSha256 => { let mut key = Zeroizing::new([0u8; 32]); hkdf::Hkdf::<sha2::Sha256>::new(None, ikm) .expand(context.as_bytes(), &mut *key) .expect("32 bytes is within the HKDF-SHA256 output limit of 8160"); key } } } }
Adding a new algorithm therefore requires three changes: a variant in the
core_types enum, a match arm in the TOML validator, and a match
arm in the dispatch function. No call sites need modification.
FIPS Considerations
Open Sesame does not claim FIPS 140-3 validation. The cryptographic
implementations are provided by RustCrypto crates (argon2, pbkdf2,
aes-gcm, blake3, hkdf, sha2) which have not undergone CMVP
certification.
For deployments subject to FIPS requirements, the
governance-compatible profile restricts algorithm selection to
NIST-approved primitives (PBKDF2-SHA256, HKDF-SHA256, AES-256-GCM,
SHA-256). This satisfies the algorithm selection requirement but does
not address the validated module requirement. Organizations requiring a
FIPS-validated cryptographic module would need to replace the RustCrypto
backends with a certified implementation (e.g., AWS-LC, BoringCrypto)
and re-validate.
minimum_peer_profile is the intended enforcement point for peers:
set to "governance-compatible", it is to refuse a federation session
using non-NIST algorithms. It enforces nothing until federation
exists; today the local [crypto] axes are the whole policy.
Memory Protection
Key material derived through derive_key is returned as SecureBytes
(core-crypto/src/secure_bytes.rs), and decrypted plaintext likewise;
SecureBytes is backed by core_memory::ProtectedAlloc. This provides:
- Page-aligned allocation with guard pages
mlockto prevent swapping to disk- Volatile zeroization on drop
- Canary bytes for buffer overflow detection
The core_types::init_secure_memory() function (core-types/src/lib.rs) must be
called before the seccomp sandbox is applied, because it probes
memfd_secret availability. After seccomp is active, memfd_secret
remains in the allowlist for all sandboxed daemons.
Vault Engine
The vault engine provides encrypted per-profile secret storage backed by SQLCipher databases with a multi-layer key hierarchy derived from BLAKE3.
SQLCipher Configuration
Each vault database is a SQLCipher-encrypted SQLite file. The following PRAGMA directives are applied
in SqlCipherStore::open() (core-secrets/src/sqlcipher.rs) before any table access:
| Parameter | Value | Purpose |
|---|---|---|
cipher_page_size | 4096 | Page-level encryption granularity |
cipher_hmac_algorithm | HMAC_SHA256 | Per-page authentication |
cipher_kdf_algorithm | PBKDF2_HMAC_SHA256 | Internal SQLCipher KDF for page keys |
kdf_iter | 256000 | PBKDF2 iteration count |
journal_mode | WAL | Write-ahead logging for crash safety |
SQLCipher encrypts every database page with AES-256-CBC and authenticates each page with
HMAC-SHA256. The page encryption key is supplied via PRAGMA key as a raw 32-byte hex-encoded
value. After the key pragma executes, both the hex string and the SQL statement are zeroized in
place via zeroize::Zeroize before any further operations proceed.
Key Hierarchy
The key derivation chain from user password to on-disk encryption proceeds through three stages:
User password + per-profile 16-byte random salt
--> Argon2id
--> Master Key (32 bytes, held in SecureBytes / mlock'd memory)
--> BLAKE3 derive_key(context="pds v2 vault-key {profile_id}")
--> Vault Key (32 bytes) -- used as SQLCipher PRAGMA key
--> BLAKE3 derive_key(context="pds v2 entry-encryption-key")
--> Entry Key (32 bytes) -- used for per-entry AES-256-GCM
BLAKE3’s derive_key mode accepts a context string that provides domain separation. The vault
key and entry key share the same vault key as input keying material but use different context
strings, making them cryptographically independent. The vault_key_derivation_domain_separation
test in core-secrets/src/sqlcipher.rs verifies this property.
The full set of derived keys sharing the same master key (defined in core-crypto/src/hkdf.rs):
| Context | Purpose |
|---|---|
pds v2 vault-key {profile_id} | SQLCipher page encryption |
pds v2 entry-encryption-key | Per-entry AES-256-GCM (derived from vault key, not master key) |
pds v2 clipboard-key {profile_id} | Clipboard encryption |
pds v2 ipc-auth-token {profile_id} | IPC authentication |
pds v2 ipc-encryption-key {profile_id} | Per-field IPC encryption (feature-gated) |
pds v2 key-encrypting-key | KEK for platform keyring storage |
An HKDF-SHA256 alternative is available via derive_vault_key_with_algorithm(), selectable per
the HkdfAlgorithm enum. BLAKE3 is the default. The
blake3_and_hkdf_sha256_produce_different_keys test confirms the two algorithms produce
different outputs for the same inputs.
Double Encryption
Each secret value receives two independent layers of encryption:
- Page-level: SQLCipher encrypts the entire database page (key names, values, metadata) using the vault key via AES-256-CBC + HMAC-SHA256.
- Entry-level: Each value is individually encrypted with AES-256-GCM using the entry key
before being written to the
valuecolumn. The wire format stored in the database is[12-byte random nonce][ciphertext + 16-byte GCM tag].
Every encryption operation generates a fresh 12-byte random nonce via getrandom. The minimum
wire length for decryption is 28 bytes (12-byte nonce + 16-byte GCM tag); shorter values are
rejected with an error. The encrypt_same_value_produces_different_ciphertext test verifies
nonce uniqueness across 100 consecutive encryptions of identical plaintext.
The db_file_contains_no_plaintext and db_file_contains_no_key_names_in_plaintext tests read
raw database file bytes and assert that neither secret values nor key names appear anywhere in
the on-disk file.
Database Schema
The schema is created via an idempotent CREATE TABLE IF NOT EXISTS statement during
SqlCipherStore::open():
CREATE TABLE IF NOT EXISTS secrets (
key TEXT PRIMARY KEY,
value BLOB NOT NULL,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
Timestamps are stored as Unix epoch seconds via SystemTime::now(). The
schema_migration_idempotent test verifies that opening a database multiple times does not fail
or corrupt existing data. After schema creation, SqlCipherStore::open() executes
SELECT count(*) FROM sqlite_master to verify the key is correct; a wrong key causes this
statement to fail with “wrong key or corrupt database”.
Per-Profile Vault Isolation
Each profile receives a separate database file at {config_dir}/vaults/{profile_name}.db and a
separate 16-byte random salt file at {config_dir}/vaults/{profile_name}.salt. The salt is
generated by getrandom on first unlock and persisted to disk by generate_profile_salt() in
daemon-secrets/src/unlock.rs.
Isolation is cryptographic, not namespace-based.
core_crypto::derive_vault_key(master_key, profile_id) uses the context string
"pds v2 vault-key {profile_id}", producing a different 32-byte key for each profile ID even
when the master key is the same. Attempting to open a vault encrypted with profile A’s key using
profile B’s key fails at the SELECT count(*) FROM sqlite_master verification step.
Tests in core-secrets/src/sqlcipher.rs that verify isolation:
cross_profile_keys_are_independent– different profile IDs yield different keys, and opening a database with the wrong profile’s key fails.cross_profile_secret_access_returns_error– reading a key from the wrong profile’s vault returnsNotFound.different_vault_keys_cannot_access– a database opened with key A rejects key B.
Vault Lifecycle
Create
A vault is created implicitly on first access after a profile is unlocked.
VaultState::vault_for() in daemon-secrets/src/vault.rs creates the
{config_dir}/vaults/ directory if needed, then calls SqlCipherStore::open() inside
tokio::task::spawn_blocking with a 10-second timeout to avoid blocking the async event loop
during synchronous SQLCipher I/O. The timeout is a defensive measure: if the blocking thread is
killed (e.g., by seccomp SIGSYS), the JoinHandle would hang indefinitely without it. The
opened store is wrapped in JitDelivery with the configured TTL (default 300 seconds, set via
the --ttl CLI flag or PDS_SECRET_TTL environment variable).
Open
SqlCipherStore::open() performs the following steps in order:
- Validate that the vault key is exactly 32 bytes.
- Open the SQLite connection via
Connection::open(). - Set the encryption key via
PRAGMA keyin raw hex mode, then zeroize the hex string and the SQL statement. - Apply SQLCipher configuration PRAGMAs (cipher_page_size, HMAC algorithm, KDF algorithm, KDF iterations, WAL mode).
- Run the idempotent schema migration (
CREATE TABLE IF NOT EXISTS). - Verify the key by executing
SELECT count(*) FROM sqlite_master. - Derive the entry key via
blake3::derive_key("pds v2 entry-encryption-key", vault_key), then zeroize the intermediate byte array.
Rekey (C-level Key Scrub)
SqlCipherStore::pragma_rekey_clear() issues PRAGMA rekey = '' to scrub SQLCipher’s internal
C-level copy of the page encryption key from memory. This is defense-in-depth: the Rust-side
entry_key: SecureBytes already zeroizes on drop, but this call ensures the C library’s
internal buffer is also cleared. The method logs a warning on failure but does not panic, since
the connection may already be in a broken state. The
pragma_rekey_clear_does_not_remove_encryption test confirms this scrubs the in-memory key
without removing on-disk encryption.
An AtomicBool (cleared) prevents redundant PRAGMA rekey calls in the Drop
implementation.
Close
Vault closing occurs during profile deactivation (VaultState::deactivate_profile()) or
locking (handle_lock_request()). The sequence is:
- Remove the profile from the
active_profilesauthorization set. This is the security-critical step and happens first, before any I/O. - Flush the JIT cache via
vault.flush().await. AllSecureBytesentries are zeroized on drop when theHashMapis cleared. - Call
pragma_rekey_clear()to scrub the C-level key buffer. - Drop the
SqlCipherStore. Theentry_key: SecureByteszeroizes on drop, andDropskips the redundantPRAGMA rekeybecauseclearedis already set. - Remove the master key from the
master_keysmap.SecureByteszeroizes on drop. - Remove any partial multi-factor unlock state for the profile.
- On Linux, delete the profile’s platform keyring entry via
keyring_delete_profile().
On lock-all (no profile specified in LockRequest), the rate limiter state is also reset to a
fresh SecretRateLimiter instance.
Secret Lifecycle
This page describes how secrets move through the system: from storage in an encrypted vault, through a JIT cache, across the IPC bus, and into a child process’s environment. It also covers key material lifecycle and the compliance testing framework.
Secret Storage Operations
The SecretsStore trait (core-secrets/src/store.rs) defines four operations that every storage
backend must implement:
| Operation | Behavior |
|---|---|
get(key) | Retrieve a secret by key. Returns an error if the key does not exist. |
set(key, value) | Store a secret. Overwrites if the key already exists. Updates updated_at; sets created_at on first insert. |
delete(key) | Delete a secret by key. Returns an error if the key does not exist. |
list_keys() | List all key names in the store. Values are not returned (no bulk decryption). |
The list_keys method intentionally avoids returning values. Listing secrets does not trigger
bulk decryption of every entry, limiting the window during which plaintext exists in memory.
Two implementations exist:
SqlCipherStore(core-secrets/src/sqlcipher.rs): Production backend. Eachsetencrypts the value with per-entry AES-256-GCM before writing to the database. Eachgetdecrypts after reading. TheMutex<Connection>serializes all database access.InMemoryStore(core-secrets/src/store.rs): Testing backend. Holds secrets in aHashMap<String, SecureBytes>protected by atokio::sync::RwLock. Values are stored asSecureBytes(mlock’d, zeroize-on-drop). Does not persist to disk.
JIT Cache
The JitDelivery<S> wrapper (core-secrets/src/jit.rs) adds a time-limited in-memory cache in
front of any SecretsStore implementation. It exists to avoid repeated SQLCipher decryption for
frequently accessed secrets.
Resolution
JitDelivery::resolve(key) checks the cache first. If a valid (non-expired) entry exists, the
cached SecureBytes clone is returned without touching the underlying store. If the entry is
missing or expired, the value is fetched from the store, cached, and returned.
Both the cache entry and the returned value are independent SecureBytes clones. Each
independently zeroizes on drop.
TTL Expiry
Each cache entry records its fetched_at timestamp as a std::time::Instant. On the next
resolve call, if fetched_at.elapsed() >= ttl, the cached value is considered expired and a
fresh fetch occurs. The default TTL is 300 seconds, configurable via the daemon’s --ttl flag
or PDS_SECRET_TTL environment variable.
The ttl_expiry_refetches test verifies that after TTL expiry, the underlying store is
re-queried and updated values are returned.
Flush on Lock
JitDelivery::flush() clears the entire cache by calling cache.clear(). Because each value
in the cache is a SecureBytes, dropping the HashMap entries triggers zeroization of all
cached secret material. Flush is called during profile deactivation and locking, before the
vault is closed and key material is destroyed.
The flush_clears_cache test verifies that after a flush, the next resolve call fetches
fresh data from the underlying store.
Store Bypass
JitDelivery::store() provides direct access to the underlying SecretsStore, bypassing the
cache. This is used for write operations (set, delete, list_keys) which should not
interact with the read cache. After a set or delete, the daemon calls
vault.flush().await to invalidate any stale cache entries.
Key Material Lifecycle
All key material in the secrets subsystem is held in SecureBytes (core-crypto), which
provides:
- mlock: The backing memory is locked to prevent swapping to disk. On Linux, this uses
memfd_secretwith guard pages when available. - Zeroize on drop: When a
SecureBytesvalue is dropped, its backing memory is overwritten with zeros before deallocation. This is implemented via thezeroizecrate’sZeroizetrait. - Clone independence: Cloning a
SecureBytesvalue creates a new mlock’d allocation. Dropping the clone does not affect the original, and vice versa.
The lifecycle of key material through the system:
- Derivation: The master key is derived via Argon2id from the user’s password and a
per-profile 16-byte salt (
derive_master_key()indaemon-secrets/src/unlock.rs, which delegates tocore_crypto::derive_key_argon2()). The result is a 32-byteSecureBytesvalue. - Storage: The master key is stored in
VaultState::master_keys(daemon-secrets/src/vault.rs), aHashMap<TrustProfileName, SecureBytes>. - Derivation (vault key): On first vault access,
core_crypto::derive_vault_key()derives a 32-byte vault key from the master key via BLAKE3. The intermediate stack array is wrapped inzeroize::Zeroizingand zeroized on scope exit. - Use: The vault key is passed to
SqlCipherStore::open(), which uses it forPRAGMA keyand derives the entry key. The vault key is not retained by the store after open completes. - Destruction: On lock or deactivation, the JIT cache is flushed (zeroizing cached
secrets),
pragma_rekey_clear()scrubs the C-level key buffer, theSqlCipherStoreis dropped (zeroizing the entry key), and the master key is removed from the map (zeroizing on drop).
Field-Level IPC Encryption
When the ipc-field-encryption feature is enabled, secret values are encrypted with AES-256-GCM
before being placed on the IPC bus, providing a second encryption layer on top of the Noise IK
transport.
The per-profile IPC encryption key is derived via
core_crypto::derive_ipc_encryption_key(master_key, profile_id) using the context string
"pds v2 ipc-encryption-key {profile_id}". The wire format is
[12-byte random nonce][AES-256-GCM ciphertext + tag].
This feature is gated behind ipc-field-encryption and disabled by default for the following
reasons, documented in daemon-secrets/src/vault.rs:
- The Noise IK transport is already the security boundary, matching the precedent set by ssh-agent, 1Password, Vault, and gpg-agent.
- CLI clients lack the master key needed to decrypt per-field encrypted values.
- The per-field key derives from the same master key that transits inside the Noise channel, so it is not an independent trust root.
When enabled, the encryption path in handle_secret_get (daemon-secrets/src/crud.rs) encrypts
values before sending the SecretGetResponse, and the decryption path in handle_secret_set
decrypts incoming values before writing to the vault. The decrypted intermediate Vec<u8> is
explicitly zeroized after the store write completes.
Compliance Testing
The compliance_tests() function (core-secrets/src/compliance.rs) defines a portable test
suite that every SecretsStore implementation must pass. The suite verifies:
| Test case | Assertion |
|---|---|
| Set and get | A stored value is retrievable with identical bytes. |
| Overwrite | Storing to an existing key replaces the value. |
| Get nonexistent | Retrieving a key that does not exist returns an error. |
| Delete | A deleted key is no longer retrievable. |
| Delete nonexistent | Deleting a key that does not exist returns an error. |
| List keys | All stored key names appear in the list. |
| Cleanup | After deleting all keys, the list is empty. |
The in_memory_store_passes_compliance test runs this suite against InMemoryStore. The
SQLCipher backend has its own compliance tests in core-secrets/src/sqlcipher.rs that
additionally verify encryption properties (no plaintext on disk, cross-profile isolation, nonce
uniqueness).
Six-Gate Security Pipeline
Every secret CRUD operation passes through a six-gate security pipeline in
daemon-secrets/src/crud.rs before the vault is accessed. The gates execute in order from
cheapest to most expensive:
- Lock check: Rejects the request if no profiles are unlocked (
master_keysis empty). - Active profile check: Rejects if the requested profile is not in the
active_profilesset. - Identity check: Logs the requester’s
verified_sender_name(stamped by the IPC bus server from the Noise IK registry). Expected requesters aredaemon-secrets,daemon-launcher, orNone(CLI relay). - Rate limit check: Applies per-requester token bucket rate limiting.
- ACL check: Evaluates per-daemon per-key access control rules from config.
5.5. Key validation: Validates the secret key name via
core_types::validate_secret_key(). - Vault access: Opens (or retrieves) the vault and performs the requested operation.
Each gate that denies a request emits both a structured tracing log entry and a
SecretOperationAudit IPC event (fire-and-forget to daemon-profile for persistent audit
logging). The denial response is sent immediately and processing stops.
Access Control
The secrets daemon enforces per-daemon per-key access control over secret operations. ACL rules are defined in the configuration file and evaluated as pure functions over config state with no I/O or mutable state. Rate limiting provides a second layer of defense against enumeration attacks.
Per-Daemon Per-Key ACL
Access control is implemented in daemon-secrets/src/acl.rs as two pure functions:
check_secret_access() for get/set/delete operations, and check_secret_list_access() for
list operations.
Configuration
ACL rules are defined in the config file under [profiles.<name>.secrets.access]. Each entry
maps a daemon name to a list of secret key names that daemon is permitted to access:
[profiles.work.secrets.access]
daemon-launcher = ["api-key", "db-password"]
daemon-wm = []
In this example, daemon-launcher can access api-key and db-password in the work
profile. daemon-wm has an explicit empty list, which denies all access including listing.
Evaluation Rules for Get/Set/Delete
The check_secret_access() function evaluates the following rules in order. The first matching
rule determines the outcome:
| Condition | Result | Rationale |
|---|---|---|
| Profile not in config, no ACL policy on any profile | Allow | Backward compatibility with pre-ACL deployments. |
| Profile not in config, ACL policy exists on any other profile | Deny | Fail-closed. An attacker must not bypass ACL by requesting a nonexistent profile. |
| Profile in config, empty access map | Allow | No ACL policy configured for this profile. |
Unregistered client (verified_sender_name is None), ACL policy exists | Deny | Unregistered clients cannot be identity-verified. |
| Daemon name absent from access map | Allow | Backward compatible default. Only daemons explicitly listed are restricted. |
| Daemon name present, key in allowed list | Allow | Explicit grant. |
| Daemon name present, key not in allowed list | Deny | Allowlist is strict. |
| Daemon name present, empty allowed list | Deny | Explicit deny-all. Empty list means no access, not unrestricted access. |
Evaluation Rules for List
The check_secret_list_access() function follows the same rules as get/set/delete with one
difference at the daemon-level check:
| Condition | Result |
|---|---|
| Daemon name present, non-empty allowed list | Allow (has at least some access) |
| Daemon name present, empty allowed list | Deny (“no keys allowed” means “cannot even see what keys exist”) |
All other conditions match check_secret_access().
Test Coverage
The ACL module contains 15 tests (acl_001 through acl_015) that verify every branch of
both functions. Each test is prefixed with a SECURITY INVARIANT comment documenting the
property it protects.
Unregistered Client Handling
Client identity is determined by the verified_sender_name field on each IPC message. This
field is stamped by the IPC bus server from the Noise IK static key registry – it is not
self-declared by the client. The check_secret_requester() function in
daemon-secrets/src/acl.rs logs an anomaly warning if a daemon other than daemon-secrets or
daemon-launcher requests secrets, since those are the only expected requesters.
Unregistered clients (those with verified_sender_name set to None) are CLI relay connections
that transit through daemon-profile with Open clearance. When any ACL policy is active,
unregistered clients are denied access to both individual secrets and the key listing. This
prevents bypass via unauthenticated connections.
Audit Logging
Every secret operation emits a structured audit log entry via the audit_secret_access()
function, regardless of whether the operation succeeds or is denied. The log entry includes:
event_type: The operation (get,set,delete,list,unlock,lock).requester: TheDaemonId(UUID) of the requesting client.profile: The target trust profile name.key: The secret key name (or-for operations that do not target a specific key).outcome: The result (success,denied-locked,denied-acl,rate-limited,not-found, etc.).
In addition to local tracing logs, each operation also emits a SecretOperationAudit IPC
event that is published to the bus for persistent logging by daemon-profile. This event is
fire-and-forget: delivery failure does not block or fail the secret operation. Both audit paths
are required; the code comments explicitly state that neither should be removed assuming the
other is sufficient.
Rate Limiting
Rate limiting is implemented in daemon-secrets/src/rate_limit.rs using the governor crate’s
in-memory GCRA (Generic Cell Rate Algorithm) token bucket.
Configuration
The rate limiter is configured with a fixed quota:
- Sustained rate: 10 requests per second
- Burst capacity: 20 requests
These values are hardcoded in SecretRateLimiter::new().
Per-Daemon Buckets
Each daemon receives an independent rate limit bucket, keyed on its verified_sender_name.
Exhausting one daemon’s quota does not affect any other daemon’s ability to access secrets.
Buckets are created lazily on first request from each daemon.
Anonymous Client Isolation
All unregistered clients (those with verified_sender_name set to None) share a single rate
limit bucket keyed on the sentinel value __anonymous__. This prevents bypass via the
new-connection-per-request pattern: an attacker who opens a fresh IPC connection for every
request still draws from the same shared anonymous bucket.
The anonymous bucket is independent from all named daemon buckets. Exhausting the anonymous bucket does not affect registered daemons, and vice versa.
Rate Limiter Reset
When a lock-all operation succeeds (no profile specified in LockRequest), the rate limiter is
reset to a fresh instance with empty buckets. This occurs in handle_lock_request() in
daemon-secrets/src/unlock.rs.
Test Coverage
The rate limiting module contains five tests (rate_001 through rate_005) that verify:
- Burst capacity of 20 requests is allowed (
rate_001). - The 21st request after burst exhaustion is denied (
rate_002). - Daemon buckets are independent (
rate_003). - The anonymous bucket is independent from named daemon buckets (
rate_004). - All anonymous clients share a single bucket (
rate_005).
Secret Injection
The sesame CLI provides two commands for injecting vault secrets into running processes:
sesame env for spawning a child process with secrets as environment variables, and
sesame export for emitting secrets in shell, dotenv, or JSON format. Both commands enforce a
runtime denylist that blocks security-sensitive environment variable names.
sesame env
sesame env spawns a child process with all secrets from the specified profile(s) injected as
environment variables.
sesame env -p work -- my-application --flag
The command resolves profile specs from the -p flag or, if omitted, from the
SESAME_PROFILES environment variable. If neither is set, the default profile name is used.
The child process also receives a SESAME_PROFILES environment variable containing a CSV of
the resolved profile specs (e.g., work,braincraft:operations), allowing it to know its
security context.
After the child process exits, all secret byte vectors are zeroized via zeroize::Zeroize
before the parent process exits with the child’s exit code.
Multi-Profile Support
Multiple profiles can be specified as a comma-separated list:
sesame env -p "default,work" -- my-application
Secrets are fetched from each profile in order and merged with left-wins collision resolution:
if the same secret key name exists in multiple profiles, the value from the first profile in
the list is used. This is implemented in fetch_multi_profile_secrets() in
open-sesame/src/ipc.rs, which uses a HashSet to track seen key names.
Prefix
The --prefix flag prepends a string to all generated environment variable names:
sesame env -p work --prefix MYAPP -- my-application
# Secret "api-key" becomes MYAPP_API_KEY
sesame export
sesame export emits secrets in one of three formats, suitable for shell evaluation or file
generation.
Shell Format
sesame export -p work --format shell
Output:
export API_KEY="the-secret-value"
export DB_PASSWORD="another-value"
Dotenv Format
sesame export -p work --format dotenv
Output:
API_KEY="the-secret-value"
DB_PASSWORD="another-value"
JSON Format
sesame export -p work --format json
Output:
{"API_KEY":"the-secret-value","DB_PASSWORD":"another-value"}
After output, all intermediate string copies are zeroized via unsafe
as_bytes_mut().zeroize().
Secret Name to Environment Variable Conversion
The secret_key_to_env_var() function in open-sesame/src/env.rs converts secret key names
to environment variable names using the following rules:
| Input character | Output |
|---|---|
Hyphen (-) | Underscore (_) |
Dot (.) | Underscore (_) |
| ASCII alphanumeric | Uppercased |
Underscore (_) | Preserved |
| All other characters | Underscore (_) |
The entire result is uppercased. If a prefix is provided, it is prepended with an underscore separator.
Examples (from tests in open-sesame/src/env.rs):
| Secret key | Prefix | Environment variable |
|---|---|---|
api-key | None | API_KEY |
api-key | MYAPP | MYAPP_API_KEY |
db.host-name | None | DB_HOST_NAME |
Environment Variable Denylist
The DENIED_ENV_VARS constant in open-sesame/src/env.rs defines environment variable names
that must never be overwritten by secret injection. The is_denied_env_var() function checks
against this list using case-insensitive comparison. The BASH_FUNC_ prefix is matched as a
prefix (any variable starting with BASH_FUNC_ is denied).
If a secret’s converted name matches a denied variable, the secret is skipped with a warning printed to stderr. It is not injected into the child process or emitted in export output.
Full Denylist
Dynamic linker – arbitrary code execution:
LD_PRELOADLD_LIBRARY_PATHLD_AUDITLD_DEBUGLD_DEBUG_OUTPUTLD_DYNAMIC_WEAKLD_PROFILELD_SHOW_AUXVLD_BIND_NOWLD_BIND_NOTDYLD_INSERT_LIBRARIESDYLD_LIBRARY_PATHDYLD_FRAMEWORK_PATH
Core execution environment:
PATHHOMEUSERSHELLLOGNAMELANGTERMDISPLAYWAYLAND_DISPLAYXDG_RUNTIME_DIR
Shell injection vectors:
BASH_ENVENVBASH_FUNC_(prefix match)CDPATHGLOBIGNORESHELLOPTSBASHOPTSPROMPT_COMMANDPS1,PS2,PS4MAIL,MAILPATH,MAILCHECKIFS
Language runtime code execution:
PYTHONPATH,PYTHONSTARTUP,PYTHONHOMENODE_OPTIONS,NODE_PATH,NODE_EXTRA_CA_CERTSPERL5LIB,PERL5OPTRUBYLIB,RUBYOPTGOPATH,GOROOT,GOFLAGSJAVA_HOME,CLASSPATH,JAVA_TOOL_OPTIONS
Security and authentication:
SSH_AUTH_SOCKGPG_AGENT_INFOKRB5_CONFIG,KRB5CCNAMESSL_CERT_FILE,SSL_CERT_DIRCURL_CA_BUNDLE,REQUESTS_CA_BUNDLEGIT_SSL_CAINFONIX_SSL_CERT_FILE
Nix:
NIX_PATHNIX_CONF_DIR
Sudo and privilege escalation:
SUDO_ASKPASSSUDO_EDITORVISUALEDITOR
Systemd and D-Bus:
SYSTEMD_UNIT_PATHDBUS_SESSION_BUS_ADDRESS
Open Sesame namespace:
SESAME_PROFILE
Shell Escaping
The shell_escape() function in open-sesame/src/env.rs produces output safe for embedding
in double-quoted export statements. The following transformations are applied:
| Character | Output | Reason |
|---|---|---|
\0 (null) | Stripped | C string truncation risk |
" | \" | Shell metacharacter |
\ | \\ | Shell metacharacter |
$ | \$ | Variable expansion |
` | \` | Command substitution |
! | \! | History expansion |
\n | \n (literal backslash-n) | Newline |
\r | \r (literal backslash-r) | Carriage return |
JSON Escaping
The json_escape() function produces output safe for embedding in JSON string values:
| Character | Output |
|---|---|
\0 (null) | Stripped |
" | \" |
\ | \\ |
\n | \n |
\r | \r |
\t | \t |
| Other control characters | \uXXXX (Unicode escape) |
Cross-Profile Behavior
Open Sesame enforces strict per-profile isolation for secret storage while providing controlled mechanisms for accessing secrets from multiple profiles in a single session.
Profile Isolation Guarantees
Each trust profile is a cryptographically independent security domain. The following properties hold:
Independent Master Keys
Each profile has its own password, its own 16-byte random salt (stored at
{config_dir}/vaults/{profile}.salt), and its own Argon2id-derived master key. Knowing the
password for profile A reveals nothing about the master key for profile B, even if the user
chooses the same password for both, because the salts differ.
Independent Vault Keys
The vault key for each profile is derived via
core_crypto::derive_vault_key(master_key, profile_id) using the BLAKE3 context string
"pds v2 vault-key {profile_id}". Different profile IDs produce different vault keys even
from the same master key. The different_profiles_produce_different_keys test in
core-crypto/src/hkdf.rs verifies this property.
Independent Database Files
Each profile’s secrets are stored in a separate SQLCipher database file at
{config_dir}/vaults/{profile_name}.db. There is no shared database. Opening profile A’s
database file with profile B’s vault key fails at the
SELECT count(*) FROM sqlite_master verification step in SqlCipherStore::open().
Independent Unlock State
Each profile is unlocked independently via UnlockRequest with an optional profile field.
The VaultState struct in daemon-secrets/src/vault.rs maintains per-profile state in
several maps:
master_keys: HashMap<TrustProfileName, SecureBytes>– per-profile master keys.vaults: HashMap<TrustProfileName, JitDelivery<SqlCipherStore>>– per-profile open vault handles.active_profiles: HashSet<TrustProfileName>– profiles authorized for secret access.partial_unlocks: HashMap<TrustProfileName, PartialUnlock>– in-progress multi-factor unlock sessions.
Multiple profiles may be unlocked and active concurrently. There is no global “locked” state; the daemon starts with empty maps and each profile is unlocked individually.
Independent Deactivation
Locking a single profile (LockRequest with a profile field) removes only that profile’s
master key, vault handle, partial unlock state, and keyring entry. Other profiles remain
unlocked and accessible.
Cross-Profile Tag References
The profile spec format used by sesame env and sesame export supports an org:vault
syntax for referencing profiles with organizational namespaces:
default --> ProfileSpec { org: None, vault: "default" }
braincraft:operations --> ProfileSpec { org: Some("braincraft"), vault: "operations" }
This parsing is implemented in parse_profile_specs() in open-sesame/src/ipc.rs. The org
field is currently informational – it is included in the SESAME_PROFILES CSV injected into
child processes but does not affect vault lookup. The vault field is used as the
TrustProfileName for IPC requests.
The format is designed for future extension to container registry-style references
(e.g., docker.io/project/org:vault@sha256).
Multi-Profile Secret Injection
The sesame env and sesame export commands accept a comma-separated list of profile specs:
sesame env -p "default,work" -- my-application
sesame export -p "default,work,braincraft:operations" --format json
The profile list can also be set via the SESAME_PROFILES environment variable, which is
checked when the -p flag is omitted. Resolution order is implemented in
resolve_profile_specs() in open-sesame/src/ipc.rs:
- If
-pis provided, use it. - Otherwise, read
SESAME_PROFILESfrom the environment. - If neither is set, use the default profile name.
Merge Behavior
fetch_multi_profile_secrets() iterates over the profile specs in order. For each profile, it
fetches all secret keys via SecretList, then fetches each value via SecretGet. Keys are
merged into the result with left-wins collision resolution: the first profile in the list that
contains a given key wins. A HashSet<String> tracks which key names have already been seen.
If a profile has no secrets, a warning is printed to stderr but processing continues with the remaining profiles.
Denylist Enforcement
After the secret key name is converted to an environment variable name (via
secret_key_to_env_var()), the result is checked against the denylist
(is_denied_env_var()). Denied variables are skipped with a warning on stderr. This check
applies identically regardless of which profile the secret originated from.
What Crosses Profile Boundaries
| Resource | Crosses boundaries? | Mechanism |
|---|---|---|
| Secret values | No | Each profile’s vault is encrypted with a unique key. |
| Secret key names | No | Key names are only visible within a single profile’s SecretList response. |
| Master keys | No | Each profile has an independent master key derived from its own salt. |
| Environment variables | Yes, at injection time | sesame env -p "a,b" merges secrets from both profiles into a single child process environment. |
| Vault database files | No | Each profile has its own .db file. |
| Salt files | No | Each profile has its own .salt file. |
| JIT cache entries | No | JitDelivery instances are per-profile in the vaults map. |
| Rate limit buckets | No (per-daemon, not per-profile) | Rate limiting is keyed on daemon identity, not profile. |
| ACL rules | No | ACL rules are defined per-profile under [profiles.<name>.secrets.access]. |
| Platform keyring entries | No | Keyring operations are per-profile (keyring_store_profile, keyring_delete_profile). |
The only mechanism by which secrets from different profiles can coexist in the same memory
space is the sesame env / sesame export multi-profile merge, which operates in the CLI
process after secrets have been fetched via IPC from independently unlocked vaults.
Multi-Profile Unlock
Each profile must be unlocked independently before its secrets can be accessed. The
sesame unlock command accepts a -p flag:
sesame unlock -p default
sesame unlock -p work
There is no batch unlock command that accepts multiple profiles in a single invocation. Each
UnlockRequest IPC message targets a single profile. If a profile is already unlocked, the
daemon rejects the request with UnlockRejectedReason::AlreadyUnlocked.
Locking supports both single-profile and all-profile modes:
sesame lock -p work # Lock only the "work" profile
sesame lock # Lock all profiles
Lock-all removes all master keys, flushes all JIT caches, scrubs all C-level key buffers, deletes all keyring entries, clears all partial unlock state, and resets the rate limiter.
Factor Architecture
This page describes the pluggable authentication backend system in core-auth: one
VaultAuthBackend per factor, registered in AuthDispatcher, and the unlock loop every client
runs over the factors a vault still requires.
AuthFactorId
The AuthFactorId enum in core-types/src/auth.rs identifies each authentication factor type.
Seven variants exist:
| Variant | Config string | Status |
|---|---|---|
Password | password | Implemented |
SshAgent | ssh-agent | Implemented |
PlatformKeyring | platform-keyring | Implemented on Linux (Platform Keyring) |
Fido2 | fido2 | Defined, no backend |
Tpm | tpm | Defined, no backend |
Fingerprint | fingerprint | Defined, no backend |
Yubikey | yubikey | Defined, no backend |
The enum derives Serialize, Deserialize, Copy, Hash, Ord, and uses
#[serde(rename_all = "kebab-case")]. A vault’s auth policy may name a factor without a
backend; unlocking such a vault fails, naming the factor.
AuthFactorId::from_config_str() parses the config-file string form.
AuthFactorId::as_config_str() returns the static string. The Display implementation
delegates to as_config_str().
VaultAuthBackend Trait
Defined in core-auth/src/backend.rs, the VaultAuthBackend trait is the extension point for
adding new authentication methods. It requires Send + Sync and uses #[async_trait].
Required Methods
| Method | Signature | Purpose |
|---|---|---|
factor_id | fn(&self) -> AuthFactorId | Which factor this backend provides |
name | fn(&self) -> &'static str | Human-readable name for audit logs and overlay display |
backend_id | fn(&self) -> &'static str | Short identifier for IPC messages and config |
is_enrolled | fn(&self, profile, layout) -> Result<bool, AuthError> | Whether the enrollment file exists |
can_unlock | async fn(&self, profile, layout) -> Result<bool, AuthError> | Enrolled, and the external dependency (agent, entered password) present; must complete in under 100 ms |
requires_interaction | fn(&self) -> AuthInteraction | What kind of user interaction is needed |
unlock | async fn(&self, profile, layout, keying) -> Result<UnlockOutcome, AuthError> | Derive the KEK and unwrap the master key |
enroll | async fn(&self, profile, master_key, layout, keying, credential) -> Result<(), AuthError> | Wrap the master key and write the enrollment file |
revoke | async fn(&self, profile, layout) -> Result<(), AuthError> | Zero-fill and remove the enrollment file; absence is not an error |
layout is the core_layout::Layout every vault file path derives from. keying is the
vault’s VaultKeying: its salt and the algorithms its keys derive under
(VaultMetadata::load_keying). enroll takes credential: Option<&str> naming which of the
backend’s credentials to enroll: for the SSH agent, the key fingerprint, with or without the
SHA256: prefix. A backend with one credential (the password) ignores it.
AuthInteraction
The AuthInteraction enum is what a client acts on for each factor a vault requires:
None– The backend unlocks without the user (an SSH agent holding a software key, the platform keyring): the client submits it at once.PasswordEntry– Keyboard input: the client asks for the password.HardwareTouch– Physical touch on a hardware token (FIDO2, PIV with a touch policy). No backend declares it yet; the CLI and the overlay report such a factor as unsupported.
FactorContribution
The FactorContribution enum describes what a backend provides to the unlock process:
CompleteMasterKey– The backend independently unwraps a complete 32-byte master key. Used inAnyandPolicymodes.FactorPiece– The backend provides a piece combined with the other factors’ pieces bycombine_factor_pieces(the vault’shkdfderivation,KeyContext::CombinedMasterKey, over the pieces concatenated inAuthFactorIdorder). Used inAllmode. Vault creation and unlock both derive the combined key with that one function.
VaultMetadata::contribution_type() returns FactorPiece when auth_policy is All, and
CompleteMasterKey for Any and Policy.
UnlockOutcome
The UnlockOutcome struct is returned by a successful unlock() call:
master_key: SecureBytes– The 32-byte master key (mlock’d, zeroize-on-drop).audit_metadata: BTreeMap<String, String>– Backend-specific metadata for audit logging (e.g.,ssh_fingerprint,key_type).factor_id: AuthFactorId– Which factor this outcome represents.
UnlockOutcome::into_factor_submit(profile) turns the outcome into the one unlock message,
FactorSubmit { factor_id, key_material, profile, audit_metadata }; the master key moves into the
message’s protected allocation without a heap copy. Every backend unlocks the same way: the
backend obtains its KEK and unwraps the master key client-side (the password backend with the
vault’s password KDF, the SSH agent backend from a deterministic signature, the platform
keyring backend from the operating system’s credential store), and daemon-secrets receives
the key material as one factor of the vault’s auth policy.
The password and platform keyring factors store the wrapped master key in one format,
WrappedKey (core-auth/src/wrapped_key.rs; Password
documents it). A blob that does not parse is AuthError::InvalidBlob, naming its file.
Reading daemon-secrets’ Answers
core-auth/src/progress.rs is the one reader of daemon-secrets’ unlock answers; the CLI and
the overlay both use it.
FactorProgress::from_response(response)– The answer to aFactorSubmit:Unlocked,AlreadyUnlocked(anUnlockRejected { reason: AlreadyUnlocked }),MoreRequired(the factor was accepted; the policy requires more), orRejected { reason }.FactorProgress::is_unlocked()is true for the first two.remaining_factors(response)– The factors aVaultAuthQueryResponsesays the vault still requires, in enrollment order: its enrolled factors less those a partial unlock has received. A response carrying an error isResponseError::Requirements.
Any other answer is ResponseError::Unexpected, carrying the answer’s redacted form.
AuthDispatcher
Defined in core-auth/src/dispatcher.rs, the AuthDispatcher is the registry of backends, one
per factor. AuthDispatcher::new(credential_store) registers SshAgentBackend and
PasswordBackend, and PlatformKeyringBackend over credential_store when it is Some.
The CLI passes core_daemon::credential_store(): the platform’s store, connected, or None
when the platform has no implementation or the store cannot be reached (the platform keyring
factor then has no backend, and a vault requiring it reports the factor by name). The overlay
passes None: its sandbox grants no D-Bus bus, and daemon-launcher submits the platform
keyring factor for it (Platform Keyring).
backend(factor) -> Option<&dyn VaultAuthBackend> – The backend that provides factor;
None when no registered backend implements it.
The dispatcher applies no policy: daemon-secrets owns the vault’s policy and reports which factors remain.
The Unlock Loop
The CLI (unlock_profile in open-sesame/src/unlock.rs) and the overlay (Runtime::resolve
in daemon-wm/src/commands_unlock.rs) unlock a vault the same way:
- Ask daemon-secrets for the factors the vault still requires (
VaultAuthQuery,remaining_factors). - Look each one up (
AuthDispatcher::backend). A factor without a backend fails the unlock, naming it. - Submit every factor whose backend needs no interaction and can unlock now. A factor that is
unavailable, fails, or is rejected is reported and the next one is tried. A submission that
completes the unlock ends it. In the overlay, the platform keyring factor is submitted by
daemon-launcher (
KeyringUnlockRequest). - Ask for the password when a remaining factor requires it, and submit it. If the policy requires more factors after the password, the vault’s remaining factors are read again.
VaultMetadata
Defined in core-auth/src/vault_meta.rs, VaultMetadata is the JSON-serialized record of a
vault’s authentication state, stored at <config dir>/vaults/<profile>.vault-meta
(Layout::vault_file(profile, VaultFile::Metadata)) with mode 0600.
Fields
| Field | Type | Purpose |
|---|---|---|
version | u32 | Format version (VAULT_META_VERSION, currently 2) |
enrolled_factors | Vec<EnrolledFactor> | Which auth methods are enrolled |
auth_policy | AuthCombineMode | Unlock policy for this vault |
kdf, hkdf | VaultAlgorithms (flattened) | The algorithms the vault’s keys derive under, fixed at creation |
created_at | u64 | Unix epoch seconds of vault creation |
policy_changed_at | u64 | Unix epoch seconds of last policy change |
EnrolledFactor
Each enrolled factor records:
factor_id: AuthFactorId– The factor type.label: String– Human-readable label (e.g., SSH key fingerprint, “master password”).enrolled_at: u64– Unix epoch seconds.
Version
VaultMetadata::load() reads the version first and refuses any version other than
VAULT_META_VERSION, naming the version and the reset command
(sesame init --wipe-reset-destroy-all-data). Metadata of the current version without the
algorithm fields is corrupt. Both are AuthError::InvalidVaultFile, naming the file.
Persistence
JSON is used rather than TOML to distinguish machine-managed metadata from user-editable
configuration. save() writes through core_layout::file::write with Mode::OwnerOnly, the
one writer of files PDS owns: it creates <path>.tmp with mode 0600, writes and syncs it,
renames it over the final name, and syncs the directory, so a reader never sees a partial
file and the rename survives a crash.
Construction and Keying
new(factors, auth_policy, crypto)– One enrolled factor per(AuthFactorId, label)pair, all stamped with the creation time, under the algorithmscryptoselects.AuthError::Clockwhen the system clock is before the Unix epoch, since enrollment and policy times are audit evidence.keying(salt) -> VaultKeying– The vault’s keying withsalt.load_keying(layout, profile)– The metadata and its keying, with the vault’s salt (salt::require: an absent salt isAuthError::NotInitialized).
Factor Management
has_factor(factor_id) -> bool– Check enrollment.add_factor(factor_id, label) -> Result<()>– Idempotent add (no-op if already enrolled).remove_factor(factor_id)– Remove by factor ID.contribution_type() -> FactorContribution– ReturnsFactorPieceforAllmode,CompleteMasterKeyforAny/Policy.
Enrollment and Revocation
Every factor command (sesame ssh, sesame keyring) enrolls and revokes through one
implementation, open-sesame/src/enrollment.rs.
Enrollment is a transaction:
- The vault password derives the master key (
PasswordBackend::unlock). - The factor’s backend enrolls (
enroll). - The new enrollment is proven: the backend unlocks with it, and the key it yields must be the vault’s master key.
- Only then is the factor recorded in the vault metadata (
add_factor,save).
A failure after step 2 revokes what the backend wrote, so no half-made enrollment remains; the error says whether the rollback succeeded.
Revocation removes the factor’s metadata record and its enrollment together, whichever of the two exists, so a factor left half-enrolled is repaired. A vault’s last factor is never revoked.
Adding a New Factor
To add a new authentication factor (e.g., FIDO2):
- The
AuthFactorIdvariant already exists incore-types/src/auth.rs(e.g.,Fido2). - Create a new module in
core-auth/src/implementing a struct (e.g.,Fido2Backend). - Implement
VaultAuthBackendfor the struct:factor_id()returns the correspondingAuthFactorIdvariant.is_enrolled()checks for the factor’s enrollment artifact on disk.can_unlock()checks whether the hardware or service is available.requires_interaction()returns the appropriateAuthInteractionvariant.unlock()derives the KEK under the vault’s keying and unwraps the 32-byte master key.enroll()wraps the master key under the factor’s KEK and writes an enrollment blob.revoke()destroys the enrollment file withcore_layout::file::destroy(zero-fill, then remove).
- Add a
VaultFilekind for the enrollment file incore-layout, so the path and the daemon sandboxes derive from one place. - Register the backend in
AuthDispatcher::new(). A backend over a platform service takes it as an argument the platform crate supplies, asPlatformKeyringBackendtakes theCredentialStore. - Add the factor’s command, enrolling and revoking through
open-sesame/src/enrollment.rs. - A backend that needs no interaction is submitted by the unlock loop as it is. One that needs
a touch is the
AuthInteraction::HardwareToucharm of the CLI’s and the overlay’s loops, which report it as unsupported until a client shows a touch prompt before callingunlock().
No changes to daemon-secrets are required – the FactorSubmit IPC handler and
PartialUnlock state machine operate on AuthFactorId and SecureBytes generically.
Policy Engine
This page describes the multi-factor authentication policy system. Policies are declared in configuration, persisted in vault metadata, and enforced by daemon-secrets at unlock time through a partial unlock state machine.
AuthCombineMode
Defined in core-types/src/auth.rs, the AuthCombineMode enum determines both the key wrapping
scheme at initialization and the unlock policy evaluation at runtime. It derives Serialize,
Deserialize, and uses #[serde(rename_all = "kebab-case")].
Any (default)
AuthCombineMode::Any
The master key is a random 32-byte value generated via getrandom. Each enrolled factor
independently wraps this master key under its own KEK (Argon2id-derived for password,
BLAKE3-derived for SSH). Any single enrolled factor can unlock the vault alone.
At unlock time in daemon-secrets, the first valid factor submitted completes the unlock
immediately. The PartialUnlock state machine clears all remaining requirements when Any
mode is detected:
#![allow(unused)]
fn main() {
if matches!(meta.auth_policy, AuthCombineMode::Any) {
partial.remaining_required.clear();
partial.remaining_additional = 0;
}
}
All
AuthCombineMode::All
Every enrolled factor must be provided at unlock time. Each factor contributes a “piece” (its
unwrapped key material). Once all pieces are collected, daemon-secrets combines them into the
master key via BLAKE3 derive_key:
- Factor pieces are sorted by
AuthFactorId(which derivesOrd). - The sorted pieces are concatenated.
- BLAKE3
derive_keyis called with context"pds v2 combined-master-key {profile_name}"and the concatenated bytes as input. - The result is a 32-byte master key.
The KDF context constant is ALL_MODE_KDF_CONTEXT defined in daemon-secrets/src/vault.rs
as "pds v2 combined-master-key".
The VaultMetadata::contribution_type() method returns FactorContribution::FactorPiece for
All mode. daemon-secrets checks this to decide whether to verify each factor’s key material
against the vault DB independently (it does not – verification only happens after
combination).
Policy
AuthCombineMode::Policy(AuthPolicy {
required: Vec<AuthFactorId>,
additional_required: u32,
})
A policy expression combining mandatory factors with a threshold of additional factors. Key
wrapping uses independent wraps (same as Any mode – each factor wraps the same random
master key). Policy enforcement happens at the daemon level.
required: Factors that must always succeed. Every factor in this list must be submitted.additional_required: How many additional enrolled factors (beyond those inrequired) must also succeed.
Example: required: [Password], additional_required: 1 means the password is always required,
plus one more factor (e.g., SSH agent or a future FIDO2 token).
FactorContribution is CompleteMasterKey for Policy mode – each factor independently
unwraps the same master key.
Configuration
Auth policy is configured in config.toml under [profiles.<name>.auth], defined by the
AuthConfig struct in core-config/src/schema_secrets.rs:
[profiles.default.auth]
mode = "any" # "any", "all", or "policy"
required = ["password", "ssh-agent"] # For mode="policy" only
additional_required = 1 # For mode="policy" only
AuthConfig::to_typed() converts the string-based config representation to AuthCombineMode.
It validates that all factor names in required are recognized via
AuthFactorId::from_config_str(). The default AuthConfig uses mode "any" with empty
required and additional_required = 0.
PartialUnlock State Machine
Defined in daemon-secrets/src/vault.rs, the PartialUnlock struct tracks in-progress
multi-factor unlocks. At most one PartialUnlock exists per profile, stored in
VaultState::partial_unlocks.
State
| Field | Type | Purpose |
|---|---|---|
received_factors | HashMap<AuthFactorId, SecureBytes> | Factor keys received so far |
remaining_required | HashSet<AuthFactorId> | Factors still needed |
remaining_additional | u32 | Additional factors still needed beyond required |
deadline | tokio::time::Instant | Expiration time |
Lifecycle
-
Creation: A
PartialUnlockis created on the firstFactorSubmitfor a profile. Theremaining_requiredandremaining_additionalfields are initialized from the vault’sAuthCombineMode. -
Factor acceptance: Each
FactorSubmitrecords the factor’s key material inreceived_factorsand removes the factor fromremaining_required. If the factor is not in the required set andremaining_additional > 0, the additional counter is decremented. -
Completion check:
is_complete()returnstruewhenremaining_requiredis empty ANDremaining_additional == 0. -
Promotion: When complete, the partial state is removed from the map and the master key is either taken directly (for
Any/Policymode, the first received factor’s key) or derived by combining all pieces (forAllmode). -
Expiration:
is_expired()checks whethertokio::time::Instant::now() >= deadline. Expired partials are rejected on the nextFactorSubmitand removed from the map.
Timeouts
PARTIAL_UNLOCK_TIMEOUT_SECS: 120 seconds. The deadline for collecting all required factors after the first factor is submitted.PARTIAL_UNLOCK_SWEEP_INTERVAL_SECS: 30 seconds. The interval at which daemon-secrets sweeps and discards expired partial unlock state.
Key Combination (All Mode)
When all factors have been received in All mode, daemon-secrets combines them:
#![allow(unused)]
fn main() {
let mut pieces: Vec<_> = partial.received_factors.into_iter().collect();
pieces.sort_by_key(|(id, _)| *id);
let mut combined = Vec::new();
for (_id, piece) in &pieces {
combined.extend_from_slice(piece.as_bytes());
}
let ctx_str = format!("{ALL_MODE_KDF_CONTEXT} {target}");
let derived: [u8; 32] = blake3::derive_key(&ctx_str, &combined);
combined.zeroize();
}
The sorting by AuthFactorId ensures deterministic ordering regardless of submission order.
CLI Unlock Flow
The CLI unlock command in open-sesame/src/unlock.rs orchestrates factor submission in three
phases:
Phase 1: Auto-Submit Non-Interactive Factors
The CLI iterates over all enrolled factors and calls try_auto_factor() for each. Currently,
only AuthFactorId::SshAgent is handled – it checks can_unlock() on the SshAgentBackend,
and if available, calls unlock() to derive the master key client-side and submits it via
FactorSubmit IPC.
If the vault uses Any mode and the SSH agent succeeds, the vault is fully unlocked and no
further factors are needed.
Phase 2: Query Remaining Factors
The CLI sends a VaultAuthQuery IPC message to daemon-secrets, which returns:
enrolled_factors: All enrolled factor IDs.auth_policy: The vault’sAuthCombineMode.partial_in_progress: Whether aPartialUnlockexists.received_factors: Which factors have already been accepted.
The CLI filters out already-received factors to determine what remains.
Phase 3: Prompt Interactive Factors
The CLI iterates over remaining factors:
Password: Prompts for password (viadialoguerif terminal, or reads from stdin), derives the master key client-side usingPasswordBackend::unlock(), and submits viaFactorSubmit.- Other factors: The CLI reports that the factor is not yet supported and exits with an error.
Each FactorSubmit response includes unlock_complete, remaining_factors, and
remaining_additional, allowing the CLI to track progress.
Factor Submission IPC
The submit_factor() function sends EventKind::FactorSubmit with:
factor_id: Which factor type.key_material: The master key in aSensitiveBytes(mlock’dProtectedAlloc).profile: Target profile name.audit_metadata: Backend-specific audit fields.
The daemon responds with EventKind::FactorResponse containing acceptance status, completion
status, and remaining factor information.
Daemon-Side Verification
For Any and Policy modes (CompleteMasterKey contribution), daemon-secrets verifies each
submitted factor’s key material against the vault database before accepting it. It derives the
vault key via core_crypto::derive_vault_key() and attempts to open the SQLCipher database. If
the open fails (wrong key, GCM authentication failure), the factor is rejected.
For All mode (FactorPiece contribution), individual pieces cannot be verified against the
vault database. Verification happens after all pieces are combined into the master key.
Password Backend
This page describes the password authentication backend, PasswordBackend in
core-auth/src/password.rs. It derives a key-encrypting key (KEK) from the vault password
under the vault’s password KDF, and wraps or unwraps the vault’s 32-byte master key with
AES-256-GCM in the vault’s .password-wrap file.
PasswordBackend
PasswordBackend holds an optional SecureVec with the password bytes (mlock’d,
zeroize-on-drop). The bytes are injected with with_password() before unlock() or
enroll(); without them both fail with AuthError::BackendNotApplicable.
Trait Implementation
| Method | Behavior |
|---|---|
factor_id() | AuthFactorId::Password |
name() | "Password" |
backend_id() | "password" |
is_enrolled(profile, layout) | Whether Layout::vault_file(profile, VaultFile::PasswordWrap) exists |
can_unlock(profile, layout) | Enrolled, and password bytes are set |
requires_interaction() | AuthInteraction::PasswordEntry |
KEK Derivation
The KEK is core_crypto::derive_password_key(kdf, password, salt): the vault’s password KDF
(VaultKeying::algorithms.kdf, fixed at vault creation by [crypto] kdf) over the password
and the vault’s 16-byte salt, returned as an AES-256-GCM EncryptionKey.
KdfAlgorithm::Argon2id(default): Argon2id with the parameters defined incore-crypto.KdfAlgorithm::Pbkdf2Sha256: PBKDF2-HMAC-SHA256, for deployments that require a NIST-approved KDF.
A vault’s KDF cannot change after creation: an unlock under the other KDF derives a different
KEK and fails with AuthError::UnwrapFailed.
Unlock
- Derive the KEK from the injected password under the vault’s keying
(
VaultMetadata::load_keying). - Load the wrapped master key from
.password-wrap(WrappedKey::load); an absent file isAuthError::NotEnrolled. - Unwrap it; a wrong password fails GCM authentication and is
AuthError::UnwrapFailed. - Return an
UnlockOutcomewith the master key,factor_id: Password, and audit metadata{"backend": "password"}. The caller submits it to daemon-secrets as one factor (FactorSubmit).
Enrollment
- Derive the KEK as above.
- Wrap the master key under it with a fresh random nonce (
WrappedKey::wrap). - Write the
.password-wrapfile (WrappedKey::save).
sesame init enrolls the password when it creates the vault. Other factors are enrolled from
the password: Factor Architecture
describes the transaction.
Revocation
revoke() destroys the .password-wrap file with core_layout::file::destroy: the file is
zero-filled in place, then removed. An absent file is not an error. A vault’s last factor is
never revoked: the enrollment transaction refuses it.
The Wrapped Master Key
WrappedKey (core-auth/src/wrapped_key.rs) is the on-disk format of a master key wrapped
under a factor’s KEK. The password factor stores it in .password-wrap; the platform keyring
factor stores the same format in .keyring-enrollment.
Binary Format
Offset Length Field
0 1 Version byte (WRAPPED_KEY_VERSION = 0x01)
1 12 Nonce (random, from the OS random source)
13 48 Ciphertext (32-byte master key + 16-byte GCM tag)
Total size: 61 bytes.
Errors
WrappedKey::deserialize rejects any length other than 61 bytes and any version other than
0x01 with AuthError::InvalidBlob. WrappedKey::load names the file in the error, so a
damaged enrollment is reported by its path.
Persistence
WrappedKey::save writes through core_layout::file::write with Mode::OwnerOnly: a
missing vaults/ directory is created 0700, and the file is written 0600 to
<path>.tmp, synced, and renamed into place, so a reader never sees a partial file.
Salt
Each profile has an independent 16-byte salt at <config dir>/vaults/<profile>.salt
(Layout::vault_file(profile, VaultFile::Salt)). core_auth::salt::create draws it from the
OS random source when sesame init creates the vault and writes it owner-only like the
wrapped key. salt::require reads it; an absent salt is AuthError::NotInitialized, and a
salt of any other length is AuthError::InvalidVaultFile naming the file.
The salt is the KDF salt of the password factor and the input of the SSH agent factor’s
challenge derivation (under the vault’s hkdf). A per-profile salt makes the same password
derive different KEKs for different vaults.
Key Material Handling
- Password bytes: a
SecureVec(mlock’d, zeroize-on-drop), filled by the CLI prompt or the overlay’s password field, and moved into the backend. - KEK: an
EncryptionKey; its AES key schedule is wiped on drop (aes-gcmwith thezeroizefeature). - Master key:
SecureBytesbacked byProtectedAlloc(guard pages, mlock, zeroize-on-drop), moved into theFactorSubmitmessage’sSensitiveByteswithout a heap copy (UnlockOutcome::into_factor_submit).
SSH Agent Backend
This page describes the SSH agent authentication backend implemented in core-auth/src/ssh.rs
and core-auth/src/ssh_types.rs. The backend connects to the user’s SSH agent, signs a
deterministic challenge, derives a KEK from the signature via BLAKE3, and wraps or unwraps
the vault master key using AES-256-GCM.
SshAgentBackend
The SshAgentBackend struct is a zero-sized type. All state lives in the SSH agent process
and on-disk enrollment blobs.
Trait Implementation
| Method | Behavior |
|---|---|
factor_id() | Returns AuthFactorId::SshAgent |
name() | Returns "SSH Agent" |
backend_id() | Returns "ssh-agent" |
is_enrolled(profile, config_dir) | Checks whether {config_dir}/vaults/{profile}.ssh-enrollment exists |
can_unlock(profile, config_dir) | Enrolled, blob is parseable, and the enrolled key’s fingerprint is present in the running agent |
requires_interaction() | Returns AuthInteraction::None |
The can_unlock() check connects to the SSH agent via spawn_blocking (the agent client,
core-auth/src/agent.rs, uses synchronous Unix socket I/O) and searches the agent’s identity
list for a key matching the fingerprint stored in the enrollment blob.
Challenge Construction
The challenge is a deterministic 32-byte value derived from the profile name and salt:
context = "pds v2 ssh-challenge {profile_name}"
challenge = BLAKE3::derive_key(context, salt)
The same profile name and salt always produce the same challenge. Different profiles or salts produce different challenges. This determinism is essential because the backend must produce the same challenge at both enrollment and unlock time.
Signature to KEK Derivation
The agent’s signature is accepted only when it carries the identity’s signature algorithm
(rsa-sha2-512 for RSA keys, the key’s own algorithm otherwise) and verifies against the
identity’s public key (ssh-key’s crypto features: Ed25519, RSA PKCS#1 v1.5); any other answer
is AuthError::AgentProtocolError, so an agent cannot substitute bytes of its choosing. The raw
signature bytes are then fed into a second BLAKE3 derive_key call:
context = "pds v2 ssh-vault-kek {profile_name}"
kek = BLAKE3::derive_key(context, signature_bytes)
The raw signature bytes are zeroized immediately after KEK derivation. The KEK is a 32-byte value used as an AES-256-GCM key to wrap or unwrap the master key.
This two-step derivation (challenge from salt, KEK from signature) ensures:
- The KEK is bound to both the profile identity and the specific SSH key.
- The signature is never stored – only the wrapped master key is persisted.
- The BLAKE3 derivation provides domain separation between the challenge and KEK contexts.
Supported Key Types
Defined in core-auth/src/ssh_types.rs, the SshKeyType enum restricts which SSH key types
can be used:
| Type | Wire name | Determinism |
|---|---|---|
Ed25519 | ssh-ed25519 | Deterministic by specification (RFC 8032) |
Rsa | ssh-rsa | PKCS#1 v1.5 padding uses no randomness; sign requests carry SSH_AGENT_RSA_SHA2_512 |
Excluded key types:
- ECDSA (
ecdsa-sha2-nistp256, etc.): Non-deterministic. Uses a randomkvalue per signature. A different signature on each unlock would produce a different KEK and fail to unwrap the enrollment blob. - RSA-PSS: Non-deterministic. Uses a random salt per signature.
SshKeyType::from_algorithm() converts from ssh_key::Algorithm, rejecting non-deterministic
types with AuthError::UnsupportedKeyType. SshKeyType::from_wire_name() parses the SSH wire
format string.
EnrollmentBlob
The EnrollmentBlob struct persists the SSH-agent enrollment on disk at
{config_dir}/vaults/{profile}.ssh-enrollment.
Binary Format
Offset Length Field
0 1 Version byte (0x01)
1 2 Key fingerprint length N (big-endian u16)
3 N Key fingerprint (ASCII, e.g. "SHA256:...")
3+N 1 Key type length M (u8)
4+N M Key type wire name (ASCII, e.g. "ssh-ed25519")
4+N+M 12 Nonce (random)
16+N+M 48 Ciphertext (32-byte master key + 16-byte GCM tag)
The version constant ENROLLMENT_VERSION is 0x01.
Security
- Fingerprint length is capped at 256 bytes during deserialization to prevent allocation attacks from malformed blobs.
- File permissions are set to
0o600before atomic rename. - Revocation overwrites the file with zeros before deletion.
Unlock Flow
- Read and deserialize the enrollment blob from disk.
- Derive the 32-byte challenge:
BLAKE3::derive_key("pds v2 ssh-challenge {profile}", salt). - Connect to the SSH agent (via
spawn_blockingto avoid blocking the tokio runtime). - Find the identity matching the enrolled fingerprint.
- Sign the challenge with the enrolled key.
- Derive the KEK:
BLAKE3::derive_key("pds v2 ssh-vault-kek {profile}", signature_bytes). - Zeroize the raw signature bytes.
- Construct an
EncryptionKeyfrom the KEK, then zeroize the KEK bytes. - Decrypt the master key from the enrollment blob’s ciphertext using AES-256-GCM.
- Return an
UnlockOutcomewithipc_strategy: DirectMasterKey,factor_id: SshAgent, and audit metadata including the SSH fingerprint and key type.
Enrollment Flow
- Connect to the SSH agent, list all identities, filter to eligible key types (Ed25519, RSA).
- Select a key by
selected_key_index(required –NonereturnsNoEligibleKey). - Sign the challenge with the selected key.
- Derive the KEK from the signature (same derivation as unlock).
- Zeroize the signature bytes.
- Generate a 12-byte random nonce via
getrandom. - Encrypt the master key with AES-256-GCM using the KEK and nonce.
- Zeroize the KEK bytes.
- Build and serialize the
EnrollmentBlobwith the key fingerprint, key type, nonce, and ciphertext. - Write to disk atomically via a
.ssh-enrollment.tmpintermediate, with0o600permissions.
Key Selection
The CLI sesame ssh enroll command in open-sesame/src/ssh.rs supports three methods for
selecting which SSH key to enroll:
Fingerprint via –ssh-key Flag
sesame ssh enroll --ssh-key SHA256:abc123...
The fingerprint is matched against loaded agent keys, with or without the SHA256: prefix.
Public Key File via –ssh-key Flag
sesame ssh enroll --ssh-key ~/.ssh/id_ed25519.pub
The file is read, parsed as an OpenSSH public key, and its SHA256 fingerprint is computed.
Path traversal via ~/ is resolved through canonicalize() and verified to remain within
$HOME. Files larger than 64 KB are rejected.
Interactive Menu
When --ssh-key is omitted and stdin is a terminal, dialoguer::Select presents a menu of
eligible keys from the agent, showing fingerprint and algorithm. In non-interactive mode
(piped stdin), --ssh-key is required.
Agent Connection
The connect_agent() function in core-auth/src/ssh.rs attempts two socket paths in order:
-
$SSH_AUTH_SOCK: The standard environment variable, set byssh-agent,sshdforwarding, or systemd environment propagation. -
~/.ssh/agent.sock: A fallback stable symlink path. On Konductor VMs,/etc/profile.d/konductor-ssh-agent.shcreates~/.ssh/agent.sockpointing to the forwarded agent socket (/tmp/ssh-XXXX/agent.PID) on each SSH login. This gives systemd user services a stable path to the forwarded agent, since$SSH_AUTH_SOCKpoints to a per-session temporary directory that changes on each login.
The function is intentionally synchronous – local Unix socket connect is sub-millisecond.
All agent operations in the async VaultAuthBackend methods are wrapped in
tokio::task::spawn_blocking to avoid blocking the tokio runtime.
Agent Forwarding
For remote or containerized environments where the SSH key lives on the operator’s workstation:
- The SSH agent socket is forwarded via
ssh -AorForwardAgent yesin SSH config. $SSH_AUTH_SOCKis set bysshdto the forwarded socket path.- The stable symlink pattern (
~/.ssh/agent.sock) provides systemd user services access to the forwarded agent, since systemd services do not inherit the per-session$SSH_AUTH_SOCK. - The Konductor profile.d hook creates and maintains this symlink automatically on each SSH login.
This architecture allows vault unlock via SSH agent even when running inside a VM or container, provided the SSH agent is forwarded from the host.
Platform Keyring Backend
The platform keyring factor (AuthFactorId::PlatformKeyring, config string
platform-keyring) unlocks a vault without interaction while the user’s operating-system
keyring is unlocked: on Linux, the freedesktop Secret Service (gnome-keyring, KWallet,
oo7-daemon, KeePassXC) that the desktop login usually unlocks.
Design
Enrollment draws a random 256-bit key-encrypting key (KEK) from the OS random source,
stores it in the credential store as service open-sesame, account vault-kek:<profile>,
and writes the vault’s master key wrapped under it (WrappedKey, AES-256-GCM) to
<config dir>/vaults/<profile>.keyring-enrollment. Unlock reads the KEK back and unwraps.
- Neither half alone yields the master key: the enrollment file decrypts nothing without the keyring item, and the keyring item is a random key that decrypts nothing but that file.
- The KEK is never derived from a password, so a stolen enrollment file offers nothing to brute-force offline.
- Each enrollment draws a fresh KEK; re-enrolling replaces both halves.
The Credential Store Seam
core_types::CredentialStore is the operating system’s store of per-user secrets behind one
interface; each platform crate implements it and consumers hold an
Arc<dyn CredentialStore>:
| Method | Answer |
|---|---|
get(id) | The secret in protected memory (SensitiveBytes), or None when no credential carries id |
set(id, label, secret) | Stores the secret, replacing the credential carrying id |
delete(id) | Whether a credential carried id |
vendor(), persistence() | The implementation, and how long credentials last |
A missing credential is an answer, not an error. The errors are distinct
(CredentialError): Unavailable (no store reachable), Locked (not unlocked),
Dismissed (the user dismissed the store’s prompt), Ambiguous (more than one credential
carries the id; the store holds items the caller did not write, and choosing one would be a
guess), and Platform.
| Platform | Implementation |
|---|---|
| Linux | platform_linux::keyring::SecretServiceStore |
| macOS | Keychain: not implemented (platform-macos/src/keychain.rs) |
| Windows | Credential Manager: not implemented (platform-windows/src/credential.rs) |
core_daemon::credential_store() connects the platform’s store, or returns None (logged)
when the platform has none or it cannot be reached. Its callers are the CLI and
daemon-launcher (Who Reads the KEK).
Linux: SecretServiceStore
SecretServiceStore is built on oo7. connect() uses the Secret Service default collection
on the host, and the Secret portal’s file keyring inside a Flatpak sandbox
(oo7::Keyring::new). with_connection(connection) uses the Secret Service on a given D-Bus
connection.
- Credentials are items with the attributes
serviceandusername, the convention libsecret’ssecret-tooland keyring-rs share (secret-tool lookup service open-sesame username vault-kek:workfinds a vault’s KEK). - A locked collection is unlocked before every operation, which may raise the keyring’s own prompt. A locked keyring is never read as an empty one.
- More than one item carrying the id is
Ambiguousforgetandset.
platform-linux/tests/secret_service.rs runs the store against oo7-daemon’s Secret Service,
served in-process over a peer-to-peer D-Bus connection: round trip, replacement, deletion,
ambiguous items, and a collection locked through the Secret Service Lock method.
Who Reads the KEK
The credential store is a service on the session D-Bus bus, and a process on that bus can also
ask the user’s service manager (org.freedesktop.systemd1, StartTransientUnit) to run any
command. No sandboxed daemon is granted the bus (Sandbox Model),
so the factor is read only by processes outside a sandbox:
sesame unlock(the CLI) reads it itself.- The overlay’s inline unlock (daemon-wm) asks daemon-launcher, the one daemon outside a
sandbox, with
KeyringUnlockRequest { profile }. daemon-launcher reads the KEK, unwraps the master key, and submits the factor to daemon-secrets; daemon-wm receives daemon-secrets’ own answer (FactorResponse,UnlockRejected), relayed, orKeyringUnlockFailed { reason }when the factor could not be read. Neither the KEK nor the master key enters daemon-wm. daemon-launcher serves the request only from the bus-verified senderdaemon-wm, since it unlocks a vault without the user.
This is the shape of the freedesktop Secret portal: the sandboxed client makes a narrow request over an authenticated channel, and a trusted process outside the sandbox does the credential access.
Commands
| Command | Effect |
|---|---|
sesame keyring enroll -p <profiles> | Enrolls the factor (the enrollment transaction); requires the vault password |
sesame keyring status -p <profiles> [--json] | Reports, per vault, the enrollment file, the metadata record, and the KEK’s state in the store; the vault is ready only with all three |
sesame keyring revoke -p <profiles> | Removes the enrollment file, the KEK, and the metadata record |
status reports each KEK state separately: present, missing, malformed,
locked, dismissed, ambiguous, store-unavailable, failed. A vault whose metadata
cannot be read is reported in its row with the reason; the store and the other vaults are
still reported. Reading the KEK may raise the keyring’s unlock prompt.
Failure Modes
| Condition | Result |
|---|---|
| No credential store reachable | The CLI’s factor has no backend, and a vault requiring it names the factor; the overlay receives KeyringUnlockFailed and tries the next factor |
| daemon-launcher not running | The overlay’s request fails and the next factor is tried |
| Keyring locked, prompt dismissed | AuthError::Keyring(CredentialError::Dismissed); the next factor is tried |
| KEK deleted from the keyring | AuthError::KeyringEntryMissing, naming the credential and sesame keyring enroll |
| Keyring item not 32 bytes | AuthError::MalformedKek, naming the credential |
| Enrollment file damaged | AuthError::InvalidBlob, naming the file |
| A different KEK in the keyring | AuthError::UnwrapFailed |
FIDO2 / WebAuthn Backend
Status: Design Intent. The
AuthFactorId::Fido2variant exists incore-types::authand theVaultAuthBackendtrait is defined incore-auth::backend, but no struct implements this factor today. This page documents what the backend will do when built, grounded in the trait interface and FIDO2 standards.
The FIDO2 backend enables vault unlock using CTAP2-compliant authenticators – USB security
keys, platform authenticators, and BLE/NFC tokens. It maps to AuthFactorId::Fido2 (config
string "fido2") and operates through libfido2 directly, without a browser or the WebAuthn
JavaScript API.
Relevant Standards
| Standard | Role |
|---|---|
| CTAP2 (Client to Authenticator Protocol 2.1) | Wire protocol between host and authenticator. Open Sesame acts as the CTAP2 platform (client). |
| WebAuthn Level 2 (W3C) | Defines the relying party model, credential creation, and assertion ceremonies. Open Sesame borrows the data model (RP ID, credential ID, user handle) but does not use a browser. |
| HMAC-secret extension (CTAP2.1) | Allows the authenticator to compute a deterministic symmetric secret from a caller-provided salt, without exposing the credential private key. This is the primary key-derivation mechanism. |
| credProtect extension | Controls whether credentials are discoverable without user verification. Should be set to level 2 or 3 to prevent silent credential enumeration. |
Mapping to VaultAuthBackend
factor_id()
Returns AuthFactorId::Fido2.
backend_id()
Returns "fido2".
name()
Returns "FIDO2/WebAuthn" (for overlay display and audit logs).
requires_interaction()
Returns AuthInteraction::HardwareTouch. CTAP2 authenticators require user presence (UP) at
minimum; most also support user verification (UV) via on-device PIN or biometric. Both require
physical interaction.
is_enrolled(profile, config_dir)
Checks whether a file {config_dir}/profiles/{profile}/fido2.enrollment exists and contains
a valid enrollment blob (see Enrollment Blob Format below). The enrollment record contains
the credential ID, relying party ID, and the wrapped master key blob. This is a synchronous
filesystem check with no device communication.
can_unlock(profile, config_dir)
- Verify enrollment exists via
is_enrolled(). - Enumerate connected FIDO2 devices via
libfido2device enumeration. - Return
trueif at least one device is present.
Device enumeration over HID typically completes in under 20ms, well within the 100ms trait
budget. This method does not verify that the connected device holds the enrolled credential
– that requires a CTAP2 transaction and user interaction, which is deferred to unlock().
enroll(profile, master_key, config_dir, salt, selected_key_index)
Enrollment proceeds as follows:
- Enumerate connected FIDO2 authenticators. If
selected_key_indexisSome(i), select the i-th device; otherwise select the first. - Construct a relying party ID:
open-sesame:{profile}(synthetic, not a web origin). - Generate a random 32-byte user ID and a random 16-byte challenge.
- Perform
authenticatorMakeCredentialwith:- Algorithm: ES256 (COSE -7) preferred, EdDSA (COSE -8) as fallback.
- Extensions:
hmac-secret: true,credProtect: 2,rk: true(resident key). - User verification: preferred (UV if the device supports it).
- Store the attestation response (credential ID, public key, attestation object).
- Immediately perform a
getAssertionwith thehmac-secretextension, passingsaltas the HMAC-secret salt input. The authenticator returns a 32-byte HMAC output. - Use the HMAC output as a key-encryption key (KEK). Wrap
master_keyunder this KEK using AES-256-GCM with a random 12-byte nonce. - Serialize and write the enrollment blob to
{config_dir}/profiles/{profile}/fido2.enrollment.
unlock(profile, config_dir, salt)
Unlock proceeds as follows:
- Load and deserialize the enrollment blob.
- Perform
authenticatorGetAssertionfor the enrolled RP ID and credential ID, with:- Extensions:
hmac-secretwithsaltas input. - User verification: preferred.
- Extensions:
- The authenticator returns a 32-byte HMAC output (the KEK) and an assertion signature.
- Unwrap the master key from the enrollment blob using the KEK (AES-256-GCM decrypt).
- If unwrap fails (wrong device or tampered blob), return
AuthError::UnwrapFailed. - Return
UnlockOutcome:master_key: the unwrapped 32-byte key.ipc_strategy:IpcUnlockStrategy::DirectMasterKey.factor_id:AuthFactorId::Fido2.audit_metadata:{"aaguid": "<hex>", "credential_id": "<hex>", "uv": "true|false"}.
revoke(profile, config_dir)
Deletes {config_dir}/profiles/{profile}/fido2.enrollment. Does not attempt to delete the
resident credential from the authenticator (CTAP2 does not guarantee remote deletion support
across all devices).
Enrollment Blob Format
Version: u8 (1)
RP ID: length-prefixed UTF-8
Credential ID: length-prefixed bytes
Public Key (COSE): length-prefixed bytes
Attestation Object: length-prefixed bytes (optional, for future policy use)
Wrapped Master Key: 12-byte nonce || ciphertext || 16-byte GCM tag
The blob is versioned to allow schema evolution. The version byte is checked on load; unknown
versions produce AuthError::InvalidBlob.
FactorContribution
AuthCombineMode::AnyorAuthCombineMode::Policy: The backend providesFactorContribution::CompleteMasterKey. It independently unwraps the full 32-byte master key from its enrollment blob.AuthCombineMode::All: The backend providesFactorContribution::FactorPiece. The 32-byte HMAC-secret output is contributed as one input to the combined HKDF derivation. In this mode, enrollment does not wrap the master key; it stores only the credential ID and RP ID. The HMAC-secret output itself is the piece.
Platform Authenticator vs Roaming Authenticator
FIDO2 defines two authenticator attachment modalities:
- Platform authenticators are built into the host device (e.g., Windows Hello TPM-backed key, macOS Touch ID Secure Enclave key, Android biometric key). On Linux desktops, platform authenticators are uncommon.
- Roaming authenticators are external devices connected via USB HID, NFC, or BLE (e.g., YubiKey 5, SoloKeys, Google Titan, Nitrokey).
This backend targets roaming authenticators. For platform biometric unlock on Linux, the
Biometrics backend (AuthFactorId::Fingerprint) is the appropriate
choice – it uses fprintd/polkit rather than CTAP2.
Browser-less Operation
Open Sesame communicates directly with authenticators via libfido2, the reference CTAP2 C
library maintained by Yubico. Consequences:
- No origin binding. The RP ID is a synthetic string (
open-sesame:{profile}), not a web origin. There is no TLS channel binding. - No browser UI. The daemon overlay prompts the user to touch the authenticator. The backend blocks on the CTAP2 transaction until UP/UV is satisfied or a timeout expires.
- Attestation is informational. The attestation object is stored for optional future policy enforcement (e.g., restricting enrollment to FIPS-certified authenticators via FIDO Metadata Service lookup) but is not verified during normal unlock.
Integration Dependencies
| Dependency | Type | Purpose |
|---|---|---|
libfido2 >= 1.13 | System C library | CTAP2 HID/NFC/BLE transport |
libfido2-dev | System package | Build-time headers and pkg-config |
Rust crate: libfido2 or ctap-hid-fido2 | Cargo dependency | Safe Rust bindings |
udev rule or plugdev group | System config | User access to /dev/hidraw* devices |
Threat Model Considerations
- Deterministic KEK. The HMAC-secret output is deterministic for a given (credential, salt) pair. Changing the vault salt invalidates the KEK; re-enrollment is required after re-keying.
- Loss recovery. If the authenticator is lost or destroyed, the enrollment blob is useless. Recovery requires another enrolled factor (password, SSH agent, etc.).
- Clone resistance. Depends on the authenticator hardware. Devices with a secure element
(YubiKey 5, SoloKeys v2) resist cloning. Software-only CTAP2 implementations (e.g.,
libfido2soft token) provide no clone resistance. - PIN brute-force. CTAP2 authenticators implement per-device PIN retry counters with lockout. This is enforced by the authenticator firmware, not by Open Sesame.
- Relay attacks. An attacker with network access to the USB HID device could relay CTAP2 messages. Physical proximity verification is delegated to the authenticator’s UP mechanism.
See Also
- Factor Architecture –
VaultAuthBackendtrait definition and dispatch - Hardware Tokens – YubiKey PIV/challenge-response (non-FIDO2 protocols)
- Biometrics – Platform biometric unlock via fprintd
- Policy Engine – Multi-factor combination modes (
Any,All,Policy)
TPM 2.0 Backend
Status: Design Intent. The
AuthFactorId::Tpmvariant exists incore-types::authand theVaultAuthBackendtrait is defined incore-auth::backend, but no struct implements this factor today. This page documents what the backend will do when built, grounded in the trait interface and TPM 2.0 standards.
The TPM backend enables vault unlock by sealing the master key to the platform’s Trusted
Platform Module. The sealed blob can only be unsealed when the TPM’s Platform Configuration
Registers (PCRs) match the values recorded at seal time, binding the vault to a specific
machine in a specific boot state. It maps to AuthFactorId::Tpm (config string "tpm").
Relevant Standards
| Specification | Role |
|---|---|
| TPM 2.0 Library Specification (TCG) | Defines the TPM command set, key hierarchies, sealing, and PCR operations. |
| TCG PC Client Platform TPM Profile (PTP) | Specifies PCR allocation and boot measurement conventions for PC platforms. |
| tpm2-tss (TCG Software Stack) | Userspace C library providing ESAPI, FAPI, and TCTI layers for TPM communication. |
| tpm2-tools | Command-line tools built on tpm2-tss, useful for enrollment scripting and debugging. |
| Linux IMA (Integrity Measurement Architecture) | Extends PCR 10 with file hashes during runtime. Optional extension point for runtime integrity. |
Core Concept: Sealing to PCR State
TPM 2.0 sealing binds a data blob to an authorization policy that includes PCR values. The TPM only unseals the blob if the current PCR values match the policy. This creates a hardware-enforced link between the vault key and boot integrity state:
- At enrollment, the backend reads the current PCR values, constructs an authorization policy from them, and seals the master key under the TPM’s Storage Root Key (SRK) with that policy.
- At unlock, the backend asks the TPM to unseal the blob. The TPM internally compares current PCR values against the sealed policy. If they match, the blob is released. If any measured component has changed, unsealing fails.
PCR Selection
The default PCR selection for desktop Linux:
| PCR | Measures |
|---|---|
| 0 | UEFI firmware code |
| 1 | UEFI firmware configuration |
| 2 | Option ROMs / external firmware |
| 3 | Option ROM configuration |
| 7 | Secure Boot state (PK, KEK, db, dbx) |
PCRs 4-6 (boot manager, GPT, resume events) are intentionally excluded by default because kernel updates would invalidate the seal on every update. The PCR set is configurable at enrollment time.
Extending to PCR 11 (unified kernel image measurement, used by systemd-stub) or PCR 10
(IMA) is supported as an opt-in for higher-assurance configurations.
Mapping to VaultAuthBackend
factor_id()
Returns AuthFactorId::Tpm.
backend_id()
Returns "tpm".
name()
Returns "TPM 2.0".
requires_interaction()
Returns AuthInteraction::None. TPM unsealing is a silent, non-interactive operation. The
TPM does not require user presence for unsealing (unlike FIDO2). If a TPM PIN (authValue) is
configured on the sealed object, the interaction type changes to
AuthInteraction::PasswordEntry.
is_enrolled(profile, config_dir)
Checks whether {config_dir}/profiles/{profile}/tpm.enrollment exists and contains a valid
sealed blob with a recognized version byte.
can_unlock(profile, config_dir)
- Verify enrollment exists via
is_enrolled(). - Open a connection to the TPM via the TCTI (typically
/dev/tpmrm0, the kernel resource manager). - Return
trueif the TPM device is accessible.
PCR matching is not checked here – a trial unseal could exceed the 100ms budget and may trigger rate limiting on some TPM implementations.
enroll(profile, master_key, config_dir, salt, selected_key_index)
- Open a TPM context via tpm2-tss ESAPI.
- Read the current PCR values for the configured PCR selection (default: 0, 1, 2, 3, 7).
- Build a
PolicyPCRauthorization policy from the PCR digest. - Optionally, combine with
PolicyAuthValueif the user wants a TPM PIN (defense-in-depth against evil-maid attacks where PCRs match but an attacker has physical access). - Create a sealed object under the SRK (Storage Hierarchy, persistent handle
0x81000001or equivalent):- Object type:
TPM2_ALG_KEYEDHASHwithsealattribute. - Data: the 32-byte
master_key. - Auth policy: the PCR policy (and optionally PIN policy).
- Object type:
- Persist the sealed object to a TPM NV index, or serialize the public/private portions to disk.
- Write the enrollment blob to
{config_dir}/profiles/{profile}/tpm.enrollment.
selected_key_index is unused (there is one TPM per machine). It is ignored.
unlock(profile, config_dir, salt)
- Load the enrollment blob and deserialize the sealed object context.
- Open a TPM context via ESAPI.
- Load the sealed object into the TPM.
- Start a policy session. Execute
PolicyPCRwith the enrolled PCR selection. - If a TPM PIN was configured, execute
PolicyAuthValueand provide the PIN. - Call
TPM2_Unsealwith the policy session. - If unsealing succeeds, the TPM returns the 32-byte master key.
- If unsealing fails (PCR mismatch), return
AuthError::UnwrapFailed. The audit metadata should include which PCRs diverged, if determinable. - Return
UnlockOutcome:master_key: the unsealed 32-byte key.ipc_strategy:IpcUnlockStrategy::DirectMasterKey.factor_id:AuthFactorId::Tpm.audit_metadata:{"pcr_selection": "0,1,2,3,7", "tpm_manufacturer": "<vendor>"}.
revoke(profile, config_dir)
- If the sealed object was persisted to a TPM NV index, evict it with
TPM2_EvictControl. - Delete
{config_dir}/profiles/{profile}/tpm.enrollment.
Enrollment Blob Format
Version: u8 (1)
PCR selection: u32 bitmask (bit N set = PCR N included)
PCR digest at seal time: 32 bytes (SHA-256)
Sealed object public area: length-prefixed bytes (TPM2B_PUBLIC)
Sealed object private area: length-prefixed bytes (TPM2B_PRIVATE)
SRK handle: u32
PIN flag: u8 (0 = no PIN, 1 = PolicyAuthValue included)
FactorContribution
AuthCombineMode::AnyorAuthCombineMode::Policy: The backend providesFactorContribution::CompleteMasterKey. The TPM directly unseals the full 32-byte master key.AuthCombineMode::All: The backend providesFactorContribution::FactorPiece. At enrollment, a random 32-byte piece is sealed (not the master key itself). At unlock, the unsealed piece is contributed to the combined HKDF derivation.
Measured Boot Chain
The security of this backend depends on the integrity of the measured boot chain:
- UEFI firmware measures itself and boot configuration into PCRs 0-3.
- Shim / bootloader (GRUB, systemd-boot) is measured by the firmware into PCR 4.
- Secure Boot state (whether Secure Boot is enabled, which keys are enrolled) is reflected in PCR 7.
- Kernel and initramfs, if using
systemd-stubunified kernel images (UKI), are measured into PCR 11.
If an attacker modifies any component in this chain, the corresponding PCR value changes, and the TPM refuses to unseal the vault key.
Firmware and Kernel Updates
After a firmware or kernel update, PCR values change and the sealed blob becomes invalid. Strategies to manage this:
- Predictive re-sealing. Before a kernel update, predict the new PCR values (using
systemd-pcrphaseorsystemd-measure) and create a second sealed blob for the new values. Delete the old one after successful boot. - Fallback factor. Always maintain a second enrolled factor (password, SSH agent) so access is not lost when PCR values change unexpectedly.
- PCR selection trade-offs. Excluding volatile PCRs (4, 5, 6) from the policy reduces re-enrollment frequency at the cost of reduced boot integrity coverage.
Platform Binding
The TPM is a physical chip (or firmware TPM) soldered to the motherboard. The sealed blob is bound to that specific TPM – it cannot be moved to another machine. This provides:
- Hardware binding. The vault is tied to a specific physical device.
- Anti-theft. A stolen drive cannot be unlocked on another machine.
- Anti-cloning. TPM private keys cannot be extracted (the TPM is designed to resist physical attacks on the chip package).
Integration Dependencies
| Dependency | Type | Purpose |
|---|---|---|
tpm2-tss >= 4.0 | System C library | ESAPI, FAPI, and TCTI for TPM communication |
tpm2-tss-devel | System package | Build-time headers |
Rust crate: tss-esapi | Cargo dependency | Safe Rust bindings to tpm2-tss ESAPI |
/dev/tpmrm0 | Kernel device | TPM resource manager (kernel >= 4.12) |
tpm2-abrmd (optional) | System service | Userspace resource manager (alternative to kernel RM) |
tpm2-tools (optional) | System package | Debugging and manual enrollment scripting |
The user must have read/write access to /dev/tpmrm0 (typically via the tss group or a
udev rule).
Threat Model Considerations
- Evil-maid with matching PCRs. If an attacker can reproduce the exact boot chain (same
firmware, same bootloader, same Secure Boot keys), they can unseal the key. Adding a TPM
PIN (
PolicyAuthValue) mitigates this. - Firmware TPM (fTPM) vulnerabilities. Firmware TPMs run inside the CPU or chipset firmware. Vulnerabilities in fTPM firmware (e.g., AMD fTPM voltage glitching) can potentially extract sealed data. Discrete TPM chips (e.g., Infineon SLB9670) offer stronger physical resistance.
- Running-system compromise. TPM sealing protects at-rest data. Once the system is booted and the vault is unlocked, an attacker with root access can read the master key from daemon-secrets process memory. TPM does not protect against runtime compromise.
- PCR reset attacks. On some platforms, a hardware reset of the TPM (e.g., via LPC bus manipulation) can reset PCRs to zero. Sealing to PCR 7 (Secure Boot state) partially mitigates this because Secure Boot measurements are replayed from firmware on reset.
- vTPM in virtualized environments. A virtual TPM provides no physical security. The hypervisor can read all sealed data. TPM enrollment in a VM is useful for binding a vault to a specific VM instance, not for hardware-level tamper resistance.
See Also
- Factor Architecture –
VaultAuthBackendtrait definition and dispatch - SED/Opal – Drive-level hardware binding (complementary to TPM)
- Policy Engine – Multi-factor combination modes
- FIDO2/WebAuthn – Alternative hardware factor (portable, not platform-bound)
Biometrics Backend
Status: Design Intent. The
AuthFactorId::Fingerprintvariant exists incore-types::authand theVaultAuthBackendtrait is defined incore-auth::backend, but no struct implements this factor today. This page documents what the backend will do when built, grounded in the trait interface and platform biometric APIs.
The biometrics backend enables vault unlock gated by fingerprint verification (and, in the
future, other biometric modalities such as face recognition). It maps to
AuthFactorId::Fingerprint (config string "fingerprint"). The critical design principle:
biometric data is never used as key material. Biometrics are authentication gates that release
a stored key, not secrets from which keys are derived.
Design Principle: Biometrics Are Not Secrets
Biometric features (fingerprint minutiae, facial geometry) are not secret – they can be observed, photographed, or lifted from surfaces. They are also not stable – they vary between readings. For these reasons, the biometrics backend never derives cryptographic key material from biometric data. Instead:
- At enrollment, the master key (or a KEK) is encrypted and stored on disk.
- The decryption key for that blob is held in a platform keystore that requires biometric verification to release.
- At unlock, the platform biometric subsystem verifies the user, and if successful, releases the decryption key to the backend.
The biometric template (the mathematical representation of the fingerprint or face) never leaves the platform biometric subsystem. Open Sesame never sees, stores, or transmits biometric data.
Platform Biometric APIs
Linux: fprintd
On Linux, fingerprint authentication is mediated by fprintd, a D-Bus service that manages
fingerprint readers and templates. The authentication flow:
- The backend calls
net.reactivated.Fprint.Device.VerifyStarton the fprintd D-Bus interface. fprintdcommunicates with the fingerprint sensor hardware vialibfprint, acquires a fingerprint image, and matches it against enrolled templates.- On match,
fprintdemits aVerifyStatussignal withverify-match. On failure,verify-no-matchorverify-retry-scan. - The backend calls
VerifyStopto end the session.
The backend uses the fprintd D-Bus API directly (not PAM) to avoid requiring a full PAM session context.
Future: macOS LocalAuthentication
On macOS (if platform support is added), LocalAuthentication.framework provides Touch ID
and Face ID gating of Keychain items. A Keychain item with
kSecAccessControlBiometryCurrentSet requires biometric verification before the Keychain
releases the stored secret. This maps directly to the “biometric gates release of a stored
key” model.
Future: Windows Hello
On Windows, Windows.Security.Credentials.KeyCredentialManager and the Windows Hello
biometric subsystem provide similar gating. The TPM-backed key is released only after
Windows Hello verification succeeds.
Mapping to VaultAuthBackend
factor_id()
Returns AuthFactorId::Fingerprint.
backend_id()
Returns "fingerprint".
name()
Returns "Fingerprint".
requires_interaction()
Returns AuthInteraction::HardwareTouch. The user must place their finger on the sensor.
is_enrolled(profile, config_dir)
Checks two conditions:
- An enrollment blob exists at
{config_dir}/profiles/{profile}/fingerprint.enrollment. - At least one fingerprint is enrolled in
fprintdfor the current system user (queried vianet.reactivated.Fprint.Device.ListEnrolledFingers).
Both must be true. If the system fingerprint enrollment is wiped (user re-enrolled fingers in system settings), the Open Sesame enrollment blob still exists on disk but the platform verification will match against different templates, making it effectively stale.
can_unlock(profile, config_dir)
- Verify enrollment exists via
is_enrolled(). - Check that
fprintdis running (D-Bus namenet.reactivated.Fprintis available). - Check that at least one fingerprint reader device is present.
D-Bus name lookup and device enumeration complete well within the 100ms trait budget.
enroll(profile, master_key, config_dir, salt, selected_key_index)
- Verify that
fprintdhas at least one enrolled fingerprint for the current user. If not, returnAuthError::BackendNotApplicable("no fingerprints enrolled in fprintd; enroll via system settings first"). - Generate a random 32-byte storage key.
- Wrap
master_keyunder the storage key using AES-256-GCM. - Store the storage key in a location protected by biometric gating:
- Primary strategy (Linux): Store the storage key in the user’s kernel keyring
(
keyctl) under a session-scoped key. The keyring entry is created with a timeout matching the user session. Biometric verification via fprintd acts as the authorization gate before the backend retrieves the keyring secret at unlock time. - Fallback strategy: Encrypt the storage key with a key derived from
saltand a device-specific identifier (machine-id). Store the encrypted storage key in the enrollment blob itself. The biometric check acts as the sole authorization gate.
- Primary strategy (Linux): Store the storage key in the user’s kernel keyring
(
- Write the enrollment blob to
{config_dir}/profiles/{profile}/fingerprint.enrollment.
selected_key_index is unused (there is one biometric subsystem per machine). It is ignored.
unlock(profile, config_dir, salt)
- Load the enrollment blob.
- Initiate fingerprint verification via fprintd D-Bus API (
VerifyStart). - Wait for the
VerifyStatussignal. The daemon overlay displays a “scan your fingerprint” prompt. - If verification fails (no match, timeout, or sensor error), return
AuthError::UnwrapFailed. - If verification succeeds, retrieve the storage key from the kernel keyring (primary strategy) or decrypt it from the blob (fallback strategy).
- Unwrap the master key using the storage key (AES-256-GCM decrypt).
- Return
UnlockOutcome:master_key: the unwrapped 32-byte key.ipc_strategy:IpcUnlockStrategy::DirectMasterKey.factor_id:AuthFactorId::Fingerprint.audit_metadata:{"method": "fprintd", "finger": "<which_finger>"}(if fprintd reports which finger matched).
revoke(profile, config_dir)
- Remove the storage key from the kernel keyring (if using primary strategy).
- Delete
{config_dir}/profiles/{profile}/fingerprint.enrollment.
Does not remove fingerprints from fprintd – those are system-level enrollments managed by the user outside of Open Sesame.
Enrollment Blob Format
Version: u8 (1)
Storage strategy: u8 (1 = kernel keyring, 2 = embedded encrypted key)
Wrapped master key: 12-byte nonce || ciphertext || 16-byte GCM tag
Embedded encrypted storage key (strategy 2 only): 12-byte nonce || ciphertext || 16-byte tag
Device binding hash: 32 bytes (SHA-256 of machine-id || profile name)
FactorContribution
AuthCombineMode::AnyorAuthCombineMode::Policy: The backend providesFactorContribution::CompleteMasterKey. It unwraps the full master key after biometric verification succeeds.AuthCombineMode::All: The backend providesFactorContribution::FactorPiece. A random 32-byte piece (not the master key) is stored behind the biometric gate and contributed to HKDF derivation upon successful verification.
The biometric itself does not contribute entropy – it is a gate. The piece is a random value generated at enrollment time and stored behind the biometric gate.
Liveness Detection
Fingerprint sensors vary in their resistance to spoofing:
| Sensor Type | Spoofing Resistance | Notes |
|---|---|---|
| Capacitive (most laptop sensors) | Moderate | Detects electrical properties of skin. Gummy fingerprints with conductive material can sometimes fool them. |
| Ultrasonic (e.g., Qualcomm 3D Sonic) | High | Measures sub-dermal features. More resistant to printed or molded replicas. |
| Optical (common in USB readers) | Low | Easiest to spoof with printed or molded fingerprints. |
Open Sesame delegates liveness detection entirely to the sensor hardware and fprintd. The
backend does not attempt its own liveness checks. Deployment guidance: use capacitive or
ultrasonic sensors for security-sensitive configurations, and combine biometric with a second
factor via AuthCombineMode::Policy.
Privacy Guarantees
- No template storage. Open Sesame never stores, transmits, or processes biometric
templates. Templates are managed exclusively by
fprintd(stored in/var/lib/fprint/). - No template access. The backend never requests raw biometric data or template bytes. It uses only the verify/match API, which returns a boolean result.
- No cross-profile linkability. The enrollment blob contains no biometric information. An attacker who obtains the blob cannot determine whose fingerprint unlocks the vault.
- User-controlled deletion. Revoking the backend deletes only the encrypted key blob. Biometric templates remain under user control in fprintd.
Integration Dependencies
| Dependency | Type | Purpose |
|---|---|---|
fprintd >= 1.94 | System service | Fingerprint verification via D-Bus |
libfprint >= 1.94 | System library | Sensor driver layer (used by fprintd) |
Rust crate: zbus | Cargo dependency | D-Bus client for fprintd communication |
Rust crate: keyutils | Cargo dependency | Linux kernel keyring access (primary storage strategy) |
| Compatible fingerprint reader | Hardware | Any reader supported by libfprint |
Threat Model Considerations
- Biometric spoofing. The backend is only as spoof-resistant as the sensor hardware. It
should not be the sole factor for high-value vaults. Combining biometric with password or
FIDO2 via
AuthCombineMode::Policyis recommended. - Stolen enrollment blob. The blob is useless without passing biometric verification (primary strategy) or without the device-specific derivation inputs (fallback strategy). The biometric gate is the critical protection.
- fprintd compromise. If an attacker can inject false D-Bus responses (by compromising fprintd or the user’s D-Bus session), they can bypass biometric verification. Running fprintd as a system service (not user session) and using D-Bus mediation via AppArmor or SELinux mitigates this.
- Irrevocable biometrics. If a fingerprint is compromised (lifted from a surface), the user cannot change their fingerprint. Mitigation: re-enroll with a different finger and revoke the old enrollment, or add a second factor requirement via policy.
- Fallback strategy weakness. The embedded-key fallback strategy protects the storage key only with device-specific derivation (machine-id + salt). An attacker with the enrollment blob and knowledge of the machine-id can bypass the biometric gate entirely. The primary strategy (kernel keyring) is strongly preferred.
See Also
- Factor Architecture –
VaultAuthBackendtrait definition and dispatch - FIDO2/WebAuthn – Roaming authenticator with on-device biometric UV
- Policy Engine – Combining biometric with other factors
Hardware Tokens Backend (YubiKey / Smart Cards / PIV)
Status: Design Intent. The
AuthFactorId::Yubikeyvariant exists incore-types::authand theVaultAuthBackendtrait is defined incore-auth::backend, but no struct implements this factor today. This page documents what the backend will do when built, grounded in the trait interface and relevant smart card standards.
The hardware tokens backend enables vault unlock using YubiKeys, PIV smart cards, and
PKCS#11-compatible cryptographic tokens. It maps to AuthFactorId::Yubikey (config string
"yubikey"). Despite the enum variant name referencing YubiKey specifically, the backend is
designed to support the broader category of challenge-response and certificate-based hardware
tokens.
This backend covers the non-FIDO2 capabilities of these devices. For FIDO2/CTAP2 operation, see the FIDO2/WebAuthn backend.
Supported Protocols
PIV (FIPS 201 / NIST SP 800-73)
Personal Identity Verification is a US government standard for smart card authentication. PIV cards (and YubiKeys with the PIV applet) contain X.509 certificates and corresponding private keys in hardware slots. The private key never leaves the card.
PIV slots relevant to Open Sesame:
| Slot | Purpose | PIN Policy | Touch Policy |
|---|---|---|---|
| 9a | PIV Authentication | Once per session | Configurable |
| 9c | Digital Signature | Always | Configurable |
| 9d | Key Management | Once per session | Configurable |
| 9e | Card Authentication | Never | Never |
Slot 9d (Key Management) is the natural fit for vault unlock – it is designed for key agreement and encryption operations, has a reasonable PIN policy (once per session), and supports touch policy configuration.
HMAC-SHA1 Challenge-Response (YubiKey Slot 2)
YubiKeys support HMAC-SHA1 challenge-response in their OTP applet (slots 1 and 2). The host
sends a challenge, the YubiKey computes HMAC-SHA1 with a pre-programmed 20-byte secret, and
returns the 20-byte response. This is the same mechanism used by ykman and ykchalresp.
Slot 2 (long press) is conventionally used for challenge-response to avoid conflicts with slot 1 (short press, often configured for OTP).
PKCS#11
PKCS#11 is the generic smart card interface. Any token with a PKCS#11 module (OpenSC, YubiKey YKCS11, Nitrokey, etc.) can be used. The backend loads the PKCS#11 shared library, finds a suitable private key object, and performs a sign or decrypt operation.
Mapping to VaultAuthBackend
factor_id()
Returns AuthFactorId::Yubikey.
backend_id()
Returns "yubikey".
name()
Returns "Hardware Token".
requires_interaction()
Returns AuthInteraction::HardwareTouch if the enrolled token has a touch policy enabled.
Returns AuthInteraction::PasswordEntry if the token requires a PIN but no touch. The
interaction type is recorded in the enrollment blob and returned by this method.
Most configurations require touch (physical presence), so HardwareTouch is the common case.
is_enrolled(profile, config_dir)
Checks whether {config_dir}/profiles/{profile}/yubikey.enrollment exists and contains a
valid enrollment blob.
can_unlock(profile, config_dir)
- Verify enrollment exists.
- Based on the enrolled protocol:
- HMAC-SHA1: Enumerate USB HID devices matching YubiKey vendor/product IDs.
- PIV/PKCS#11: Attempt to open a PCSC connection and verify that a card is present in a reader.
- Return
trueif a device is detected.
No cryptographic operation is performed (must stay within 100ms).
enroll(profile, master_key, config_dir, salt, selected_key_index)
The enrollment path depends on the protocol. The backend auto-detects the preferred protocol based on the connected device, or the user specifies via configuration.
HMAC-SHA1 Path
- Enumerate connected YubiKeys. If
selected_key_indexisSome(i), select the i-th device. - Issue a challenge-response using
saltas the challenge (hashed to fit the challenge length if needed). - The YubiKey returns a 20-byte HMAC-SHA1 response.
- Derive a 32-byte KEK from the HMAC response using HKDF-SHA256:
KEK = HKDF-SHA256(ikm=hmac_response, salt=salt, info="open-sesame:yubikey:{profile}"). - Wrap
master_keyunder the KEK using AES-256-GCM. - Store the enrollment blob with the YubiKey serial number, slot number, and wrapped master key.
PIV Path
- Open a PCSC connection to the smart card.
- Select the PIV applet (AID
A0 00 00 03 08). - Authenticate to the card (PIN prompt if required by slot policy).
- Read the certificate from the selected slot (default: 9d).
- Generate a random 32-byte challenge.
- Encrypt the challenge using the public key from the certificate (RSA-OAEP or ECDH depending on key type).
- Derive a KEK:
KEK = HKDF-SHA256(ikm=challenge, salt=salt, info="open-sesame:piv:{profile}"). - Wrap
master_keyunder the KEK. - Store the enrollment blob with the certificate fingerprint (SHA-256), slot number, encrypted challenge, and wrapped master key.
PKCS#11 Path
Follows the PIV path but uses the PKCS#11 API (C_FindObjects, C_Decrypt / C_Sign)
instead of raw APDU commands. The enrollment blob additionally stores the PKCS#11 module
path and token serial number.
unlock(profile, config_dir, salt)
HMAC-SHA1 Path
- Load enrollment blob.
- Issue challenge-response with
saltas the challenge. - Derive KEK from the HMAC response (same HKDF as enrollment).
- Unwrap master key. If unwrap fails (different YubiKey or different slot 2 secret), return
AuthError::UnwrapFailed.
PIV Path
- Load enrollment blob, including the encrypted challenge.
- Open PCSC connection, select PIV applet, authenticate (PIN if required).
- Decrypt the encrypted challenge using the card’s private key (slot 9d).
- Derive KEK from the decrypted challenge (same HKDF as enrollment).
- Unwrap master key.
Common Outcome
Return UnlockOutcome:
master_key: the unwrapped 32-byte key.ipc_strategy:IpcUnlockStrategy::DirectMasterKey.factor_id:AuthFactorId::Yubikey.audit_metadata:{"protocol": "hmac-sha1|piv|pkcs11", "serial": "<device_serial>", "slot": "<slot>"}.
revoke(profile, config_dir)
Delete {config_dir}/profiles/{profile}/yubikey.enrollment. Does not modify the token
itself (the HMAC secret or PIV keys remain on the device).
Enrollment Blob Format
Version: u8 (1)
Protocol: u8 (1 = HMAC-SHA1, 2 = PIV, 3 = PKCS#11)
Device serial: length-prefixed UTF-8
Slot/key identifier: length-prefixed UTF-8
Interaction type: u8 (maps to AuthInteraction variant)
--- Protocol-specific fields ---
[HMAC-SHA1]
Wrapped master key: 12-byte nonce || ciphertext || 16-byte GCM tag
[PIV]
Certificate fingerprint: 32 bytes (SHA-256)
Encrypted challenge: length-prefixed bytes
Wrapped master key: 12-byte nonce || ciphertext || 16-byte GCM tag
[PKCS#11]
Module path: length-prefixed UTF-8
Token serial: length-prefixed UTF-8
Certificate fingerprint: 32 bytes
Encrypted challenge: length-prefixed bytes
Wrapped master key: 12-byte nonce || ciphertext || 16-byte GCM tag
FactorContribution
AuthCombineMode::AnyorAuthCombineMode::Policy: The backend providesFactorContribution::CompleteMasterKey. It independently unwraps the full master key.AuthCombineMode::All: The backend providesFactorContribution::FactorPiece. For HMAC-SHA1, the HKDF output derived from the HMAC response is the piece (32 bytes). For PIV, the decrypted challenge is the piece. The piece is contributed to the combined HKDF derivation.
Touch Requirement for Physical Presence
YubiKeys and some smart cards support a touch policy: the device requires the user to physically touch a contact sensor before performing a cryptographic operation. This provides proof of physical presence, mitigating malware that silently uses the token while plugged in.
| Policy | Behavior |
|---|---|
| Never | No touch required (default for HMAC-SHA1 on some firmware) |
| Always | Touch required for every operation |
| Cached | Touch required once, cached for 15 seconds |
The backend records the touch policy in the enrollment blob so that
requires_interaction() returns the correct AuthInteraction variant. The daemon overlay
displays a “touch your key” prompt when AuthInteraction::HardwareTouch is indicated.
HMAC-SHA1 Key Derivation Detail
The HMAC-SHA1 response is only 20 bytes, insufficient for a 32-byte AES key directly. The HKDF-SHA256 expansion step stretches this to 32 bytes:
- The HMAC-SHA1 secret on the YubiKey is 20 bytes (160 bits), programmed at configuration time.
- The challenge (vault salt) is up to 64 bytes.
- The 20-byte HMAC output has at most 160 bits of entropy.
- HKDF’s security bound is
min(input_entropy, hash_output_length)= 160 bits, which exceeds the 128-bit security target for the derived 256-bit KEK.
Integration Dependencies
| Dependency | Type | Purpose |
|---|---|---|
pcsc-lite + libpcsclite-dev | System library | PCSC smart card access |
pcscd | System service | Smart card daemon (must be running for PIV/PKCS#11) |
opensc (optional) | System package | PKCS#11 module and generic smart card drivers |
ykpers / yubikey-manager (optional) | System library/tool | YubiKey HID communication for HMAC-SHA1 |
Rust crate: pcsc | Cargo dependency | PCSC bindings for PIV |
Rust crate: yubikey | Cargo dependency | YubiKey PIV operations |
Rust crate: cryptoki | Cargo dependency | PKCS#11 bindings |
Rust crate: yubico-manager or challenge-response | Cargo dependency | HMAC-SHA1 challenge-response |
Threat Model Considerations
- HMAC-SHA1 secret extraction. The HMAC secret on a YubiKey cannot be read back after programming. Extracting it requires destructive chip analysis.
- PIN brute-force. PIV PINs have a retry counter (default 3 attempts before lockout). After lockout, the PUK (PIN Unlock Key) is required. After PUK lockout, the PIV applet must be reset (destroying all keys).
- Token loss. If the token is lost, the enrollment blob is useless without the physical device. Recovery requires an alternative enrolled factor.
- Relay attacks (HMAC-SHA1). HMAC-SHA1 challenge-response over USB HID can be relayed over a network. Touch policy (set to “always”) mitigates this by requiring physical presence.
- Relay attacks (PIV). Smart card operations over PCSC can be relayed using tools like
virtualsmartcard. Touch policy on YubiKey PIV mitigates this. - SHA-1 and HMAC-SHA1. HMAC-SHA1 is not affected by SHA-1 collision attacks. HMAC security depends on the PRF property of the compression function, not collision resistance. HMAC-SHA1 remains secure for key derivation.
See Also
- Factor Architecture –
VaultAuthBackendtrait definition and dispatch - FIDO2/WebAuthn – FIDO2 mode of the same hardware (different protocol)
- TPM – Platform-bound hardware factor (non-portable)
- Policy Engine – Multi-factor combination modes
Self-Encrypting Drive (SED) / TCG Opal Backend
Status: Design Intent. No
AuthFactorIdvariant exists for SED/Opal today. This backend is a future extension that would require adding anAuthFactorId::SedOpalvariant tocore-types::auth. TheVaultAuthBackendtrait incore-auth::backenddefines the interface it would implement. This page documents the design intent.
The SED/Opal backend enables vault unlock by binding the master key to a Self-Encrypting Drive’s hardware encryption using the TCG Opal 2.0 specification. The drive’s encryption controller holds the key material, accessible only after the drive is unlocked with the correct credentials. This provides protection against physical drive theft without relying on software-layer full-disk encryption.
Relevant Standards
| Specification | Role |
|---|---|
| TCG Opal 2.0 (Trusted Computing Group) | Defines the SED management interface: locking ranges, authentication, band management, and the Security Protocol command set. |
| TCG Opal SSC (Security Subsystem Class) | Profile of TCG Storage that Opal-compliant drives implement. |
| ATA Security Feature Set | Legacy drive locking (ATA password). Opal supersedes this but some drives support both. |
| NVMe Security Send/Receive | Transport for TCG commands on NVMe drives. |
| IEEE 1667 | Silo-based authentication for storage devices (used by some USB encrypted drives). |
Core Concept: Drive-Bound Vault Keys
A Self-Encrypting Drive transparently encrypts all data written to it using a Media Encryption Key (MEK) stored in the drive controller. The MEK is wrapped by a Key Encryption Key (KEK) derived from the user’s authentication credential. Without the correct credential, the MEK cannot be unwrapped and the drive contents are cryptographically inaccessible.
The SED/Opal backend leverages this mechanism for vault key storage:
- At enrollment, the backend stores the vault master key within an Opal locking range’s DataStore table. The locking range is protected by an Opal credential that the backend manages.
- At unlock, the backend authenticates to the Opal Security Provider (SP) using the stored credential, reads the master key from the DataStore, and provides it to daemon-secrets.
Locking Range Architecture
Opal drives support multiple locking ranges. The backend uses a dedicated locking range for Open Sesame, separate from the global locking range (which may be used for full-disk encryption by the OS):
- Global Range (Range 0): Managed by the OS or firmware for full-disk encryption (e.g.,
sedutil-cli, BitLocker,systemd-cryptenroll). - Dedicated Range (Range N): A small range allocated for Open Sesame DataStore usage. Contains only the encrypted vault master key blob.
If a dedicated range cannot be allocated (drive does not support multiple ranges, or all ranges are in use), the backend falls back to storing the wrapped key in the DataStore table associated with the Admin SP.
Mapping to VaultAuthBackend
factor_id()
Returns AuthFactorId::SedOpal (to be added to the enum).
backend_id()
Returns "sed-opal".
name()
Returns "Self-Encrypting Drive".
requires_interaction()
Returns AuthInteraction::None. SED unlock is non-interactive. The backend authenticates to
the drive controller programmatically using a credential derived from device-specific secrets,
not a user-entered password.
is_enrolled(profile, config_dir)
Checks whether {config_dir}/profiles/{profile}/sed-opal.enrollment exists and contains a
valid enrollment blob identifying the drive (serial number, locking range, and Opal credential
reference).
can_unlock(profile, config_dir)
- Verify enrollment exists.
- Identify the enrolled drive by serial number.
- Check that the drive is present and accessible (block device exists or can be found by serial via sysfs).
- Return
trueif the drive is present.
Does not attempt Opal authentication (may exceed 100ms and may trigger lockout counters on failure).
enroll(profile, master_key, config_dir, salt, selected_key_index)
- Enumerate Opal-capable drives by sending TCG Discovery 0 to each block device.
- If
selected_key_indexisSome(i), select the i-th drive. Otherwise select the first Opal-capable drive. - Authenticate to the drive’s Admin SP using the SID (Security Identifier) or a pre-configured admin credential.
- Allocate or identify a locking range for Open Sesame use.
- Generate a random Opal credential for the locking range (or derive one from
saltand a device-specific secret). - Store the vault
master_keyin the DataStore table of the locking range. - Lock the range, binding it to the generated credential.
- Write the enrollment blob to
{config_dir}/profiles/{profile}/sed-opal.enrollmentcontaining the drive serial, locking range index, and the Opal credential (encrypted under a key derived fromsaltand the machine ID).
unlock(profile, config_dir, salt)
- Load the enrollment blob.
- Derive the Opal credential (decrypt using
saltand machine ID). - Open a session to the drive’s Locking SP.
- Authenticate with the credential.
- Read the master key from the DataStore table.
- Return
UnlockOutcome:master_key: the 32-byte key read from the DataStore.ipc_strategy:IpcUnlockStrategy::DirectMasterKey.factor_id:AuthFactorId::SedOpal.audit_metadata:{"drive_serial": "<serial>", "locking_range": "<N>"}.
revoke(profile, config_dir)
- Authenticate to the drive’s Admin SP.
- Erase the master key from the DataStore table (overwrite with zeros).
- Optionally release the locking range allocation.
- Delete
{config_dir}/profiles/{profile}/sed-opal.enrollment.
Enrollment Blob Format
Version: u8 (1)
Drive serial: length-prefixed UTF-8
Drive model: length-prefixed UTF-8
Block device path at enrollment time: length-prefixed UTF-8 (informational; may change)
Locking range index: u16
Opal credential (encrypted): 12-byte nonce || ciphertext || 16-byte GCM tag
Machine binding hash: 32 bytes (SHA-256 of machine-id, used in credential derivation)
FactorContribution
AuthCombineMode::AnyorAuthCombineMode::Policy: The backend providesFactorContribution::CompleteMasterKey. The drive hardware releases the full master key from the DataStore.AuthCombineMode::All: The backend providesFactorContribution::FactorPiece. A random 32-byte piece (not the master key) is stored in the DataStore and contributed to combined HKDF derivation.
Pre-Boot Authentication
TCG Opal defines a Pre-Boot Authentication (PBA) mechanism: a small region of the drive (the Shadow MBR) is presented to the BIOS/UEFI before the main OS boots. The PBA image authenticates the user and unlocks the drive before the OS sees the encrypted data.
Open Sesame does not implement PBA. It operates entirely within the running OS. If the drive is locked at boot by system-level SED management, Open Sesame assumes the drive is already unlocked by the time daemon-secrets starts. The backend uses Opal only for its DataStore facility (key storage with hardware-gated access), not for drive-level boot locking.
Integration Dependencies
| Dependency | Type | Purpose |
|---|---|---|
sedutil-cli | System tool | Opal drive management (enrollment, locking range setup) |
libata / kernel NVMe driver | Kernel | ATA Security / NVMe Security Send/Receive commands |
Rust crate: sedutil-rs or direct ioctl | Cargo dependency | Programmatic Opal SP communication |
/dev/sdX or /dev/nvmeXnY | Block device | Target drive |
Root or CAP_SYS_RAWIO | Privilege | Required for TCG command passthrough via SG_IO / NVMe admin commands |
Privilege Requirements
Opal commands require raw SCSI/ATA/NVMe command passthrough, which typically requires root
or CAP_SYS_RAWIO. Since daemon-secrets runs as a system service, this is consistent with
its privilege model. Enrollment and revocation also require admin-level Opal credentials
(SID or Admin1 authority).
Threat Model
Protects Against
- Physical drive theft. An attacker who steals the drive (but not the machine) cannot access the vault master key. The DataStore contents are encrypted by the drive’s MEK, inaccessible without the Opal credential.
- Offline forensic imaging. Imaging the raw drive platters or flash chips yields only ciphertext.
- Cold boot on different hardware. Moving the drive to another machine does not help because the Opal credential is derived from the original machine’s identity.
Does Not Protect Against
- Running-system compromise. Once the OS is booted and the drive is unlocked, an attacker with root access can read the DataStore contents. SED encryption is transparent to the running OS after unlock.
- DMA attacks. An attacker with physical access to the running machine can use DMA (e.g., via Thunderbolt or FireWire) to read memory containing the unlocked master key.
- SED firmware vulnerabilities. Research has demonstrated that some SED implementations have firmware bugs allowing bypass of Opal locking without the credential (e.g., the 2018 Radboud University disclosure affecting Crucial and Samsung drives). The backend cannot detect or mitigate firmware-level flaws.
- Evil-maid with machine access. If the attacker has access to the original machine (not just the drive), they can boot the machine, wait for the drive to be unlocked by the OS, and extract the master key.
Complementary Use with TPM
SED/Opal and TPM provide complementary hardware binding:
- TPM binds the vault to the boot integrity state (firmware, bootloader, Secure Boot policy). Protects against software-level boot chain tampering.
- SED/Opal binds the vault to the physical drive. Protects against drive theft.
Using both factors in AuthCombineMode::All provides defense in depth: the vault is bound
to both the machine’s boot state and the specific physical drive.
See Also
- Factor Architecture –
VaultAuthBackendtrait definition and dispatch - TPM – Complementary platform-binding factor
- Policy Engine – Combining SED with other factors
Federation Factors
Status: Design Intent. No
AuthFactorIdvariant orVaultAuthBackendimplementation exists for federation today. Federation is a future capability that builds on top of the existing factor backends. This page documents the design intent for cross-device factor delegation.
Federation factors allow a user to satisfy an authentication factor on one device and have that satisfaction count toward unlocking a vault on a different device. This enables scenarios such as unlocking a headless server’s vault using a phone’s fingerprint sensor, or centrally managing vault unlock across a fleet of machines via an HSM.
Core Concepts
Factor Delegation
Factor delegation separates where a factor is satisfied from where the vault is unlocked:
- Origin device: The device where the user physically performs authentication (touches a FIDO2 key, scans a fingerprint, enters a password).
- Target device: The device where the vault resides and where daemon-secrets runs.
- Delegation token: A cryptographic proof that a specific factor was satisfied on the origin device, valid for a bounded time and scope.
The delegation token does not contain the master key. It is an authorization proof that daemon-secrets on the target device accepts in lieu of direct local factor satisfaction.
Trust Chain
Federation introduces a multi-hop trust chain:
Device Attestation -> Factor Proof -> Delegation Token -> Vault Unlock
- Device attestation. The origin device proves its identity and integrity to the target device. This may use TPM remote attestation, a pre-shared device certificate, or a Noise IK session where the origin device’s static public key is pre-enrolled.
- Factor proof. The origin device satisfies a factor locally (e.g., fingerprint verification via fprintd) and produces a signed statement: “factor F was satisfied by user U at time T on device D.”
- Delegation token. The factor proof is wrapped into a delegation token that specifies the target vault, permitted operations, expiration time, and scope restrictions.
- Vault unlock. The target device’s daemon-secrets receives the delegation token, verifies the full chain (device identity, factor proof signature, token validity, scope), and uses it to authorize the unlock.
Delegation Token Structure
Version: u8 (1)
Token ID: 16 bytes (random, for revocation and audit)
Origin device ID: 32 bytes (public key fingerprint or device certificate hash)
Factor ID: AuthFactorId (which factor was satisfied)
Factor proof signature: length-prefixed bytes (signed by origin device's attestation key)
Timestamp: u64 (Unix epoch seconds when factor was satisfied)
Expiry: u64 (Unix epoch seconds when token becomes invalid)
Target vault: length-prefixed UTF-8 (profile name on target device)
Scope: DelegationScope (see below)
Token signature: length-prefixed bytes (signed by origin device's delegation key)
DelegationScope
Delegation tokens carry explicit scope restrictions that limit what the token can authorize:
#![allow(unused)]
fn main() {
struct DelegationScope {
/// Which operations the token authorizes.
allowed_operations: Vec<DelegatedOperation>,
/// Maximum number of times the token can be used (None = unlimited within expiry).
max_uses: Option<u32>,
/// If set, token is only valid from these source IP addresses.
source_addresses: Option<Vec<IpAddr>>,
}
enum DelegatedOperation {
/// Unlock the vault (read access to secrets).
VaultUnlock,
/// Unlock and modify secrets.
VaultUnlockWrite,
/// Unlock a specific secret by path.
SecretAccess(String),
}
}
Scope Narrowing
A delegation token can only have equal or narrower scope than the factor it represents. Scope narrowing is enforced at token creation time:
- A password factor with full vault access can delegate a token that only unlocks specific secrets.
- A biometric factor can delegate a token valid for 5 minutes instead of the session duration.
- A FIDO2 factor can delegate a token restricted to a single use.
Scope can never be widened. A token scoped to SecretAccess("/ssh/id_ed25519") cannot be
used to unlock the entire vault.
Relationship to VaultAuthBackend
Federation does not implement VaultAuthBackend directly. Instead, it wraps existing
backends:
- On the origin device, a standard
VaultAuthBackend(fingerprint, FIDO2, password, etc.) performs the actual authentication. - The origin device’s federation service creates a delegation token signed with the device’s attestation key.
- On the target device, a
FederationReceivercomponent (a new daemon component, not aVaultAuthBackend) validates the token and translates it into an internal unlock authorization.
The target device’s daemon-secrets treats a validated delegation token as equivalent to a
local factor satisfaction for policy evaluation purposes. If the vault’s
AuthCombineMode::Policy requires AuthFactorId::Fingerprint, a delegation token proving
fingerprint satisfaction on a trusted origin device satisfies that requirement.
IPC Flow
Origin Device Target Device
───────────── ─────────────
User touches fingerprint sensor
|
v
FingerprintBackend.unlock() succeeds
|
v
FederationService creates
delegation token
|
v
Noise IK session ──────────────────> FederationReceiver
|
v
Verify device attestation
Verify factor proof signature
Check token expiry and scope
|
v
daemon-secrets accepts
factor as satisfied
|
v
Policy engine evaluates
(may need more factors)
|
v
Vault unlocked (if policy met)
FactorContribution
Federation does not change the FactorContribution type of the underlying factor. If the
delegated factor provides FactorContribution::CompleteMasterKey locally, the delegation
token authorizes release of the same master key on the target device (which must have its
own wrapped copy from a prior enrollment of that factor type).
In AuthCombineMode::All, federation cannot provide a FactorPiece remotely because the
piece must be combined locally with other pieces on the target device. Federation in All
mode requires the origin device to contribute its piece to a multi-party key derivation
protocol. This is deferred to a future design iteration (see Open Questions).
Use Cases
Unlock Server Vault from Phone
A developer manages secrets on a headless server. The server vault requires fingerprint +
password (AuthCombineMode::Policy, both required). The developer:
- Scans a fingerprint on their phone (origin device).
- The phone creates a delegation token for the server vault, scoped to
VaultUnlock, expiring in 60 seconds. - The token is sent to the server over a Noise IK session (phone’s static public key is pre-enrolled on the server).
- The server’s daemon-secrets accepts the fingerprint factor as satisfied.
- The developer enters a password directly on the server (or via SSH).
- Both policy requirements are met; the vault unlocks.
Fleet Unlock via Central HSM
An organization operates a fleet of machines, each with a vault. A central HSM holds a master delegation key. An administrator:
- Authenticates to the HSM management interface (FIDO2 + password).
- The HSM creates delegation tokens for a set of target machines, each scoped to
VaultUnlock, expiring in 5 minutes. - Tokens are distributed to target machines via the management plane.
- Each machine’s daemon-secrets validates the token against the HSM’s pre-enrolled public key.
- Vaults unlock. The HSM never sees the vault master keys.
Emergency Break-Glass
A break-glass procedure for when normal factors are unavailable:
- An administrator authenticates to a break-glass service using a hardware token.
- The service creates a single-use delegation token (
max_uses: 1) for the target vault. - The token is transmitted to the target device.
- The vault unlocks once. The token is consumed and cannot be reused.
- All break-glass events are audit-logged with the token ID, origin device, and administrator identity.
Remote Attestation
Before a target device accepts a delegation token, it must verify that the origin device is trustworthy. Remote attestation provides this assurance.
Device Identity
Each device in the federation has a long-lived identity key pair. The public key is enrolled on peer devices during a setup ceremony. Options for the identity key:
- TPM-backed key. The device’s TPM generates a non-exportable attestation key. The public portion is enrolled on peers. This proves the origin device has not been cloned.
- Noise IK static keypair. The existing Open Sesame Noise IK transport provides mutual authentication. The origin device’s static public key is already known to the target device from IPC bus enrollment.
- X.509 certificate. A CA-issued device certificate, validated against a pinned CA public key. Suitable for organizational deployments with existing PKI.
Platform State Attestation
Optionally, the origin device can include a TPM quote (signed PCR values) in the delegation token, proving its boot integrity at the time of factor satisfaction. The target device verifies the quote against a known-good PCR policy. This prevents a compromised origin device from generating fraudulent factor proofs.
Time-Bounded Delegation Tokens
All delegation tokens have mandatory expiration:
- Minimum expiry: 10 seconds (prevents creation of tokens that expire before delivery).
- Maximum expiry: Configurable per-vault, default 300 seconds (5 minutes). Longer durations increase the window for token theft and replay.
- Clock skew tolerance: 30 seconds. The target device accepts tokens where
now - 30s <= timestamp <= now + 30sandnow <= expiry + 30s.
Token expiry is checked at the target device at time of use. A token that was valid when created but has since expired is rejected. There is no renewal mechanism; a new factor satisfaction and new token are required.
Replay Prevention
Each token has a unique random 16-byte ID. The target device maintains a set of consumed token IDs (in memory, persisted to disk for crash recovery). A token ID that has been seen before is rejected, even if the token has not expired.
The consumed-ID set is pruned of entries older than max_expiry + clock_skew_tolerance to
bound memory usage.
Security Considerations
- Token theft. A stolen delegation token can be used by an attacker within its validity
window and scope. Mitigations: short expiry, single-use tokens (
max_uses: 1), source address restrictions, and Noise IK transport encryption (tokens are never sent in plaintext). - Origin device compromise. If the origin device is compromised, an attacker can generate arbitrary delegation tokens. Mitigations: TPM-backed attestation keys (attacker cannot extract the signing key without hardware attack), platform state attestation (compromised boot state is detected), and administrative revocation of the device’s enrollment on all target devices.
- Target device compromise. If the target device is already compromised, delegation tokens are irrelevant – the attacker already has access to the running system. Federation does not increase or decrease the attack surface of a compromised target.
- Network partition. If origin and target devices cannot communicate directly, the token must be relayed through an intermediary. The token’s cryptographic signatures ensure integrity regardless of the relay path, but relay latency may cause expiry. Pre-generating tokens with longer expiry is an option for intermittently-connected environments.
- Scope escalation. The scope narrowing invariant (delegation can only narrow, never widen) is enforced at token creation on the origin device and verified at the target device. A malicious origin device could create a token with any scope up to the full permissions of the delegated factor – this is inherent to the delegation model. Trust in the origin device is a prerequisite for accepting its tokens.
Open Questions
AuthCombineMode::Allsupport. Federation inAllmode requires multi-party key derivation where the origin device contributes its piece without revealing the combined master key. Threshold secret sharing or secure multi-party computation protocols may be needed.- Token revocation broadcast. How does a target device learn that a token has been revoked before its natural expiry? Options include a revocation list pushed via the management plane, or making tokens short-lived enough that revocation is unnecessary.
- Multi-hop delegation. Can device A delegate to device B, which then re-delegates to device C? The current design does not support transitive delegation. Each token is signed by the origin device and validated against that device’s enrolled key directly.
- Offline token pre-generation. For air-gapped environments, tokens may need to be generated in advance with longer validity. This increases the theft window and requires careful scope restriction.
See Also
- Factor Architecture –
VaultAuthBackendtrait definition and dispatch - Policy Engine – How delegated factors interact with
AuthCombineMode - Biometrics – Common delegation source (phone fingerprint)
- TPM – Remote attestation for device identity
Window Manager Daemon
The daemon-wm process implements a Wayland overlay window switcher with mnemonic letter hints,
application launching, and inline vault unlock. It runs a single-threaded tokio runtime
(current_thread) connected to the IPC bus as a BusClient, plus two OS threads: the overlay
(overlay-sctk) and the window list poll (wm-winlist-poll).
Event Loop
main.rs drives a core_daemon::EventLoop. Each iteration wakes for one of:
| Wake | Source | Handling |
|---|---|---|
Wake::Message | IPC bus | Runtime::message: overlay activations, InputKeyEvent, WmListWindows, WmActivateWindow |
Wake::Own(Local::Overlay(Some(event))) | Overlay thread | Runtime::overlay_event: keyboard events, dismissal |
Wake::Own(Local::Overlay(None)) | Overlay thread exited | Runtime::overlay_died: discard the activation, release the keyboard, schedule a respawn |
Wake::Own(Local::Respawn) | Respawn timer (2 s) | Runtime::respawn_overlay: a new overlay thread |
Wake::Own(Local::Deadline) | controller.next_deadline() | Event::DwellTimeout |
Wake::Own(Local::CompositorLost) | Window list poll thread | The daemon stops with an error; systemd restarts it |
Wake::ConfigReloaded | Configuration watcher | Runtime::reconfigure: new WmConfig, new theme, ConfigReloaded announced |
Wake::Shutdown | SIGTERM/SIGINT | The overlay thread quits; DaemonStopped announced |
serve::Respawns::next orders the daemon’s own sources: a lost compositor first, then the
pending respawn while the overlay thread is dead (otherwise its next event), then the
controller deadline. An overlay thread that dies more than 5 times within 2 minutes stops the
daemon for a systemd restart. A bus connection loss is an error from the event loop and stops
the daemon the same way.
Controller State Machine
The OverlayController (controller.rs) is the single owner of all overlay state, timing, and
decisions. Runtime::handle feeds it an Event, and Runtime::execute performs the returned
Command list in order. The controller performs no I/O.
Phases
- Idle – Nothing happening. No overlay visible, no timers running.
- Armed – The overlay surface is mapped but draws nothing, holding keyboard exclusivity.
The controller waits for a modifier release (quick-switch) or the dwell deadline (Picking).
Carries
entered_at, theSnapshot,selection,family,dwell_ms, and an optional pendingLaunchRequest. - Picking – The picker is visible. The user cycles through the windows or types an app
key to narrow them to its family. Carries the
Snapshot,selection,family, an optional pending launch, andreveal: while?reveals the launches, the selection before it did. - Launching – A
LaunchExecuterequest is in flight todaemon-launcher. - LaunchError – A launch failed. The overlay shows the reason; any key dismisses.
- Unlocking – Vault unlock in progress:
profiles_to_unlock,current_index,password_len,unlock_mode(Resolving,Password,Verifying), and theLaunchRequestretried after unlock.
In Armed and Picking, selection indexes every entry of the snapshot (its windows, then its
launches) and family is the app key the picker is narrowed to (None for every window).
Events
| Event | Source | Description |
|---|---|---|
Activate | IPC WmActivateOverlay | Forward activation (Alt+Tab) |
ActivateBackward | IPC WmActivateOverlayBackward | Backward activation (Alt+Shift+Tab) |
ActivateLauncher | IPC WmActivateOverlayLauncher | Launcher mode ([global] launcher_key, default Alt+Space) |
ActivateLauncherBackward | IPC WmActivateOverlayLauncherBackward | Launcher mode, backward (launcher key with Shift) |
ModifierReleased | Overlay keyboard or IPC InputKeyEvent | The last cycle modifier (Alt, Super, Control) released |
Char(char) | Overlay or IPC key event | An app key typed (alphanumeric characters are kept), or ?: reveal or hide the launches |
Backspace | Overlay or IPC key event | Backspace: widen to every window |
SelectionDown / SelectionUp | Overlay or IPC key event | Arrow navigation |
Confirm | Overlay or IPC key event | Enter |
Escape / Dismiss | Overlay or IPC key event / stale activation | Cancel |
DwellTimeout | Controller deadline | Dwell expired |
LaunchResult | Launch executor | The LaunchOutcome of a request |
UnlockStatus | Unlock executor | Where a vault’s unlock stands: Unlocked, NeedsPassword { error }, or Failed { message } |
The four activations are core_types::OverlayRequest, the one definition of each request’s bus
event, shortcut id (the sesame wm overlay fast-path datagram and the GlobalShortcuts portal id),
description, sesame command arguments, and shortcut (OverlayRequest::trigger). The shortcuts
reach daemon-wm through the session’s keybinding backend (Linux
Platform).
Transitions
Idle ──Activate──> Armed ──DwellTimeout──> Picking
| |
|──Activate──> Picking |──Activate──> Picking (selection cycles)
| |
|──Char / Selection──> Picking
| |──?──> Picking (launches revealed, or hidden)
| |──ModifierReleased──> Idle (activate selection)
| |──Confirm──> Idle (activate selection)
| |──Escape──> Idle
|
|──ModifierReleased──> Idle (quick-switch or selection)
+──staged launch + ModifierReleased / Confirm──> Launching
Launching ──LaunchResult(Launched)──> Idle
Launching ──LaunchResult(VaultsLocked)──> Unlocking
Launching ──LaunchResult(other)──> LaunchError ──any key──> Idle
Unlocking ──UnlockStatus(Unlocked)──> next profile or Launching (retry)
Unlocking ──UnlockStatus(NeedsPassword)──> password prompt (with the error, if any)
Unlocking ──UnlockStatus(Failed)──> LaunchError
Unlocking ──Escape──> Idle
An activation in Launching, LaunchError, or Unlocking is ignored.
Snapshot
A fresh activation builds a Snapshot that carries all window data through the overlay
lifecycle:
- MRU entries for windows that no longer exist are pruned.
- The window list is MRU-ordered (
mru::reorder) and truncated tomax_visible_windows(default 20). - The origin, the window the compositor reports focused, is moved to the last index. With no focused window (an empty workspace) there is no origin, and the most recently used window is the quick-switch target.
- Badges are computed with
hints::badges(see Hints), parallel to the window list, with the overlay rows (WindowInfo:app_id,title), from the key bindings the Runtime passes: each role completed from the latest default applications (WmConfig::with_default_apps), and the dynamic keys of the open applications (hints::KeyRegistry, in the order the window list poll first saw each open). - After the windows, one entry per launch a key would stage (
hints::launch_keys, see Revealed Launches), its badge every key that stages it, its overlay row the launch command and the application’s name. - Those key bindings are copied for families and focus-or-launch.
The snapshot reads recency and writes none: the MRU stack is the compositor’s focus history, recorded from its activation reports (see MRU Stack), so the window focused before the current one is the quick-switch target however focus moved.
Keyboard actions only update the selection, the family, and the revealed launches. Every
ShowPicker and UpdatePicker carries the rows the controller computed (Snapshot::rows: the
family’s windows by the family rule, then, revealed, its launches) as the
rows the overlay draws, and the selection, an index into every entry, so the highlighted row is
the one a release or Enter commits (OverlayController::commit: the staged launch, then a
revealed launch row, otherwise the window).
Before every activation, Runtime::activate asks the poll thread for a fresh window list,
waiting up to 200 ms (FRESH_WINDOWS_WAIT) so windows closed since the last poll are not
offered. A fresh activation (from Idle) also re-reads the theme (dark/light, accent, and
frosted-glass changes apply without a restart) and, within the same wait, asks daemon-launcher
which application each desktop role resolves to (LaunchDefaultApps, see Default
Applications), so a default changed in the
desktop’s settings applies at the next activation. Without an answer in time the previous
resolution stands; before the first answer, role keys have no application.
Families
Typing an app key narrows the picker to that key’s family and selects its most recent window
other than the origin (Snapshot::family_entry). Every later motion – the same key again, a
reactivation, SelectionDown/SelectionUp – steps within the family the picker is narrowed
to (Snapshot::step), wrapping. Another key switches family; Backspace widens back to every
window and keeps the selection. ? reveals the launches as rows after the windows, which every
motion then steps through too; ? again hides them. Hints lists each
input’s effect.
Quick-Switch
On ModifierReleased in Armed, the controller activates initial_forward() (the MRU previous
window) when all of these hold:
- Less than
dwell_mshas elapsed sinceentered_at. - No app key has been typed (the picker is not narrowed).
- The selection has not moved from
initial_forward().
Otherwise it activates the current selection. A fast Alt+Tab release therefore switches to the previous window without the picker ever drawing.
Dwell
controller.next_deadline() returns entered_at + dwell_ms in Armed. dwell_ms is:
quick_switch_threshold_ms(default 250) for forward and backward activation.min(overlay_delay_ms, 100)for launcher activation: a short dwell that lets the compositor grant keyboard exclusivity before the first keypress. Launcher mode activates even with no windows; the switcher modes require at least one.
At the deadline, on_dwell_timeout() enters Picking and shows the picker.
Reactivation
An activation while Armed or Picking (a repeated Alt+Tab or launcher key the compositor
intercepted) moves the selection one step in its direction within the family the picker is
narrowed to (every window when it is not), wrapping, enters Picking, and emits
Command::ResetGrace so the overlay’s modifier grace period restarts (the shortcut’s modifier
is still held). The restart keeps the activation’s confirmed keyboard source (compositor or IPC)
and its last input; only the grace and timeout clocks start again. The advance is timestamped:
one SelectionDown/SelectionUp within 100 ms (REACTIVATION_DEDUP) is the same keystroke
arriving through the keyboard and is suppressed.
Staged Launch
When a typed key has no open window and its binding has a launch command
(hints::binding_for_key), the controller narrows to the key’s empty family, stages a
LaunchRequest (command, tags, launch args), and emits Command::ShowLaunchStaged. The launch
is not executed yet:
- ModifierReleased or Confirm with a staged launch enters Launching and emits
Command::ShowLaunchingandCommand::LaunchApp. - A key with open windows replaces the staged launch with its family; Backspace cancels it.
- Escape dismisses the overlay.
Runtime::launch_app releases the keyboard grab, sends LaunchExecute under the configured
default profile with a 10-second timeout (LAUNCH_TIMEOUT), and feeds the outcome back as
Event::LaunchResult. An unanswered request is LaunchOutcome::Failed.
Overlay Thread
surface::wayland::spawn_overlay starts the overlay-sctk thread, themed and laid out from
WmConfig. The daemon sends it OverlayCmd over std::sync::mpsc and receives
OverlayEvent over a tokio channel (capacity 64).
Layer-Shell Surface
OverlayApp::recreate_layer_surface creates a zwlr_layer_shell_v1 surface:
Layer::Overlay, namespacesesame, anchored to all four edges, exclusive zone-1.- Keyboard interactivity
Noneand an empty input region while hidden or armed, so the surface takes no input until it is shown. - An
ext_background_effect_surface_v1object for blur when the compositor offersext_background_effect_manager_v1.
Loop
run_sctk_overlay repeats until Quit, a dropped command channel, or a failed Wayland
connection:
- Flush requests, poll the display fd for up to 4 ms (
POLL_TIMEOUT), read, and dispatch. - Apply every queued
OverlayCmd. - Poll the activation (modifier release, stale activation).
- Render when the view changed.
Without wl_compositor or wl_shm the thread ends. Without a layer shell it runs a stub loop
that answers activations with Dismiss and HideAndSync with SurfaceUnmapped, so the daemon
never waits on a surface that does not exist.
Views
The overlay shows one View: Hidden, Border (armed: an invisible surface holding the
keyboard), Picker, Launching, LaunchError, UnlockPrompt, or UnlockProgress.
| Command | Effect |
|---|---|
ShowBorder | Starts an activation, view Border, keyboard Exclusive |
ShowFull { windows, hints, family, rows, selection } | View Picker of every entry (the windows, then the launches) and its badge, narrowed to family, drawing the entries rows, entry selection selected (starts an activation when none is running) |
UpdatePicker { family, rows, selection } | Picker narrowed to family, drawing the entries rows, with entry selection selected; clears the staged launch |
ShowLaunchStaged { command } | Picker shows Launch <command> when the family has no window |
ShowLaunching / ShowLaunchError | Launch status views |
ShowUnlockPrompt / ShowUnlockProgress | Unlock views (the prompt receives password_len, never password bytes) |
Hide | View Hidden: keyboard None, empty input region, no blur |
HideAndSync | Hide, then SurfaceUnmapped to the daemon |
ResetGrace | Restarts the activation’s grace period |
ConfirmKeyboardInput | Keyboard input arrives over IPC this activation |
Reconfigure { theme, columns, reply } | New renderer settings, redraw; acknowledged on reply when given (a configuration application) |
Quit | The thread ends |
Runtime::hide_and_sync releases the keyboard grab, sends HideAndSync, and waits up to
5 seconds (UNMAP_TIMEOUT) for SurfaceUnmapped before a window is activated, so the window
activated next receives focus from an overlay already gone.
Activation Polling
poll::Activation tracks the keyboard source of one activation (Unconfirmed, Compositor,
or Ipc) and reports at most one end:
- No key event within 3 seconds (
STALE_ACTIVATION_TIMEOUT):Dismiss. While unconfirmed, the overlay re-requests exclusive keyboard focus on every poll. - IPC keyboard but no input within 30 seconds (
IPC_IDLE_TIMEOUT):Dismiss. - Compositor keyboard, past the 150 ms grace period (
MODIFIER_POLL_GRACE), no cycle modifier held:ModifierReleased. This catches a release made before keyboard focus arrived. A cycle modifier held again rearms the release.
The cycle modifiers are Alt, Super, and Control (core_types::keysym::CYCLE_MASK); Shift only
reverses the direction. The keyboard handler tracks whether one is held (cycle_held):
- Enter: from the keys pressed as focus arrives.
- Modifiers: from the compositor’s modifier state. The update that leaves no cycle modifier
held reports
ModifierReleasedat once. The modifier state is the one source of the release: releasing Alt while Super is still held ends nothing. - Leave: nothing is held. Losing focus while a view is shown dismisses the overlay
(
Dismiss): the release that ends the cycle can no longer reach it.
The overlay keyboard and IPC report one release under one deduplicator key (CYCLE_END),
whichever modifier was released last; a release outside Armed and Picking does nothing.
Scale and Buffers
The output scale comes from SCTK’s scale_factor_changed (the preferred buffer scale on
wl_surface v6, the largest output scale otherwise). The buffer is the configured logical size
times the scale, in a shm SlotPool resized with the surface.
Rendering
render::Canvas draws one frame on a transparent tiny_skia::Pixmap (tiny-skia zero-fills
it, so the Armed view draws nothing). Each view returns the card it drew:
- Picker: a centered card with one row per entry of the picker’s
rows: the badge on the left, every key that selects the window or launches the application (the matched colors for a narrowed family’s rows), then the app name column (show_app_id) and the title column (show_title, ellipsized; a revealed launch’s names the application). The selected row gets the selection wash. The card holds at most the rows that fit 80% of the screen height (Layout::max_rows); with more, it shows the rows from the first while the selected row fits, else the rows ending at it, so the selection is always in view. The family key shows in a pill below the card. A family without rows showsLaunch <command>for a staged launch. - Messages: launch status, launch errors, the unlock prompt (one dot per character, at most 32), and unlock progress, each on a centered card.
Layout metrics (render::layout::Layout) follow a 4-point grid in logical pixels – padding 20,
row height 48, row spacing 8, badge 48x32 with radius 8 (every badge widened to fit the longest
badge of the rows drawn, plus padding), app column 180, text 16, column gap 16, card outline
1 – scaled by the output scale. Text is shaped and rasterized with cosmic-text
(FontSystem, SwashCache) in the theme’s font family.
render_frame::present attaches the ARGB8888 buffer, sets the buffer scale and damage, sets the
blur region behind the drawn card (converted to surface-local logical coordinates), and commits
once: the blur region is double-buffered state applied by that same commit.
Theme
OverlayTheme holds card_background, card_border, text_primary, text_secondary,
badge_background, badge_text, badge_matched_background, badge_matched_text,
selection_highlight, corner_radius, and font_family. OverlayTheme::from_config builds
it in priority order:
- COSMIC system theme (
platform_linux::cosmic_theme::CosmicTheme): primary, accent, and secondary component colors, the medium corner radius, and the interface font. The card is translucent so the compositor blur shows through: the theme’s blurred alpha when frosted, half opacity otherwise. - Configuration: each
WmConfigcolor set to other than its default overrides the theme (card_color,border_color,text_color,hint_color,hint_matched_color). - Defaults when no COSMIC theme is available.
Colors are CSS hex (#RRGGBB or #RRGGBBAA) parsed by Color::from_hex.
MRU Stack
mru::MruStore keeps the most-recently-used window stack in the file Layout::mru_file
names: one window ID per line, most recent first, capped at 64 entries.
It has one writer: winlist::record_activations saves each window the compositor backend
reports activated (Linux Platform), in order, from
the window focused when the backend connects onward. Every focus change is recorded, whether by
pointer, keyboard shortcut, a newly mapped window, a workspace switch, or daemon-wm’s own
activation. The file persists history across daemon restarts; COSMIC window IDs are stable
across them.
load()reads under a sharedflock; a missing file is an empty stack.save(target)movestargetto the top under an exclusiveflock.prune(live_ids)drops entries for windows that no longer exist.reorder(windows, get_id, state)sorts by stack position; windows not in the stack keep their compositor order after the tracked ones.
The stack orders the overlay and is not authoritative: MruStore logs I/O failures and
degrades to an empty stack or an unchanged file.
Inline Vault Unlock
A launch denied with LaunchDenial::VaultsLocked { locked_profiles } enters Unlocking without
dismissing the overlay, keeping the LaunchRequest for the retry.
- Resolve (
Command::ResolveUnlock):Runtime::resolve_unlockshows “Authenticating” and runs the unlock loop of Factor Architecture: it asksdaemon-secretswhich factors the vault still requires (VaultAuthQuery, 5-secondQUERY_TIMEOUT), looks each one up (AuthDispatcher::backend), and submits every factor that needs no interaction (the SSH agent) as aFactorSubmit(30-secondFACTOR_TIMEOUT) under the vault’s keying (core_auth::VaultMetadata::load_keying). The platform keyring factor is submitted by daemon-launcher (KeyringUnlockRequest, 2-minuteKEYRING_TIMEOUT: the keyring’s own unlock prompt may wait for the user), because the credential store is on the session D-Bus bus, which this daemon’s sandbox does not grant.daemon-secretsapplies the vault’s auth policy. The result is anEvent::UnlockStatus:Unlockedwhen a submission completed the unlock (or the vault already was unlocked);NeedsPasswordwhen a remaining factor is the password;Failedwhen the vault requires a factor the overlay cannot provide (no backend, or a hardware touch), its metadata or enrollment is unreadable, or no factor is available. The overlay shows the message as a launch error.
- Password: the controller enters
Passwordand shows the prompt. Characters go to the runtime’sSecureVecpassword buffer; the overlay receives only the length. - Submission (
Command::SubmitPasswordUnlock):Runtime::submit_password_unlockshows “Verifying”, moves the buffer intocore_auth::PasswordBackend(the runtime keeps a fresh empty buffer), unwraps the master key, and submits it as a factor. A password that does not unwrap the key shows the prompt again with “Wrong password”; a factordaemon-secretsrejects shows its reason. An accepted password of a vault whose policy requires more factors resolves the remaining factors (step 1) instead of reporting a wrong password. - Next profile: after each unlock the next locked profile starts at step 1. A status for any profile but the one being unlocked is ignored.
- Retry: with every profile unlocked, the controller emits
Command::ActivateProfiles(ProfileActivateper profile, 10-secondACTIVATE_TIMEOUT) andCommand::LaunchAppwith the original request.
Escape in Unlocking clears the password buffer and dismisses the overlay. The password buffer
is pre-allocated and mlocked (SecureVec::for_password) and never leaves the daemon thread.
Keyboard Input
Key events arrive from two sources:
- The overlay keyboard: the layer surface’s SCTK
KeyboardHandlerwhile it holds exclusive focus, sent asOverlayEvents. - IPC
InputKeyEvent:daemon-inputforwards evdev key events while this daemon holds a grab.ipc_keys::map_ipc_key_to_eventmaps X11 keysyms (core_types::keysym) to controller events; Tab is ignored (cycling comes from reactivation). Of releases only the one that ends the cycle counts: a cycle modifier released with no other cycle modifier in the event’s mask (keysym::ends_cycle).
Both pass through one KeyDeduplicator (8 recent entries, 50 ms window, direction-aware), so
the first arrival of each keystroke is handled. Command::ShowBorder publishes
InputGrabRequest; hiding publishes InputGrabRelease (before the overlay hides). The first
IPC key event of an activation sends ConfirmKeyboardInput. A launcher activation with no
windows confirms IPC input at once: the compositor grants no focus without a toplevel.
Window List
When platform_linux::compositor::detect_compositor finds a backend, its activation reports
feed the MRU stack and the wm-winlist-poll thread re-enumerates every 2 seconds
(POLL_INTERVAL) and on request (Refresh::fresh); the compositor backend’s synchronous
Wayland roundtrips would otherwise stall the single-threaded runtime. After 10 consecutive
failed enumerations (MAX_FAILURES) the compositor connection is dead: the thread reports it
(Refresh::lost), and the event loop stops the daemon with an error for a systemd restart.
Without a backend no window is listed or activatable; the launcher still launches.
Window activation (Runtime::activate_window) sends the backend’s activate_window on the
blocking pool; the compositor’s activation report then records the window in the MRU stack.
Without a backend, or when the request cannot be delivered, the activation fails
(WmActivateWindowResponse { success: false }).
IPC Interface
| Message | Response | Description |
|---|---|---|
WmListWindows | WmListWindowsResponse { windows } | The MRU-ordered window list |
WmActivateWindow { window_id } | WmActivateWindowResponse { success } | Activates the window with that ID or app ID |
WmActivateOverlay | – | Forward activation |
WmActivateOverlayBackward | – | Backward activation |
WmActivateOverlayLauncher | – | Launcher activation |
WmActivateOverlayLauncherBackward | – | Launcher activation, backward |
InputKeyEvent | – | Key event from daemon-input (handled only while not idle) |
The daemon publishes WmOverlayShown on activation and WmOverlayDismissed when the overlay
closes.
Process Hardening
platform_linux::security::harden_process()and resource limits (nofile = 4096,memlock_bytes = 0).core_types::init_secure_memory()probesmemfd_secretbefore the sandbox.daemon_wm::sandbox::apply_sandboxapplies Landlock and seccomp on the only thread, before the runtime, configuration watcher, Wayland, and overlay threads start. The grants are the bus, the Wayland socket, configuration (read), SSH agent sockets, the systemd notification socket, the cache directory (MRU stack), COSMIC theme configuration, user data, and the system font, library, and XKB paths. There are no DRI or GPU grants (rendering is CPUwl_shm) and no D-Bus bus (Sandbox Model).platform_linux::systemd::notify_ready()at startup; the event loop sends watchdog notifications.
Configuration
WmConfig (core-config/src/schema_wm.rs), from the configured default profile:
| Field | Type | Default | Description |
|---|---|---|---|
hint_keys | String | "asdfghjkl" | Keys for apps with no key binding and no free letter in their name |
overlay_delay_ms | u32 | 150 | Launcher dwell bound (the launcher dwell is min(overlay_delay_ms, 100)) |
quick_switch_threshold_ms | u32 | 250 | Release within this time switches instantly; the switcher dwell |
border_color | String | "#89b4fa" | Card outline color |
card_color | String | "#1e1e1ef0" | Card background color |
text_color | String | "#ffffff" | Text color |
hint_color | String | "#646464" | Hint badge color |
hint_matched_color | String | "#4caf50" | Hint badge color of a narrowed family’s rows |
key_bindings | BTreeMap | (see Hints) | Per-key app bindings and launch commands |
show_title | bool | true | Title column |
show_app_id | bool | false | App name column |
max_visible_windows | u32 | 20 | Windows in the picker |
On a configuration reload the daemon adopts the new WmConfig, sends the overlay its theme, and
announces ConfigReloaded.
Dependencies
Workspace crates: core-types, core-config, core-daemon, core-layout, core-ipc,
core-crypto, core-auth. On Linux: platform-linux (with cosmic),
smithay-client-toolkit, wayland-client, wayland-protocols, tiny-skia, cosmic-text,
and rustix.
Hint Assignment
The hints module (daemon-wm/src/hints.rs) gives every window a badge: every key that selects
it. Typing a key narrows the picker to that key’s family, and the switcher’s own cycling then
moves within it, so one key and the usual Alt+Tab motion reach any window of an application
however many are open. The same key launches the application when no window of it is open
(focus-or-launch), and ? in the picker reveals those launches as rows of their own.
Badges and Keys
One map binds keys to applications: the static bindings (Key Bindings:
configuration over the compiled defaults, roles resolved) and the dynamic keys below. A
window’s badge is every key whose binding covers its application (hints::badges), and a key
selects exactly the windows its binding covers (hints::members). So every key a badge shows
selects that window, and every key that selects a window is on its badge. An application bound
to more than one key shows them all: with the web-browser role resolved to Edge, Edge windows
show EW, and e and w each narrow to them. Each alias spends a key that no other
application can have.
Dynamic Keys
An application no static binding covers gets a dynamic key when daemon-wm first sees it open
(hints::KeyRegistry), and keeps it until its last window closes:
- Every enabled static key is reserved, whether or not its application is open; a key turned
off (
enabled = false) is free. - Applications are keyed in the order they were first seen open (
winlist::OpenOrder, kept from every window list poll); applications first seen in the same poll, such as at daemon start, in name order. - Each takes the first letter of its name (the last reverse-DNS segment, lowercased) that is
neither reserved nor held by an application opened before it: its initial, else its next
free letter. Without one, it takes the first free
hint_keyskey; without one, it has no key, shows·, and is reached by cycling. - A key held is never taken by an application opened later, whatever opens or closes around it. A configuration that comes to bind the key or the application takes it back.
With no static f or b, foo and bar opened take f and b; fizz and buzz opened next take
i and u; bop and fop opened next take o and p.
hint_keys (default "asdfghjkl") must be a non-empty set: configuration validation reports
an error for an empty pool or a repeated key.
Families
members(family, app_ids, key_bindings) is the one definition of a family: the windows the
key’s binding covers, or every window when the picker is not narrowed, in window order. The
controller cycles through these windows and sends them to the overlay as the rows it draws, so
the rows drawn are the rows cycled and the highlighted row is the window a commit activates.
Window order is recency order with the window you are on last (see Snapshot), so a family lists its windows from the most recently used to the least, the origin last:
| Input | Picker | Selection |
|---|---|---|
| A key | Narrowed to the key’s family | The family’s most recent window other than the origin |
| The same key again | Unchanged | One window on within the family, wrapping |
| Alt+Tab / Alt+Space again, Down | Unchanged | One window on within the family, wrapping |
| Shift with the activation, Up | Unchanged | One window back within the family, wrapping |
| Another key | Narrowed to that key’s family | That family’s most recent window other than the origin |
| Backspace | Every window | Unchanged |
| A key without windows, with a launch | Narrowed; shows Launch <command> (its row, revealed) | Unchanged (its row, revealed); the launch is staged |
| A key without windows or launch | Unchanged | Unchanged |
? | Reveals the launches after the windows; again, hides them | Unchanged; a selected launch row hidden returns to the selection before ? |
The modifier release or Enter commits the selection, or the staged launch. With twelve Edge
windows open, Alt+Space then w (or e, both on the Edge badges) narrows to Edge at the most
recent one, and each further Space, Tab, or w moves to the next Edge window in recency order.
Revealed Launches
? in the picker reveals what the keys imply but the window rows do not show: a row, after the
windows, for each application a key would launch because no window of its family is open
(hints::launch_keys, the keys with a launch whose family is empty). Each launch
is one row; its badge is every key that launches it, and its title column names the
application. The picker is otherwise unchanged: the rows are cycled, narrowed, and committed as
windows are, and the release or Enter on a revealed row launches it as its key would
(Focus-or-Launch). ? again hides them.
The revealed rows are read from the same key bindings, by the same family rule, as the badges and the keys: a key is on an open window’s badge or on a revealed row, never both, and a key that does nothing (turned off, or without a launch and without a window) is on neither.
Key Bindings
The key_bindings map in WmConfig maps a key to the applications it covers and what it
launches:
[profiles.default.wm.key_bindings.f]
apps = ["firefox", "org.mozilla.firefox"]
launch = "firefox"
A pattern of apps covers an application, ignoring case, when it equals the application ID or
the application’s name (org.mozilla.firefox is named firefox). Every key is exactly one
character: configuration validation reports an error for any other.
Roles
A binding with a role follows the desktop’s default application for that role:
[profiles.default.wm.key_bindings.w]
role = "web-browser"
daemon-launcher resolves each role (Default
Applications) when an activation starts
(Snapshot). The resolved
application’s window app IDs join the binding’s apps, and its desktop entry becomes the
launch when the binding names none. A role the desktop names no application for leaves the
binding as configured. The roles are web-browser, files, mail, music, video,
photos, calendar, terminal, text-editor, app-store, settings, and
system-monitor.
Default Key Bindings
The compiled key bindings are the lowest configuration layer:
| Key | Binding | Launch |
|---|---|---|
t | terminal role | the role’s application |
n | files role | the role’s application |
x | text-editor role | the role’s application |
w | web-browser role | the role’s application |
m | mail role | the role’s application |
u | music role, and spotify | the role’s application |
p | video role | the role’s application |
i | photos role | the role’s application |
k | calendar role | the role’s application |
a | app-store role | the role’s application |
o | settings role | the role’s application |
r | system-monitor role | the role’s application |
g | ghostty, com.mitchellh.ghostty | ghostty |
f | firefox, org.mozilla.firefox | firefox |
e | microsoft-edge, com.microsoft.Edge | microsoft-edge |
c | chromium, google-chrome | – |
v | code, Code, cursor, Cursor | code |
s | slack, Slack | slack |
d | discord, Discord | discord |
Stacking
Every layer stacks a key’s binding field by field, the compiled bindings as the lowest layer and the configuration files over them as every table stacks (see the README’s Configuration section): a field a layer sets replaces that field below it, and a field it leaves out keeps the value below. A key no layer binds keeps its compiled binding; an empty table changes nothing.
# w keeps following the web-browser role, but launches Firefox.
[profiles.default.wm.key_bindings.w]
launch = "firefox"
TOML has no null, so the two optional fields have a value that clears them, and enabled turns
a key off, freeing it for application initials:
| Field | Clears or turns off |
|---|---|
role | role = "none": the key follows no role |
launch | launch = "": the key focuses only |
enabled | enabled = false: the key neither focuses nor launches |
# w is Firefox whatever the desktop's default browser.
[profiles.default.wm.key_bindings.w]
role = "none"
apps = ["firefox", "org.mozilla.firefox"]
launch = "firefox"
# p is free for application initials.
[profiles.default.wm.key_bindings.p]
enabled = false
Focus-or-Launch
When a typed key has no window, the controller looks it up with
hints::binding_for_key(key, key_bindings) (case-insensitive). If the binding has a launch
command:
- A pending launch is staged with the binding’s command,
tags, andlaunch_args. - The overlay shows the staged intent (
Launch <command>), or, with the launches revealed, selects the key’s row. - The launch executes on modifier release or Enter (see Staged Launch).
A key with neither a window nor a launch command changes nothing.
Tags and Launch Args
Each WmKeyBinding can carry tags and launch_args:
[profiles.default.wm.key_bindings.g]
apps = ["ghostty"]
launch = "ghostty"
tags = ["dev-rust", "ai-tools"]
launch_args = ["--working-directory=/workspace"]
tagsare forwarded todaemon-launcherin theLaunchExecuteIPC message for launch profile composition (environment variable injection, secret fetching, Nix devshell activation). Tags support qualified cross-profile references using colon syntax (e.g.,"work:corp").launch_argsare appended to the launched command’s argument list.
Clipboard Daemon
The daemon-clipboard process captures the text selections of the Wayland clipboard into
per-profile history and serves that history over the Noise IK IPC bus. It runs a single-threaded
tokio runtime (current_thread) beside one capture thread, and connects to the bus as a
BusClient.
Capture
platform_linux::clipboard::spawn_capture watches the regular clipboard of the first seat through
wl-clipboard-rs’s Watcher, over ext-data-control-v1 or, when the compositor lacks it,
wlr-data-control-v1. cosmic-comp, sway, Hyprland, niri, and KWin offer data-control to clients
outside a security context; GNOME’s Mutter does not, and there the daemon serves history without
capturing (clipboard capture is off in its log). Without a Wayland session capture is off as
well.
For each new selection the watcher reads the text type wl-paste reads (select_mime_type with
MimeType::Text: text/plain;charset=utf-8, then UTF8_STRING, then any text type). A selection
is skipped when it offers no text, its text is not UTF-8, it exceeds 1 MiB, or its source does not
deliver it within 2 seconds. The watcher’s blocking wait runs on the clipboard-capture thread;
captures cross to the runtime over a channel. A Wayland failure after the start reconnects with
exponential backoff from 1 to 30 seconds.
The Profile an Entry Belongs To
A selection is filed under the default profile: the one daemon-profile reports in
StatusResponse when daemon-clipboard starts (the configured [global] default_profile when
daemon-profile does not answer within 5 seconds), then each DefaultProfileChanged daemon-profile
announces when the context engine or sesame profile default changes it. Only announcements whose
server-verified sender is daemon-profile are followed.
Entries carry the installation-scoped profile identity, ProfileId::of_profile (UUID v5 of
profile:<name> in the installation namespace of installation.toml), the identity daemon-profile
and the audit log use. Before sesame init writes the installation identity, nothing is recorded;
the identity is read again on every configuration reload.
Sensitivity
A selection whose source offers the password manager hint (x-kde-passwordManagerHint with the
content secret, as KeePassXC and other password managers set it) is a secret when the profile’s
clipboard.detect_sensitive is true:
- It is held in memory only, in protected memory (
SensitiveBytes), and is never written to the database. - Its preview is
[secret]; its content is served byClipboardGetuntil it expires. - It expires
clipboard.sensitive_ttl_sseconds after capture (ClipboardEntryExpiredis published); with a TTL of 0 it is not kept at all.
Every other selection is Public and persisted. A selection that repeats the profile’s newest
persisted entry (same text and type) is not recorded again, and after each insert the profile’s
history is pruned to its clipboard.max_history newest entries (0 records nothing). Each new entry
is announced as ClipboardChanged { entry_id, sensitivity, content_type, profile_id }.
Setting ([profiles.<name>.clipboard]) | Default | Effect |
|---|---|---|
max_history | 1000 | Persisted entries kept per profile |
sensitive_ttl_s | 30 | Seconds a secret is held |
detect_sensitive | true | Honor the password manager hint |
Storage
The database is <cache dir>/clipboard.db (core_layout::Layout::clipboard_db), by default
~/.cache/open-sesame/clipboard.db. Startup creates the parent directory when absent, opens the
database with rusqlite, and applies the schema idempotently:
CREATE TABLE IF NOT EXISTS clipboard_entries (
entry_id TEXT PRIMARY KEY,
profile_id TEXT NOT NULL,
content TEXT NOT NULL,
content_type TEXT NOT NULL DEFAULT 'text/plain',
sensitivity TEXT NOT NULL DEFAULT 'public',
preview TEXT NOT NULL,
timestamp_ms INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_clipboard_profile
ON clipboard_entries(profile_id, timestamp_ms DESC);
profile_id holds the entry’s ProfileId. The preview is the first 80 characters of the text,
with line breaks and other control characters shown as spaces. The index serves the per-profile,
most-recent-first history query and the pruning.
Decoding Rows
A row decodes into a ClipboardEntry strictly; a malformed value is an error, never a default:
entry_idandprofile_idmust be UUID strings.sensitivitymust be one of the labels below. An unknown label is an error: a value that cannot be classified is never downgraded toPublic.timestamp_msmust be non-negative.
| Label | SensitivityClass |
|---|---|
public | Public |
confidential | Confidential |
secret | Secret |
topsecret | TopSecret |
IPC Interface
| Message | Response | Behavior |
|---|---|---|
ClipboardHistory { profile, limit } | ClipboardHistoryResponse { entries } | The profile’s newest limit entries, held and persisted |
ClipboardGet { entry_id } | ClipboardGetResponse { content, content_type } | One entry’s content, or Nones |
ClipboardClear { profile } | ClipboardClearResponse { success } | Deletes the profile’s held and persisted entries |
History entries carry entry_id, profile_id, content_type, sensitivity, preview, and
timestamp_ms, but not content; ClipboardGet returns the content of one entry. History and
clear resolve the named profile to its ProfileId; ClipboardGet selects by entry_id alone: an
entry ID (clip-<uuid>, UUIDv7, as sesame clipboard history prints it) names its entry in any
profile.
A failed history query is logged and answered with an empty list; a failed clear, or a clear
before sesame init, is answered with success: false; a failed or empty get is answered with
None content and type. Responses carry the request’s message ID (Message::with_correlation).
The daemon ignores messages it published itself, and other message kinds.
Process Hardening
On Linux the daemon calls platform_linux::security::harden_process(), sets resource limits
(nofile = 4096, memlock_bytes = 0), probes memfd_secret (core_types::init_secure_memory()),
and applies a Landlock and seccomp sandbox built from the layout (core_daemon::sandbox) before
the runtime and the capture thread start:
- Bus client (
ipc_client_rules): the per-daemon key directory ($XDG_RUNTIME_DIR/pds/keys, read), the bus endpoint ($XDG_RUNTIME_DIR/pds/bus.endpoint, read), and the bus socket ($XDG_RUNTIME_DIR/pds/bus.sock, connect). - Configuration (
config_rules, read-only): the configuration directory (~/.config/pds, withinstallation.toml) and the directories its symlinks resolve into (for example/nix/store). - systemd notification (
notify_rules): the$NOTIFY_SOCKETsocket when it is a filesystem socket that exists. - Wayland (
wayland_rules): the compositor socket ($XDG_RUNTIME_DIR/$WAYLAND_DISPLAY, connect). - Cache (read-write): the cache directory holding the database.
The seccomp allowlist is the base set (file I/O, memory, threads, the event loop, Unix sockets,
pipes, signals, inotify, memfd_secret) plus SQLite’s flock, fsync, and fdatasync. A
selection is received through a pipe whose write end the compositor passes to the source client;
no file system grant is involved. When the sandbox cannot be applied, startup fails; the daemon
never runs unconfined.
Lifecycle
- Startup: process hardening;
core_daemon::startup()(layout, directory bootstrap, configuration load); the database; the sandbox; the installation identity; the configuration watch; capture; the bus connection (core_daemon::connect_bus); the default profile (StatusRequest). - Announcement:
DaemonStarted { capabilities: ["clipboard", "history"] }. - Readiness:
READY=1(platform_linux::systemd::notify_ready()). - Event loop (
core_daemon::EventLoop): the 15-second watchdog, bus messages, captured selections, the next secret’s expiry, configuration reloads (ConfigReloaded { changed_keys: ["clipboard"] }is published), and SIGINT/SIGTERM. A closed bus ends the process (exit status- for systemd to restart.
- Shutdown:
DaemonStopped { reason: "shutdown" }. Held secrets are zeroized when dropped.
Input Daemon
The daemon-input process reads keyboard events from Linux evdev, translates them with XKB, and
forwards them over the Noise IK IPC bus to daemon-wm while the window switcher holds a grab. It
runs a single-threaded tokio runtime (current_thread) and connects to the bus as a BusClient.
Device Discovery
spawn_keyboard_readers() (keyboard.rs) enumerates input devices
(platform_linux::input::enumerate_devices()), keeps those with is_keyboard, and opens each as
an async event stream (platform_linux::input::open_keyboard_stream()). One tokio task per
keyboard feeds a single channel of capacity 256.
When enumeration fails or finds no keyboard (typically because the user is not in the input
group), the daemon logs a warning naming the remedy (sudo usermod -aG input $USER) and runs
with an empty channel; daemon-wm then relies on its layer-shell surface’s keyboard. A device
that cannot be opened is skipped with a warning.
Event Reading
Each reader forwards EventSummary::Key events:
- value 1 (press):
RawKeyEvent { keycode, pressed: true }. - value 0 (release):
RawKeyEvent { keycode, pressed: false }. - value 2 (repeat): dropped; repetition is the consumer’s concern.
keycode is the evdev code (30 for KEY_A). A read error (device removed, permission revoked)
ends that device’s reader with a warning.
XKB Translation
XkbContext::new() compiles the system default keymap (Keymap::new_from_names with empty
rules, model, layout, and variant) and returns None when the XKB data files are absent. Under
the nix desktop package, daemon-input is wrapped with XKB_CONFIG_ROOT pointing at
xkeyboard-config.
process_key(evdev_keycode, pressed) produces a KeyboardEvent:
- The XKB keycode is
evdev_keycode + 8. - The keysym (
key_get_one_sym) and UTF-32 character (key_get_utf32) are read before the state is updated, so pressing Alt reports modifiers without Alt and releasing it reports them with Alt;daemon-wmrelies on this to tell the last cycle modifier’s release (keysym::ends_cycle). - The modifier mask is read (below).
- The state is updated with the key direction.
unicodeis set on presses only, when the character is non-zero.
| Modifier | XKB name | Bit | core_types::keysym (GDK name) |
|---|---|---|---|
| Shift | MOD_NAME_SHIFT | 0 | SHIFT_MASK (GDK_SHIFT_MASK) |
| Control | MOD_NAME_CTRL | 2 | CONTROL_MASK (GDK_CONTROL_MASK) |
| Alt | MOD_NAME_ALT | 3 | ALT_MASK (GDK_ALT_MASK) |
| Super | MOD_NAME_LOGO | 26 | SUPER_MASK (GDK_SUPER_MASK) |
Each is tested with mod_name_is_active(…, STATE_MODS_EFFECTIVE).
Without an XKB context the daemon warns at startup, and during a grab forwards events with the
raw evdev code as keyval, no modifiers, and no character.
Grab Protocol
The daemon tracks grab_active and grab_requester.
- During a grab, every press and release is translated and published as
InputKeyEvent(SecurityLevel::Internal). - Outside a grab, every event still updates the XKB state, so modifiers are right when a grab
starts, and only releases of the cycle modifiers (
keysym::is_cycle_modifier: Control_L, Control_R, Meta_L, Meta_R, Alt_L, Alt_R, Super_L, Super_R) are published. A grab request can arrive after the user released the shortcut’s modifier; forwarding these releases unconditionally letsdaemon-wmsee the release anyway, at the cost of eight keysyms’ releases of extra traffic.
A failed InputKeyEvent publish ends the daemon: a lost key event would desynchronize the
overlay.
| Message | Response | Behavior |
|---|---|---|
InputGrabRequest { requester } | InputGrabResponse { success: true } | Starts a grab for requester |
InputGrabRelease { requester } | – | Ends the grab when requester holds it |
InputLayersList | InputLayersListResponse | The single active default layer, no remaps |
InputStatus | InputStatusResponse | Layer default, no grabbed devices, remapping off |
Key remapping is not implemented; the layer and status responses report exactly that.
Deduplication and Key Mapping in daemon-wm
When the compositor gives the overlay keyboard focus, the same keystroke arrives twice: from the
layer surface and as InputKeyEvent. daemon-wm’s KeyDeduplicator (ipc_keys.rs) keeps the
last 8 (keyval, pressed, time) entries in a ring and rejects an event matching an entry’s
keyval and direction within 50 ms. A press and a release of one key never deduplicate each other.
A forwarded release counts only when it ends the cycle (keysym::ends_cycle): the release of a
cycle modifier whose event mask holds no other cycle modifier. The overlay keyboard’s report of
the same release deduplicates with it under one key, whichever modifier was released last.
map_ipc_key_to_event(keyval, unicode) maps a forwarded key press to an overlay event:
| Keysym | Key | Event |
|---|---|---|
0xFF1B | Escape | Escape |
0xFF0D, 0xFF8D | Return, KP_Enter | Confirm |
0xFF09 | Tab | none |
0xFF54 | Down | SelectionDown |
0xFF52 | Up | SelectionUp |
0xFF08 | Backspace | Backspace |
0x0020 | Space | Char(' ') |
| other | – | Char(ch) when unicode is printable ASCII or space |
Tab maps to nothing: the compositor intercepts Alt+Tab and re-activates the overlay
(WmActivateOverlay / WmActivateOverlayBackward), so forwarding Tab would advance the
selection twice.
Process Hardening
On Linux the daemon calls platform_linux::security::harden_process(), sets resource limits
(nofile = 4096, memlock_bytes = 0), probes memfd_secret (core_types::init_secure_memory()),
and applies a Landlock and seccomp sandbox built from the layout (core_daemon::sandbox) plus
its device paths:
- Bus client (
ipc_client_rules): the per-daemon key directory ($XDG_RUNTIME_DIR/pds/keys, read), the bus public key, and the bus socket (connect). - Configuration (
config_rules, read-only):~/.config/pdsand the directories its symlinks resolve into. - systemd notification (
notify_rules): the$NOTIFY_SOCKETsocket when it is a filesystem socket that exists. - Devices (read-only):
/dev/input,/sys/class/input(enumeration symlinks), and/sys/devices(their targets’ metadata).
The seccomp allowlist includes ioctl for evdev queries, inotify for configuration reload,
memfd_secret, and standard I/O and process lifecycle calls. When the sandbox cannot be applied,
startup fails with “refusing to run unsandboxed”; the daemon never runs unconfined.
Reading evdev directly makes the overlay’s input independent of compositor focus: exclusive layer-shell keyboard interactivity may be granted late or not at all, and the grab request may arrive after the triggering keystroke.
Lifecycle
- Startup: process hardening;
core_daemon::startup()(layout, directory bootstrap, configuration load); the configuration watch; the keyboard readers and XKB context; the bus connection (core_daemon::connect_bus, up to 5 attempts 500 ms apart); the sandbox. - Announcement:
DaemonStarted { capabilities: ["input", "remap"] }. - Readiness:
READY=1(platform_linux::systemd::notify_ready()). - Event loop:
tokio::select!over the 15-second watchdog, keyboard events, bus messages, configuration reloads (ConfigReloaded { changed_keys: ["input"] }is published), and SIGINT/SIGTERM. A closed bus ends the process (exit status 1) for systemd to restart. - Shutdown:
DaemonStopped { reason: "shutdown" }.
Snippets Daemon
The daemon-snippets process holds text snippets per trust profile and answers list, expand, and
add requests over the Noise IK IPC bus. It runs a single-threaded tokio runtime
(current_thread) and connects to the bus as a BusClient.
Storage
Snippets live in memory only, in a BTreeMap<(String, String), String> (the SnippetMap alias)
keyed by (profile, trigger) with the template as the value. The ordered map makes listings
deterministic: SnippetList returns a profile’s snippets sorted by trigger.
The configuration schema has no snippets section. build_snippet_map() returns an empty map at
startup and on every configuration reload, so snippets exist only from a SnippetAdd until the
next reload or restart; a reload clears them.
Profile Scoping
The profile is the first half of every key, so two profiles hold the same trigger without collision, and no operation crosses profiles:
SnippetListreturns the entries whose key’s profile is the requested one.SnippetExpandlooks up the exact(profile, trigger)key.SnippetAddinserts or replaces the(profile, trigger)key.
IPC Interface
| Message | Response | Behavior |
|---|---|---|
SnippetList { profile } | SnippetListResponse { snippets } | The profile’s snippets, by trigger |
SnippetExpand { profile, trigger } | SnippetExpandResponse { expanded } | The template, or None |
SnippetAdd { profile, trigger, template } | SnippetAddResponse { success: true } | Insert or replace |
Each SnippetInfo in a list carries trigger and template_preview. A template of at most 80
characters is its own preview; a longer one previews as its first 77 characters followed by
.... Previews count characters, not bytes, so a multibyte template never splits a code point.
Responses carry the request’s message ID (Message::with_correlation). The daemon ignores
messages it published itself, and other message kinds.
Triggers and Templates
Trigger lookup is exact and case-sensitive: the requested trigger must equal the stored one
byte for byte. SnippetExpand returns the stored template verbatim; templates are plain text,
with no variable or secret substitution.
CLI
sesame snippet list -p <profile>, sesame snippet expand -p <profile> <trigger>, and
sesame snippet add -p <profile> <trigger> <template> send these requests. expand prints the
template, or fails naming the trigger when the profile has no such snippet.
Process Hardening
On Linux the daemon calls platform_linux::security::harden_process(), sets resource limits
(nofile = 4096, memlock_bytes = 0), probes memfd_secret (core_types::init_secure_memory()),
and applies a Landlock and seccomp sandbox built from the layout (core_daemon::sandbox):
- Bus client (
ipc_client_rules): the per-daemon key directory ($XDG_RUNTIME_DIR/pds/keys, read), the bus public key ($XDG_RUNTIME_DIR/pds/bus.pub, read), and the bus socket ($XDG_RUNTIME_DIR/pds/bus.sock, connect). - Configuration (
config_rules, read-only): the configuration directory (~/.config/pds) and the directories its symlinks resolve into (for example/nix/store). - systemd notification (
notify_rules): the$NOTIFY_SOCKETsocket when it is a filesystem socket that exists.
It needs no Wayland socket, no /dev/input, and no cache directory. The seccomp allowlist covers
standard I/O, memory management, the IPC socket, inotify for configuration reload,
memfd_secret, and process lifecycle calls. When the sandbox cannot be applied, startup fails
with “refusing to run unsandboxed”; the daemon never runs unconfined.
Lifecycle
- Startup: process hardening;
core_daemon::startup()(layout, directory bootstrap, configuration load); the empty snippet map; the configuration watch; the bus connection (core_daemon::connect_bus, up to 5 attempts 500 ms apart); the sandbox. - Announcement:
DaemonStarted { capabilities: ["snippets", "expansion"] }. - Readiness:
READY=1(platform_linux::systemd::notify_ready()). - Event loop:
tokio::select!over the 15-second watchdog, bus messages, configuration reloads (the map is rebuilt, andConfigReloaded { changed_keys: ["snippets"] }published), and SIGINT/SIGTERM. A closed bus ends the process (exit status 1) for systemd to restart. - Shutdown:
DaemonStopped { reason: "shutdown" }.
Launch Profiles
Launch profiles define composable environment bundles that attach to application launches. Each profile specifies environment variables, secret references, an optional Nix devshell, and an optional working directory. Profiles are scoped to trust profiles and composed at launch time via tags.
Profile Structure
A launch profile is defined by the LaunchProfile struct in core-config/src/schema_wm.rs:
[profiles.work.launch_profiles.dev-rust]
env = { RUST_LOG = "debug", CARGO_HOME = "/workspace/.cargo" }
secrets = ["github-token", "crates-io-token"]
devshell = "/workspace/myproject#rust"
cwd = "/workspace/alice/github.com/org/repo"
Each field is optional and defaults to empty:
env(BTreeMap<String, String>): static environment variables injected into the child process.secrets(Vec<String>): secret names fetched from the vault and converted to env vars.devshell(Option<String>): Nix flake devshell reference. Wraps the command innix develop.cwd(Option<String>): absolute path used as the working directory for the spawned process.
Tag System
Key bindings in the window manager configuration reference launch profiles through the tags field
on WmKeyBinding:
[profiles.default.wm.key_bindings.g]
apps = ["ghostty", "com.mitchellh.ghostty"]
launch = "ghostty"
tags = ["dev-rust", "ai-tools"]
launch_args = ["--working-directory=/workspace/user/github.com/org/repo"]
When a key binding triggers a launch, daemon-launcher resolves each tag against the configuration to compose the final environment. Tags are processed in order; the composition rules are described below.
Cross-Profile Tag References
Tags support qualified cross-profile references using the profile:name syntax. An unqualified tag
resolves against the default (or explicitly specified) trust profile. A qualified tag resolves
against a different trust profile.
dev-rustresolvesdev-rustin the current trust profile.work:corpresolvescorpin theworktrust profile.
The parsing logic in daemon-launcher/src/launch.rs (parse_tag) splits on the first colon. If no
colon is present, the tag is unqualified and uses the default profile.
Cross-profile references allow a single key binding to compose environments from multiple trust boundaries. For example, a terminal binding might combine a personal development environment with corporate secrets:
tags = ["dev-rust", "work:corp-secrets"]
Tag Composition Rules
When multiple tags are specified, they are processed sequentially. The composition semantics are:
- Environment variables: merged into a single
BTreeMap. When the same key appears in multiple tags, the later tag wins. - Secrets: accumulated. Duplicate secret names (same name, same trust profile) are deduplicated; secrets from different trust profiles are kept independently.
- Devshell: last tag with a non-
Nonedevshell wins. - Working directory: last tag with a non-
Nonecwdwins.
This is implemented in daemon-launcher/src/launch.rs in the launch_entry function. The composed
environment is applied to the child process after secret fetching completes.
Configuration Schema
Launch profiles live under each trust profile’s configuration section:
[profiles.personal]
# ... other profile settings ...
[profiles.personal.launch_profiles.dev-rust]
env = { RUST_LOG = "debug" }
secrets = ["github-token"]
devshell = "/workspace/project#rust"
cwd = "/workspace/alice/github.com/org/repo"
[profiles.personal.launch_profiles.ai-tools]
env = { ANTHROPIC_MODEL = "claude-sonnet-4-20250514" }
secrets = ["anthropic-api-key"]
The full path in the config tree is
profiles.<trust_profile_name>.launch_profiles.<launch_profile_name>. Daemon-launcher reads these
from the hot-reloaded configuration state (ConfigWatcher) at launch time, so changes take effect
without daemon restart.
Configuration loads in this order: system policy, user config.toml, sorted config.d/*.toml
fragments, then sorted profiles/<trust-profile>/config.toml overrides under the PDS configuration
directory. An override may contain only its own [profiles.<trust-profile>] table and nested
tables. Global settings or another trust profile in that file reject the configuration. Startup and
reload use the same schema and semantic validation; a rejected reload retains the last accepted
configuration.
Configuration editors stage their complete changeset before publication. Dry-run performs the same in-memory edits and conflict checks without creating files or acquiring a writer lock. Commit checks all recorded reads under the writer lock, records a durable undo journal, and publishes the files. Readers reject pending journals. The next updating command recovers interrupted writes; unexpected external contents stop recovery and remain untouched. External editors do not acquire this lock, so an edit after a conflict check cannot be protected by this protocol.
Denial Handling
If a tag references a trust profile or launch profile that does not exist, daemon-launcher returns a
structured LaunchDenial to the window manager:
LaunchDenial::ProfileNotFound– the trust profile name in a qualified tag does not exist.LaunchDenial::LaunchProfileNotFound– the launch profile name does not exist within the resolved trust profile.
The window manager can use these denials to display user-facing error messages.
Secret Injection
Secrets flow from per-profile SQLCipher vaults into launched processes as environment variables.
Two mechanisms exist: the sesame env CLI command for interactive use, and the daemon-launcher
IPC path for overlay-driven launches.
Vault to Environment Pipeline
daemon-launcher Path
When daemon-launcher processes a LaunchExecute request with tags, the pipeline is:
- Tag resolution: each tag is resolved to a
LaunchProfilefrom the hot-reloaded configuration. Cross-profile tags (work:corp) route to different trust profiles. - Secret collection: secret names from all resolved launch profiles are accumulated with their owning trust profile name. Duplicates (same name, same profile) are deduplicated.
- IPC fetch: for each
(secret_name, trust_profile_name)pair, daemon-launcher sends aSecretGetrequest over the Noise IK bus to daemon-secrets. The request specifies the trust profile that owns the vault. - Name conversion: the secret name is converted to an environment variable name (see below).
- Environment injection: the secret value is inserted into the composed environment map,
then passed to the child process via
Command::env(). - Zeroization: after the child process is spawned and the environment has been copied to
the OS process, all secret values in the composed environment map are zeroized via
zeroize::Zeroize.
Batched Denial Collection
Daemon-launcher does not abort on the first secret fetch failure. Instead, it collects all denials and returns them in a single response so the window manager can prompt for all required vault unlocks at once:
- Locked vaults:
SecretDenialReason::LockedorProfileNotActivedenials are collected into alocked_profileslist. - Missing secrets:
SecretDenialReason::NotFounddenials increment amissing_count. - Rate limiting:
SecretDenialReason::RateLimitedcauses an immediate abort withLaunchDenial::RateLimited.
After iterating all secrets, locked vaults take priority: if any vaults are locked,
LaunchDenial::VaultsLocked is returned with the full list. Otherwise, if secrets are missing,
LaunchDenial::SecretNotFound is returned.
sesame env
The sesame env command spawns a child process with vault secrets injected as environment
variables:
sesame env -p work -- my-command --flag
It connects to the IPC bus, fetches all secrets for the specified profile(s), converts each secret name to an env var, injects them into the child process, waits for the child to exit, zeroizes all secret copies, and exits with the child’s exit code.
The child also receives a SESAME_PROFILES environment variable containing a comma-separated
list of the profile specs that were used.
sesame export
The sesame export command outputs secrets in shell, dotenv, or JSON format without spawning
a child:
sesame export -p work --format shell
sesame export -p work --format dotenv
sesame export -p work --format json
Output is written to stdout. Secret values are zeroized after printing.
Secret Name to Env Var Conversion
Two conversion implementations exist, with slightly different rules:
daemon-launcher (launch.rs)
Applies to secrets injected via launch profile tags:
- Uppercase the entire name.
- Replace hyphens with underscores.
Examples: github-token becomes GITHUB_TOKEN. anthropic-api-key becomes
ANTHROPIC_API_KEY.
sesame env / sesame export (env.rs)
Applies to secrets injected via the CLI:
- Uppercase the entire name.
- Replace hyphens, dots, and non-alphanumeric characters (except underscores) with underscores.
Examples: api-key becomes API_KEY. db.host-name becomes DB_HOST_NAME.
Prefix System
The --prefix flag (available on sesame env and sesame export) prepends a string to every
generated environment variable name, separated by an underscore:
sesame env --prefix MYAPP -p work -- my-command
With prefix MYAPP, the secret api-key becomes MYAPP_API_KEY.
The prefix is also configurable per-workspace via .sesame.toml:
secret_prefix = "MYAPP"
The prefix is applied after the name-to-env-var conversion, so the full transformation is:
secret_name -> uppercase + substitute -> prepend prefix.
Denied Environment Variables
The sesame env and sesame export commands maintain a deny list of environment variable names
that must never be overwritten by secret injection. This prevents secrets with adversarial names
from hijacking the dynamic linker, shell execution, or privilege escalation vectors. The deny
list includes:
- Dynamic linker variables:
LD_PRELOAD,LD_LIBRARY_PATH,DYLD_INSERT_LIBRARIES, and others. - Core execution:
PATH,HOME,SHELL,USER. - Shell injection vectors:
BASH_ENV,IFS,PROMPT_COMMAND, and others. - Language runtime injection:
PYTHONPATH,NODE_OPTIONS,RUBYOPT, and others. - Open Sesame’s own namespace:
SESAME_PROFILE.
Matching is case-insensitive. The BASH_FUNC_ prefix is matched as a prefix pattern to block
Bash function export injection.
Implicit Environment Variables
Every launched process receives these environment variables regardless of tag configuration:
| Variable | Value |
|---|---|
SESAME_PROFILE | The trust profile name used for the launch. |
SESAME_APP_ID | The desktop entry ID of the launched application. |
SESAME_SOCKET | Path to the IPC bus Unix socket. |
These are injected after the composed environment, so they cannot be overridden by launch profile
env entries.
Desktop Entry Discovery
Daemon-launcher discovers launchable applications by scanning XDG desktop entry files, builds a fuzzy search index, and ranks results using frecency (frequency + recency).
XDG Desktop Entry Scanning
The scanner in daemon-launcher/src/scanner.rs uses the freedesktop-desktop-entry crate to
enumerate .desktop files from $XDG_DATA_DIRS/applications/. Scanning is synchronous and runs
in a tokio::task::spawn_blocking context at daemon startup.
Filtering Rules
Entries are filtered before indexing:
| Condition | Action |
|---|---|
Hidden=true | Skipped. The entry is deleted, per the Desktop Entry Specification. |
No Exec= field | Skipped. Not a launchable application. |
NoDisplay=true | Cached for launching by ID, not indexed for search: a desktop’s default application may be one. |
| Duplicate ID | Only the first occurrence (highest precedence) is kept. |
Indexed Fields
For each surviving entry, the scanner produces a MatchItem with:
- id: the desktop entry ID (e.g.,
org.mozilla.firefox). - name: the localized
Name=field, falling back to the entry ID. - extra: a space-joined string of
Keywords=andCategories=values, used to broaden fuzzy match surface.
The Exec line, StartupWMClass, and Terminal flag are cached separately in a CachedEntry
for post-scan use during launch execution and default-application resolution. The cache is
stored as a HashMap<String, CachedEntry> keyed by entry ID.
Default Applications
LaunchDefaultApps asks daemon-launcher which application each desktop role (AppRole:
web browser, files, mail, music, video, photos, calendar, terminal, text editor, app store,
settings, system monitor) resolves to; daemon-wm asks when an activation starts
(Snapshot). daemon-launcher/src/default_apps.rs
answers from the files as they are at each request.
The [Default Applications] groups of the XDG MIME Applications Associations specification’s
mimeapps.list files (Layout::mimeapps_lists) are read, highest precedence first:
$XDG_CONFIG_HOME/<desktop>-mimeapps.list, then$XDG_CONFIG_HOME/mimeapps.list- the same in each
$XDG_CONFIG_DIRSdirectory (default/etc/xdg) - the same in
$XDG_DATA_HOME/applications - the same in each
$XDG_DATA_DIRSdirectory’sapplications
<desktop> is each $XDG_CURRENT_DESKTOP name, lowercased, most specific first (unity is
gnome). The first file naming an eligible entry for any of the role’s MIME types decides the
role; within a file the role’s MIME types are taken in order (the types COSMIC Settings’ Default
Applications page writes: x-scheme-handler/http for the web browser, inode/directory for
files, x-scheme-handler/terminal for the terminal, text/plain for the text editor), and
within a type its listed entries in order. An entry is eligible when it is cached (installed,
not Hidden, with Exec) and not Terminal=true: such an entry’s windows belong to the
terminal it runs in. When no file decides, the desktop’s shipped application is the last resort
(on COSMIC: Files, Player, Viewer, Terminal, Edit, Store, Settings, and Monitor).
A resolved application’s window app IDs are its entry ID and, when different, its
StartupWMClass. A role with no eligible application is absent from the answer.
Fuzzy Search
Daemon-launcher uses the nucleo fuzzy matching library (via the core-fuzzy crate). Items are
injected into the matcher at startup via an Injector. Queries arrive as LaunchQuery IPC
messages and are dispatched to SearchEngine::query(), which combines fuzzy match scores with
frecency boosts.
Query results are returned as LaunchResult values containing the entry ID, display name, icon,
and composite score.
Frecency Ranking
Launch frequency and recency are tracked in a per-profile SQLite database managed by
core-fuzzy::FrecencyDb. The database file is stored at:
~/.config/pds/launcher/{profile_name}.frecency.db
Each trust profile has its own frecency database, providing isolation between profiles. When a
LaunchQuery specifies a different profile than the current one, the search engine switches its
frecency context via engine.switch_profile().
When a LaunchExecute succeeds, engine.record_launch(entry_id) updates the frecency database.
The frecency boost is refreshed periodically via engine.refresh_frecency().
Desktop Entry Field Code Stripping
Before executing an Exec line, the scanner strips freedesktop %-prefixed field codes. These
are placeholder tokens defined by the Desktop Entry Specification that would normally be replaced
by a file manager:
Stripped codes: %f, %F, %u, %U, %d, %D, %n, %N, %i, %c, %k, %v, %m.
The literal %% sequence is collapsed to a single %.
After stripping, multiple consecutive spaces from removed codes are collapsed. The result is
then tokenized using freedesktop quoting rules (double-quote escaping for \", \`, \\,
\$). The tokenizer does not invoke a shell.
3-Strategy Resolution Fallback
When a LaunchExecute request arrives, the entry ID is resolved against the cached entries
using three strategies in order:
- Exact match: the entry ID matches a cache key exactly (e.g.,
org.mozilla.firefox). - Last segment match: the entry ID matches the last dot-separated segment of a cached ID,
case-insensitively (e.g.,
firefoxmatchesorg.mozilla.firefox). - Case-insensitive full ID match: the entry ID matches a cached ID when both are lowercased
(e.g.,
alacrittymatchesAlacritty).
If none of the three strategies produces a match, LaunchDenial::EntryNotFound is returned.
Process Management
Daemon-launcher spawns child processes in isolated systemd scopes with zombie reaping and post-spawn secret zeroization.
systemd-run Scope Isolation
Every launched process is wrapped in a transient systemd user scope via:
systemd-run --user --scope --unit=app-open-sesame-{entry_id}-{pid}.scope -- {program} {args}
This provides:
- cgroup isolation: the child runs in its own cgroup, enabling per-application resource
accounting via
systemd-cgtop. - No inherited limits: the child does not inherit
MemoryMaxor mount namespace restrictions from the launcher’s service unit. - Launcher restart survival: because
KillMode=processsemantics apply to scopes (the scope itself has no main process), children survive launcher daemon restarts. - Clean unit naming: the scope name is sanitized from the entry ID by replacing non-alphanumeric characters with dashes and collapsing runs.
Fallback to Direct Spawn
If systemd-run is unavailable (not installed, or the spawn fails), daemon-launcher falls back
to a direct Command::spawn(). The via_scope flag in the log output indicates which path was
taken.
No Sandbox Inheritance
Daemon-launcher intentionally does not apply seccomp or Landlock sandboxing to itself. Seccomp
and Landlock rules inherit across fork+exec and would be applied to every child process,
breaking arbitrary desktop applications. The security boundary for daemon-launcher is the Noise
IK authenticated IPC bus, not process-level sandboxing.
Child Reaping
After spawning, daemon-launcher reaps the wrapper process (or direct child) in a
tokio::task::spawn_blocking closure that calls child.wait(). This prevents zombie
accumulation.
When using systemd-run scopes, the reaped process is the systemd-run wrapper, not the
application itself. The application continues running under the transient scope until it exits
naturally.
Secret Zeroization
Secret values pass through two zeroization points:
- Error paths: if a secret value fails UTF-8 validation, the raw bytes are zeroized before returning the error.
- Post-spawn cleanup: after
Command::spawn()copies the environment to the OS process, all values in the composed environmentBTreeMapare zeroized viazeroize::Zeroize, and the map is dropped.
This ensures secret material does not persist in the daemon-launcher process memory after it has been handed off to the child.
I/O Configuration
Spawned processes have their I/O handles configured as:
| Stream | Configuration |
|---|---|
| stdin | /dev/null (Stdio::null()) |
| stdout | /dev/null (Stdio::null()) |
| stderr | Inherited from daemon-launcher (Stdio::inherit()) |
Stderr inheritance allows application error output to reach the journal when daemon-launcher runs under systemd.
Environment Propagation
The composed environment (launch profile env vars + secrets + implicit SESAME_* vars) is
propagated to both the systemd-run wrapper and the direct spawn fallback. The systemd-run
process passes its environment through to the child in the scope.
The working directory (cwd) from the launch profile is validated as an absolute, existing
directory path before being set on the command. Relative paths are rejected with an error.
Structured Logging
All Open Sesame daemons use the tracing crate for structured, leveled logging. Log output is
configurable between JSON and human-readable formats, with journald integration on Linux.
Tracing Integration
Every daemon initializes a tracing-subscriber stack at startup. The two supported output
formats are:
- JSON (
--log-format json, default for daemon-profile): machine-parseable structured JSON, one object per line. Enabled viatracing_subscriber::fmt().json().init(). - Pretty (
--log-format pretty): human-readable colored output viatracing_subscriber::fmt().init().
The format is selected via the --log-format CLI flag or the PDS_LOG_FORMAT environment
variable. The implementation is in daemon-profile/src/sandbox.rs (init_logging).
RUST_LOG and Log Levels
All daemons read the RUST_LOG environment variable via
tracing_subscriber::EnvFilter::try_from_default_env(). If RUST_LOG is not set, the default
filter is info.
Standard tracing levels are used throughout:
| Level | Usage |
|---|---|
error | IPC failures, secret fetch denials, audit chain verification failures, sandbox application failures. |
warn | Non-fatal issues: systemd-run fallback, corrupt audit tail entry, HTTP git URL detected. |
info | Daemon lifecycle (starting, ready, shutting down), launch execution, watchdog ticks, config reloads, key rotation, audit chain verification on startup. |
debug | Child reaping status, context engine debounce suppression. |
journald Integration
The tracing-journald crate is a Linux dependency of daemon-launcher and other daemons. When
running under systemd, structured log fields are forwarded to the journal as journal fields,
enabling filtering with journalctl:
journalctl --user -u daemon-launcher.service
journalctl --user -u daemon-profile.service
Structured Fields
Tracing spans and events use structured key-value fields throughout the codebase. Notable patterns:
- Launch execution:
entry_id,program,arg_count,scope_name,tags,devshell,env_count,secret_count,via_scope,pidare attached to launch log lines indaemon-launcher/src/launch.rs. - Secret fetching:
secret_countand per-secretreasonfields on denial. - Watchdog:
watchdog_tick_counttracks event loop health indaemon-profile/src/main.rs. - IPC messages:
senderandmsg_ididentify message origin. - Audit:
path,sequence,entriestrack audit log state at startup. - Security posture: sandbox
statusis logged after Landlock and seccomp application. - Key rotation:
daemon_name,generation,clearancefields on rotation events. - Desktop entry resolution:
entry_id,resolved_idlogged with the resolution strategy used.
Daemon Startup Logging Sequence
Daemon-profile follows this startup sequence (other daemons follow a similar pattern):
"daemon-profile starting"– logged immediately after CLI parsing.harden_process()andapply_resource_limits()– the platform layer hardens the process (RLIMIT_NOFILE, RLIMIT_MEMLOCK, etc.).init_secure_memory()– probesmemfd_secret(2)availability and logs whether the kernel supports sealed anonymous memory for secret storage.- Sandbox application – logs the Landlock and seccomp result via
?statusstructured field. - IPC bus server bind – logs
pathand confirms Noise IK encryption. - Per-daemon keypair generation – logs
daemon,clearancefor each of the six known daemons. - Audit logger initialization – logs
pathandsequence(chain head position). - Audit chain verification – logs
entriescount if the chain is intact, or an error if verification fails. - Context engine initialization – logs
profile(the default ProfileId). platform_linux::systemd::notify_ready()– sendsREADY=1to systemd."daemon-profile ready"– logged after readiness notification.
Audit Chain
Open Sesame keeps a tamper-evident audit log: every auditable operation appends a JSONL entry
whose prev_hash is the hash of the previous entry’s serialized line. Changing, deleting,
reordering, or injecting an entry breaks every later link.
core-profile/src/audit.rs is the only reader and writer of the log: open_audit_log
resumes the chain for appending, read_audit_log reads it, and verify_audit_log replays
it.
Hash Algorithm
The chain hash is the configured [crypto] audit_hash: BLAKE3 (default) or SHA-256 for
governance-compatible deployments. A chain is verifiable only under the algorithm it was
written with: verifying a SHA-256 chain as BLAKE3 fails at the second entry.
Appending
AuditLogger holds the chain head (last_hash, the hex hash of the last written line, and
sequence), the hash algorithm, and the default agent identity. append(action):
- Reads the wall clock (milliseconds since the Unix epoch); a clock before the epoch is an error.
- Builds an
AuditEntrywith sequencesequence + 1andprev_hashthe current head. - Serializes it to one JSON line, writes it, and flushes.
- Only after the write succeeds, advances the head to the new line’s hash and sequence: a failed write leaves the logger consistent with the log.
The first entry of a fresh log has an empty prev_hash.
Entry Structure
{
"sequence": 1,
"timestamp_ms": 1700000000000,
"action": { "ProfileActivated": { "target": "...", "duration_ms": 42 } },
"prev_hash": "",
"agent_id": "..."
}
| Field | Type | Description |
|---|---|---|
sequence | u64 | Monotonically increasing, starting at 1. |
timestamp_ms | u64 | Wall clock time in milliseconds since the Unix epoch. |
action | AuditAction | The auditable operation (below). |
prev_hash | String | Hex hash of the previous entry’s line. Empty for the first entry. |
agent_id | Option<AgentId> | The agent that triggered the action; omitted when unknown. |
AuditAction Variants
AuditAction (core-profile/src/lib.rs, #[non_exhaustive]):
| Variant | Fields | Description |
|---|---|---|
ProfileActivated | target, duration_ms | A trust profile was activated. |
ProfileDeactivated | target, duration_ms | A trust profile was deactivated. |
ProfileActivationFailed | target, reason | An activation failed. |
ProfileDeactivationFailed | target, reason | A deactivation failed or was not confirmed. |
DefaultProfileChanged | previous, current | The default profile for new launches changed. |
IsolationViolationAttempt | from_profile, resource | A cross-profile resource access was blocked. |
SecretAccessed | profile_id, secret_ref | A secret was read from a vault. |
KeyRotationStarted | daemon_name, generation | IPC key rotation began. |
KeyRotationCompleted | daemon_name, generation | Key rotation completed. |
KeyRevoked | daemon_name, reason, generation | A daemon’s key was revoked. |
SecretOperationAudited | action, profile, key, requester, requester_name, outcome | A secret operation was performed or denied. |
AgentConnected | agent_id, agent_type | An agent connected. |
AgentDisconnected | agent_id, reason | An agent disconnected. |
InstallationCreated | id, org, machine_binding_present | An installation was created. |
AuthorizationRequired | request_id, operation | An operation requires authorization. |
AuthorizationGranted | request_id, delegator, scope | Authorization was granted. |
AuthorizationDenied | request_id, reason | Authorization was denied. |
AuthorizationTimeout | request_id | An authorization request timed out. |
DelegationRevoked | delegation_id, revoker, reason | A delegation was revoked. |
HeartbeatRenewed | delegation_id, renewal_source | A delegation heartbeat was renewed. |
FederationSessionEstablished | session_id, remote_installation | A federation session was established. |
FederationSessionTerminated | session_id, reason | A federation session ended. |
PostureEvaluated | composite_score | A device posture evaluation produced a score. |
Verification: sesame audit verify
sesame audit verify replays the chain of the log under the configured algorithm:
$ sesame audit verify
OK: 1247 entries verified.
verify_chain iterates the non-empty lines in order, parses each as an AuditEntry, and
checks that its prev_hash is the hash of the previous line. The first mismatch is an error
naming the sequence number and the expected and actual prev_hash; an unparseable line is
an error naming its line number. The core-profile tests cover modified, deleted, and
reordered entries, and a chain resumed across a restart.
sesame audit tail
sesame audit tail -n 10
sesame audit tail --follow
Without --follow, the last N entries are pretty-printed. With --follow, new appends are
printed as the file grows, until Ctrl-C.
Startup and Recovery
daemon-profile opens the log once installation.toml exists (open_audit):
open_audit_logreads the chain head from the log’s last non-empty line: its hash under the configured algorithm and its sequence. A missing or empty log starts a fresh chain.- A last line that does not parse is an error naming the file and
sesame audit verify: starting a fresh chain after it would fork the log, so daemon-profile does not start until the log is inspected. verify_audit_logthen replays the whole chain. A broken chain is logged aterrorand the daemon keeps running: the log stays tamper-evident (sesame audit verifyreports the break), and refusing to start would also stop recording new events.
The chain survives restarts: the first entry after a restart links to the last entry before it.
File Format and Location
- Path:
Layout::audit_log,<config dir>/audit.jsonl(~/.config/pds/audit.jsonl). - Format: JSON Lines, one entry per line.
- Mode: opened for appending and restricted to its owner (
0600), including a log that already existed with wider permissions. - Agent identity: daemon-profile’s default agent is
uuid::Uuid::new_v5(&install_ns, "agent:human:uid{uid}"), from the installation namespace and the process’s Unix UID.
Retention and Rotation
The log is not rotated or pruned by Open Sesame and grows without bound. External rotation
(for example logrotate) severs the chain at the rotation point: sesame audit verify
validates one contiguous file, so rotated segments must be archived and verified on their
own.
Health Checks
Open Sesame provides daemon health monitoring through sesame status and systemd watchdog
integration.
sesame status
The sesame status command in open-sesame/src/status.rs connects to the IPC bus and sends a
StatusRequest message to daemon-profile. The response (StatusResponse) includes:
- Per-vault lock state (
lock_state: Result<BTreeMap<TrustProfileName, bool>, String>): daemon-secrets inventories persisted vault artifacts and held runtime state. Configuration profiles do not define this inventory. A successful inventory is displayed with profile names and lock indicators; acquisition and responder errors are displayed as unknown. - Default profile (
default_profile: TrustProfileName): the currently active default profile for new unscoped launches. - Active profiles (
active_profiles: Vec<TrustProfileName>): the list of profiles that are currently activated (vault open, serving secrets). - Global locked flag (
locked: bool): whether daemon-secrets holds no master keys. This flag cannot replace a failed inventory.
Example output:
Vaults:
personal unlocked
work locked
Default profile: personal
Active profiles:
- personal (default)
A successful empty inventory displays none found. An unavailable inventory displays unknown with
its cause, including before installation initialization.
Configuration Convergence
sesame status --doctor config --output json --exit-code
The config category captures the local source revision, requests each daemon’s configuration status through its authenticated bus owner, and captures local sources again after the probe. Changing sources during the probe fails the check rather than comparing inconsistent inputs.
Daemon and configuration checks always include profile, secrets, launcher, and snippets. WM, clipboard, and input are included when the desktop target is active or transitioning, or when their individual service is running, transitioning, or failed. Inactive desktop services on a headless installation are not required. Failure to query the service manager is an explicit applicability failure.
Source acceptance and consumer application are independent. Each response reports the last accepted revision, last applied revision, latest observation result, watcher health, and application outcome. Pending application, rejected or unreadable observations, failed resource application, restart-required changes, and unavailable responders fail convergence. An applied current revision with degraded native watches is a warning: timer reconciliation continues. Native watches with accepted, applied current sources pass.
Only a consumer acknowledgement emits ConfigReloaded. Source acceptance alone emits no application
success. The WM waits for renderer settings adoption; the launcher prepares replacement portal
bindings before committing its configuration. Failed attempts retain the previously applied
snapshot. Authorization additionally requires an accepted observation matching the consumer’s
acknowledged observation, so stale policy cannot authorize requests. Loss of an established launcher
shortcut stream rejects application and retries binding on reconciliation. A portal absent at
startup is optional; once adopted, it must recover before the launcher can report convergence.
Lock and deactivation use transport authentication without loading installation identity. A malformed identity file therefore cannot prevent these authority-reducing operations.
Consumer Application Policies
| Consumer | Application boundary | Failure behavior |
|---|---|---|
| Profile | Rebuild profiles, default profile, and context engine; announce default changes after acknowledgement | Activation requires current acknowledged policy; deactivation and inventory remain available |
| Secrets | Adopt request-time ACL and profile policy | CRUD, factor submission, and activation fail closed; lock, deactivation, and inventory remain available |
| Launcher | Prepare replacement shortcut bindings, then commit launch configuration | Keep previous committed configuration when preparation fails; lost adopted bindings require recovery |
| WM | Renderer acknowledges theme and column settings | Reject failed application; resource loss prevents convergence until respawn and acknowledgement |
| Clipboard | Adopt clipboard settings and installation namespace | Retain previous applied settings when source observation fails |
| Input | Acknowledge observation; capture is controlled by XKB and CLI rather than profile input fields | Existing capture continues; source failures remain visible in configuration status |
| Snippets | Acknowledge observation; contents belong to the in-memory RPC store | Existing snippets remain available; source failures remain visible in configuration status |
The shared reload boundary classifies changes to sandbox requirements, IPC configuration, cryptography, and an already-adopted installation identity as restart-required. The previous applied snapshot remains available, but these changes cannot report convergence. First-time installation identity adoption is supported without restarting pre-init daemons.
Clipboard retains the latest authenticated default-profile announcement across configuration notifications. Recording pauses while that identity cannot be resolved in the applied configuration, then resumes when its profile becomes available. A configuration notification does not overwrite an already reported default.
Liveness Check
The sesame status command implicitly tests daemon-profile liveness. If the IPC bus is unreachable
(daemon-profile is not running or the socket is missing), the connect() call fails with an error.
This makes sesame status usable as a basic health check in scripts and monitoring systems.
systemd Integration
Type=notify and sd_notify
Daemons use systemd’s Type=notify service type. After completing initialization (config loaded,
IPC connected, indexes built), each daemon calls platform_linux::systemd::notify_ready(), which
sends READY=1 to systemd. This tells systemd that the daemon is ready to accept requests.
Every sandboxed daemon’s Landlock ruleset grants the NOTIFY_SOCKET path
(core_daemon::sandbox::notify_rules) so that sd_notify calls succeed after the sandbox is
applied: from Landlock ABI 9 a pathname socket is reachable only under a rule. The user service
manager’s notification socket is a pathname socket ($XDG_RUNTIME_DIR/systemd/notify); an abstract
one (@-prefixed) would be unreachable under the abstract-socket scope every daemon runs with
(Sandbox Model).
WatchdogSec=30
Daemon-profile runs a tokio interval timer at half the watchdog interval (15 seconds) and calls
platform_linux::systemd::notify_watchdog() on each tick, which sends WATCHDOG=1 to systemd.
If a daemon fails to send a watchdog notification within 30 seconds (two missed ticks), systemd
considers the daemon unresponsive and restarts it according to the unit’s Restart= policy.
The watchdog tick in daemon-profile also serves as the reconciliation driver – every other tick (every 30 seconds), it reconciles state with daemon-secrets.
Reconciliation
Daemon-profile reconciles with daemon-secrets every 30 seconds (every other watchdog tick). The reconciliation RPC updates:
- The global
lockedflag. - The
active_profilesset. - Per-profile lock state.
This ensures that sesame status reports current state even if an IPC event was lost or a daemon
restarted between reconciliation cycles.
Crash-Restart Detection
Daemon-profile tracks daemon identities via DaemonTracker in daemon-profile/src/main.rs. The
tracker maintains a HashMap<String, DaemonId> mapping daemon names to their last known identity.
When a DaemonStarted event arrives from a daemon name that already has a registered DaemonId,
the track() method detects a crash-restart: the old ID differs from the new one. It returns
Some(old_id), allowing daemon-profile to clean up stale state associated with the previous
instance.
Watchdog Logging
Watchdog ticks are logged at info level for the first three ticks and then every 20th tick
(controlled by watchdog_tick_count <= 3 || watchdog_tick_count.is_multiple_of(20)). This provides
startup confirmation without flooding the journal during steady-state operation.
Metrics and Observability
This page describes the metrics and observability design for Open Sesame.
Structured logging is implemented today; metrics export and the
sesame status --doctor command are planned.
Current State
All daemons emit structured log events via the tracing crate. Log output
includes span context (daemon ID, profile name, operation), timestamps, and
severity levels. Logs are written to journald when running under systemd,
or to stderr in development.
Metrics export (Prometheus, OpenTelemetry) is not yet implemented.
Planned Metrics Export
Prometheus
Each daemon will expose a /metrics endpoint on a local Unix socket (not a
TCP port) in Prometheus exposition format. A Prometheus instance or
prometheus-node-exporter textfile collector can scrape these.
OpenTelemetry (OTLP)
For environments with an OTLP collector (Grafana Agent, OpenTelemetry
Collector), daemons will support OTLP export over gRPC or HTTP. This is
configured in ~/.config/pds/observability.toml.
Planned Metric Categories
Daemon Health
| Metric | Type | Description |
|---|---|---|
pds_daemon_uptime_seconds | Gauge | Seconds since daemon start |
pds_daemon_restart_count | Counter | systemd restart count (from watchdog) |
pds_daemon_memory_rss_bytes | Gauge | Resident set size |
pds_daemon_memory_locked_bytes | Gauge | mlock’d memory |
Vault Operations
| Metric | Type | Description |
|---|---|---|
pds_vault_unlock_total | Counter | Unlock attempts (labeled by factor, result) |
pds_vault_unlock_duration_seconds | Histogram | Time to complete unlock |
pds_vault_secret_read_total | Counter | Secret read operations |
pds_vault_secret_write_total | Counter | Secret write operations |
pds_vault_acl_denial_total | Counter | ACL-denied operations |
IPC Throughput
| Metric | Type | Description |
|---|---|---|
pds_ipc_messages_sent_total | Counter | Messages sent (labeled by event kind) |
pds_ipc_messages_received_total | Counter | Messages received |
pds_ipc_message_bytes_total | Counter | Total bytes over the bus |
pds_ipc_request_duration_seconds | Histogram | Request-response round-trip time |
pds_ipc_connections_active | Gauge | Current connected clients |
pds_ipc_clearance_drop_total | Counter | Messages dropped by clearance check |
Memory Protection Posture
| Metric | Type | Description |
|---|---|---|
pds_mlock_limit_bytes | Gauge | Configured LimitMEMLOCK |
pds_mlock_used_bytes | Gauge | Currently locked memory |
pds_seccomp_active | Gauge | 1 if seccomp filter is loaded, 0 otherwise |
pds_landlock_active | Gauge | 1 if Landlock restrictions are active |
sesame status –doctor
The sesame status --doctor command (tracked as issue #20) performs a
comprehensive system health check. The planned implementation runs 43
individual checks across 6 categories.
Check Categories
1. Daemon Liveness
Verifies each daemon process is running, its systemd unit is active, and it
responds to StatusRequest on the IPC bus.
2. IPC Connectivity
Tests Noise IK handshake to the bus server, measures round-trip latency, verifies the socket file exists with correct permissions.
3. Vault Integrity
Checks SQLCipher database integrity, verifies enrolled auth factors match configuration, tests that the vault salt is present and the correct length.
4. Cryptographic Posture
Verifies Noise IK keypairs exist, checks key file permissions (0600),
validates that the ClearanceRegistry is populated, confirms mlock is
available for secret memory.
5. Platform Integration
Checks Wayland session type, verifies COSMIC compositor protocol
availability, tests xdg-desktop-portal connectivity, confirms D-Bus
session bus access.
6. Configuration
Validates TOML configuration against the schema, checks for deprecated keys, verifies file permissions on sensitive config files.
Output Formats
The --doctor command supports multiple output formats:
- Text (default) – Human-readable output with pass/fail/warn indicators and remediation suggestions.
- JSON (
--format json) – Machine-parseable output for CI integration. - Prometheus exposition (
--format prometheus) – Each check becomes a gauge metric (pds_doctor_check{name="...",category="..."}with value 0, 1, or 2 for pass, fail, or warn). - OTLP (
--format otlp) – Exports check results as OpenTelemetry metrics to a configured collector.
Governance Profile Filtering
Checks can be filtered by governance profile to focus on compliance-relevant items:
# Run only STIG-relevant checks
sesame status --doctor --governance stig
# Run PCI-DSS checks, output as JSON
sesame status --doctor --governance pci-dss --format json
# Run SOC2 checks
sesame status --doctor --governance soc2
Each check is tagged with the governance frameworks it is relevant to. For
example, the mlock availability check is relevant to STIG and PCI-DSS but
not SOC2; the audit log integrity check is relevant to all three.
Single Desktop
Open Sesame runs as a full desktop suite on COSMIC/Wayland systems, providing secret management, window management overlays, clipboard isolation, input capture, and application launching across trust profiles.
Package Model
A desktop installation requires both packages:
| Package | Contents |
|---|---|
open-sesame | CLI (sesame), headless daemons: profile, secrets, launcher, snippets |
open-sesame-desktop | Desktop daemons: wm, clipboard, input; Wayland/COSMIC integration |
The open-sesame-desktop package depends on open-sesame. Installing the desktop package
pulls in the headless package automatically.
Installation
APT (Ubuntu 24.04 Noble)
curl -fsSL https://scopecreep-zip.github.io/open-sesame/gpg.key \
| sudo gpg --dearmor -o /usr/share/keyrings/open-sesame.gpg
echo "deb [signed-by=/usr/share/keyrings/open-sesame.gpg] \
https://scopecreep-zip.github.io/open-sesame noble main" \
| sudo tee /etc/apt/sources.list.d/open-sesame.list
sudo apt update
sudo apt install open-sesame open-sesame-desktop
Package integrity is verified via GPG-signed repository indices and SLSA build provenance
attestations generated by GitHub Actions. See SECURITY.md for verification commands.
Nix Flake
nix profile install github:ScopeCreep-zip/open-sesame
Pre-built binaries are available from the scopecreep-zip.cachix.org binary cache with
Ed25519 signing. For home-manager integration, add the flake input and include the Open Sesame
module in the home-manager configuration.
From Source
cargo build --release --workspace
The seven daemon binaries (daemon-profile, daemon-secrets, daemon-launcher,
daemon-snippets, daemon-wm, daemon-clipboard, daemon-input) and the sesame CLI
are placed in target/release/.
Initialization
After installation, initialize the installation identity and default vault:
sesame init
This command performs the following:
- Generates a UUID v4 installation identifier, persisted to
~/.config/pds/installation.tomlas anInstallationConfig(core-config/src/schema_installation.rs). - Derives a deterministic namespace UUID for profile ID generation (
namespacefield). - Creates the default trust profile vault (
vaults/default.db) as a SQLCipher-encrypted database. - Enrolls the first authentication factor (password via Argon2id KDF or SSH agent key).
- Installs and enables systemd user services and targets.
Optionally, an organizational namespace can be provided at init time:
sesame init --org braincraft.io
This populates the org field in installation.toml with the domain and a deterministic
namespace derived as uuid5(NAMESPACE_URL, domain), per the OrgConfig type.
Daemon Architecture
All seven daemons run as systemd user services:
| Daemon | Responsibility | Target | SecurityLevel |
|---|---|---|---|
daemon-profile | IPC bus host, key management, profile activation, audit | Headless | Internal |
daemon-secrets | SQLCipher vaults, ACL, rate limiting | Headless | SecretsOnly |
daemon-launcher | Application launching, frecency scoring | Headless | Internal |
daemon-snippets | Snippet management | Headless | Internal |
daemon-wm | Window management, Alt+Tab overlay | Desktop | Internal |
daemon-clipboard | Clipboard isolation per profile | Desktop | ProfileScoped |
daemon-input | Keyboard/mouse capture, hotkey routing | Desktop | Internal |
Inter-daemon communication uses the Noise IK protocol (X25519 + ChaChaPoly + BLAKE2s) over a
Unix domain socket IPC bus hosted by daemon-profile. Each daemon registers its X25519 static
public key in the clearance registry (core-ipc/src/registry.rs). Messages are routed based on
SecurityLevel ordering: Open < Internal < ProfileScoped < SecretsOnly. A daemon can only
emit messages at or below its own clearance level, and only receives messages at or below its
clearance level.
systemd Targets
Two systemd targets compose the service graph:
| Target | WantedBy | Daemons |
|---|---|---|
open-sesame-headless.target | default.target | profile, secrets, launcher, snippets |
open-sesame-desktop.target | graphical-session.target | wm, clipboard, input |
The desktop target declares Requires=open-sesame-headless.target graphical-session.target.
Starting the desktop target starts all headless daemons first. Stopping the desktop target
leaves headless daemons running, so secret management continues when the graphical session
is inactive.
All daemon services use Type=notify with WatchdogSec=30. Services that fail restart
after RestartSec=5.
Service Dependency Graph
default.target
+-- open-sesame-headless.target
+-- open-sesame-profile.service
+-- open-sesame-secrets.service (Requires/After: profile)
+-- open-sesame-launcher.service (After: profile)
+-- open-sesame-snippets.service (After: profile)
graphical-session.target
+-- open-sesame-desktop.target (Requires: headless)
+-- open-sesame-wm.service
+-- open-sesame-clipboard.service
+-- open-sesame-input.service
File Locations
Configuration
| Path | Purpose |
|---|---|
~/.config/pds/config.toml | User configuration: profiles, crypto, agents, extensions |
~/.config/pds/installation.toml | Installation identity: UUID, namespace, org, machine binding |
~/.config/pds/ssh-agent.env | SSH agent socket path for factor enrollment |
/etc/pds/policy.toml | System policy overrides (enterprise-managed, read-only at runtime) |
Configuration follows layered inheritance: system policy > user config > built-in defaults.
Each PolicyOverride (core-config/src/schema.rs) records a dotted key path, enforced value,
and source string (e.g., /etc/pds/policy.toml).
Runtime
| Path | Purpose |
|---|---|
$XDG_RUNTIME_DIR/pds/ | Runtime directory |
$XDG_RUNTIME_DIR/pds/bus.sock | Noise IK IPC bus socket |
The IPC socket path can be overridden via the global.ipc.socket_path key in config.toml.
Default channel capacity per subscriber is 1024 messages with a 5-second slow-subscriber
timeout (IpcConfig in core-config/src/schema.rs).
Data
| Path | Purpose |
|---|---|
~/.config/pds/vaults/{profile}.db | SQLCipher encrypted vault per trust profile |
~/.config/pds/launcher/{profile}.frecency.db | Application launch frecency database |
~/.config/pds/audit/ | BLAKE3 hash-chained audit log |
Each trust profile name maps 1:1 to a vault file. The TrustProfileName type
(core-types/src/profile.rs) enforces path safety: ASCII alphanumeric plus hyphens and
underscores, max 64 bytes, no path traversal components.
Security Hardening
Each daemon service applies the following systemd directives (see contrib/systemd/*.service):
NoNewPrivileges=yes– prevents privilege escalation.ProtectSystem=strict– mounts the filesystem read-only except explicitReadWritePaths.ProtectHome=read-only– prevents writes outside~/.config/pds/and$XDG_RUNTIME_DIR/pds/.LimitCORE=0– disables core dumps.LimitMEMLOCK=64M– permitsmemfd_secret(2)andmlock(2)allocations for secure memory.MemoryMax– per-daemon ceiling (128M for profile, 256M for secrets).
The secrets daemon additionally declares PrivateNetwork=yes, preventing all network access
from the process that holds decrypted vault keys.
Landlock filesystem sandboxing and seccomp-bpf syscall filtering are applied in-process by each daemon at startup. Partially-enforced Landlock is treated as a fatal error; the daemon does not start with degraded isolation.
Desktop Overlay
On COSMIC desktops, daemon-wm provides an Alt+Tab window switching overlay rendered via the
COSMIC compositor backend (platform-linux). The overlay displays windows scoped to the active
trust profile. Profile switching is routed through the IPC bus at Internal security level.
Verification
After initialization:
# Verify all daemons are healthy
sesame status
# Verify systemd targets
systemctl --user status open-sesame-headless.target
systemctl --user status open-sesame-desktop.target
# Verify IPC bus socket exists
ls -la $XDG_RUNTIME_DIR/pds/bus.sock
# Verify vault was created
ls -la ~/.config/pds/vaults/default.db
Headless Server
Open Sesame operates without a display server, making it suitable for servers, CI/CD runners,
containers, and virtual machines. The headless deployment uses the open-sesame package only,
with no GUI dependencies.
Package
Only the open-sesame package is required. It contains:
sesameCLIdaemon-profile(IPC bus host, key management, audit)daemon-secrets(SQLCipher vaults, ACL, rate limiting)daemon-launcher(application launching, frecency scoring)daemon-snippets(snippet management)
The open-sesame-desktop package is not installed. The three desktop daemons (daemon-wm,
daemon-clipboard, daemon-input) are absent and no Wayland or COSMIC libraries are linked.
Use Cases
CI/CD Secret Injection
Open Sesame injects secrets into build processes as environment variables, scoped by trust profile:
sesame env -p ci-production -- make deploy
The sesame env command activates the named profile, decrypts the vault, and launches the
child process with secrets projected into its environment. The child process inherits only
the secrets defined in the ci-production profile’s vault. On process exit, the secrets are
not persisted anywhere on disk outside the encrypted vault.
Server Credential Management
Long-running services can read secrets at startup or on demand:
# One-shot: print a secret value
sesame secret get -p work database-url
# Launch a service with its secret environment
sesame env -p production -- ./my-service
Container Secret Injection
In container environments, Open Sesame can run as a sidecar or init container that projects secrets into shared volumes or environment:
# In an init container or entrypoint script
sesame init --non-interactive
sesame env -p container -- exec "$@"
systemd Target
The headless target starts on default.target, requiring no graphical session:
# contrib/systemd/open-sesame-headless.target
[Unit]
Description=Open Sesame Headless Suite
# No display server required. Suitable for servers, containers, VMs.
[Install]
WantedBy=default.target
The four headless daemons are PartOf=open-sesame-headless.target. The profile daemon starts
first; secrets, launcher, and snippets declare ordering dependencies on profile.
Starting and Stopping
# Start the headless suite
systemctl --user start open-sesame-headless.target
# Stop all headless daemons
systemctl --user stop open-sesame-headless.target
# Enable on boot
systemctl --user enable open-sesame-headless.target
SSH Agent Forwarding for Remote Vault Unlock
When Open Sesame is installed on a remote server, vault unlock can use an SSH agent key from the operator’s local machine. This avoids storing passwords on the server.
Setup
-
On the remote server, enroll an SSH agent factor during
sesame init:sesame init --auth-factor ssh-agent -
When connecting, forward the SSH agent:
ssh -A user@server -
On the remote server, unlock the vault using the forwarded agent:
sesame unlock -p work --factor ssh-agent
The SSH agent backend (AuthFactorId::SshAgent in core-types/src/auth.rs) produces a
deterministic signature over a challenge, which is processed through
BLAKE3 derive_key("pds v2 ssh-vault-kek {profile}") to produce a KEK. The KEK unwraps the
master key from the EnrollmentBlob stored on disk. The SSH private key never leaves the
local machine.
Multi-Factor on Headless
The AuthCombineMode (core-types/src/auth.rs) supports three modes for headless
environments:
| Mode | Behavior |
|---|---|
Any | Any single enrolled factor unlocks. SSH agent alone suffices. |
All | All enrolled factors required. Both password and SSH agent must be provided. |
Policy | Configurable: e.g., SSH agent always required, plus one additional factor. |
For headless servers where interactive password entry is impractical, enrolling SSH agent as
the sole factor with Any mode provides passwordless unlock gated on SSH key possession.
Configuration
Headless configuration is identical to desktop, minus the window manager, clipboard, and input
sections. The relevant top-level configuration file is ~/.config/pds/config.toml with the
schema defined in core-config/src/schema.rs.
Key headless-specific settings:
[global]
default_profile = "production"
[global.ipc]
# Custom socket path for containerized deployments
# socket_path = "/run/pds/bus.sock"
channel_capacity = 1024
[global.logging]
level = "info"
json = true # Structured output for log aggregation
journald = true # journald integration on systemd hosts
File Locations
| Path | Purpose |
|---|---|
~/.config/pds/config.toml | User configuration |
~/.config/pds/installation.toml | Installation identity |
~/.config/pds/vaults/{profile}.db | Encrypted vaults |
$XDG_RUNTIME_DIR/pds/bus.sock | IPC socket |
~/.config/pds/audit/ | Audit log |
Security Notes
The secrets daemon runs with PrivateNetwork=yes, which is particularly relevant on servers
where network-facing services coexist. Even if an adjacent service is compromised, it cannot
reach the secrets daemon over the network. All access is via the authenticated Noise IK IPC
bus over a Unix domain socket.
On headless systems without memfd_secret(2) support (e.g., older kernels or containers
without CONFIG_SECRETMEM=y), the daemons fall back to mmap(MAP_ANONYMOUS) with mlock(2)
and MADV_DONTDUMP. This fallback is logged at ERROR level with an explicit compliance impact
statement naming the frameworks affected (IL5/IL6, STIG, PCI-DSS) and the remediation command
to enable CONFIG_SECRETMEM.
Headless-First Design
Every sesame CLI command works from explicit primitives without interactive prompts. The CLI
does not assume a terminal is attached. Exit codes, structured JSON output, and non-interactive
flags support automation:
# Non-interactive unlock with SSH agent
sesame unlock -p work --factor ssh-agent --non-interactive
# JSON output for scripting
sesame secret list -p work --json | jq '.[].key'
# Exit code indicates vault lock state
sesame status -p work --quiet; echo $?
Multi-User
Open Sesame supports multiple users on a shared workstation. Each user operates an independent set of daemons, vaults, and IPC buses with hardware-enforced isolation between users.
Per-User Service Instances
Each user runs their own systemd user services. There is no system-wide Open Sesame daemon.
When user alice and user bob both log into the same machine:
- Alice’s
daemon-profilelistens on$XDG_RUNTIME_DIR/pds/bus.sock(typically/run/user/1000/pds/bus.sock). - Bob’s
daemon-profilelistens on/run/user/1001/pds/bus.sock. - Each user’s daemon set is managed by their own
systemctl --userinstance. - The two sets of daemons have no knowledge of each other.
Isolation Boundaries
| Boundary | Mechanism |
|---|---|
| IPC bus | Separate Unix domain sockets under each user’s $XDG_RUNTIME_DIR |
| Configuration | Separate ~/.config/pds/ per user home directory |
| Vaults | Separate SQLCipher databases per user, per profile |
| Audit logs | Separate BLAKE3 hash chains per user |
| Secret memory | memfd_secret(2) pages are per-process; invisible to other UIDs and to root |
| Process isolation | Landlock + seccomp per daemon; ProtectHome=read-only prevents cross-user access |
memfd_secret Isolation
On Linux 5.14+ with CONFIG_SECRETMEM=y, all secret-carrying memory allocations
(SecureBytes, SecureVec, SensitiveBytes) use memfd_secret(2). Pages allocated via
this syscall are:
- Removed from the kernel direct map.
- Invisible to
/proc/pid/memreads. - Inaccessible to kernel modules and DMA.
- Inaccessible via
ptraceeven as root.
This means that even a root-level compromise on the shared workstation cannot read another user’s decrypted secrets from memory. The secrets exist only in the virtual address space of the owning process.
When memfd_secret is unavailable, the fallback is mmap(MAP_ANONYMOUS) with mlock(2) and
MADV_DONTDUMP. This prevents secrets from being swapped to disk or appearing in core dumps,
but does not remove them from the kernel direct map. The fallback is logged at ERROR level
with compliance impact.
RLIMIT_MEMLOCK
Each daemon service sets LimitMEMLOCK=64M (see contrib/systemd/*.service). On a
multi-user workstation, the total memfd_secret and mlock usage is the sum across all
users’ daemon instances. System administrators should verify that the system-wide locked
memory limit and per-user RLIMIT_MEMLOCK (via /etc/security/limits.conf) accommodate
the expected number of concurrent users.
Shared Workstation Model
Separate Vaults, Separate Profiles
Each user has their own InstallationConfig with a distinct installation UUID. Two users on
the same machine have different installation IDs, different vault encryption keys, and
different profile IDs even if both name a profile work. The TrustProfileName maps to a
per-user vault file at ~/.config/pds/vaults/{name}.db.
Hardware Security Key per User
Users can enroll different hardware security keys (FIDO2, YubiKey) as authentication factors.
The AuthFactorId::Fido2 and AuthFactorId::Yubikey variants in core-types/src/auth.rs
support per-user enrollment. A shared YubiKey slot is not assumed; each user’s enrollment
produces a distinct credential ID.
Profile Activation Independence
Profile activation is per-user. Alice activating her corporate profile does not affect
Bob’s active profile. The daemon-profile instance for each user independently evaluates
activation rules (ActivationConfig in core-config/src/schema.rs): WiFi SSID triggers,
USB device presence, time-of-day rules, and security key requirements.
System Policy
Enterprise administrators can enforce organization-wide defaults via /etc/pds/policy.toml.
This file is read-only at runtime and applies to all users on the machine.
# /etc/pds/policy.toml
[[policy]]
key = "crypto.kdf"
value = "argon2id"
source = "enterprise-security-policy"
[[policy]]
key = "audit.enabled"
value = true
source = "enterprise-security-policy"
[[policy]]
key = "clipboard.max_history"
value = 0
source = "enterprise-data-loss-prevention"
Each entry corresponds to a PolicyOverride struct (core-config/src/schema.rs) with a
dotted key path, enforced value, and source identifier. Policy overrides take precedence
over user configuration. Users cannot override a policy-locked key.
Policy Distribution
System policy files are managed by the organization’s configuration management tooling
(Ansible, Puppet, Chef, NixOS modules, or similar). Open Sesame does not implement its own
policy distribution mechanism. The file at /etc/pds/policy.toml is a standard configuration
file managed by the operating system’s package manager or configuration management.
Kernel Requirements
For full multi-user isolation:
| Requirement | Purpose | Verification |
|---|---|---|
| Linux 5.14+ | memfd_secret(2) | uname -r |
CONFIG_SECRETMEM=y | Kernel direct-map removal | grep SECRETMEM /boot/config-$(uname -r) |
| systemd 255+ | Per-user service management | systemctl --version |
| Sufficient RLIMIT_MEMLOCK | Locked memory for all users | ulimit -l |
Auditing in Multi-User Environments
Each user’s audit log is independent. The BLAKE3 hash-chained audit log for a user resides at
~/.config/pds/audit/ under that user’s home directory. Audit verification with
sesame audit verify operates on the current user’s chain only.
For centralized audit collection across all users on a workstation, the structured JSON
logging output (global.logging.json = true) can be forwarded to a central log aggregator
via journald or a sidecar log shipper. Each log entry includes the installation ID, which
uniquely identifies the user’s Open Sesame instance.
Fleet Management
Design Intent. This page describes the architecture for managing Open Sesame across many devices. The primitives referenced below (
InstallationId,OrganizationNamespace,PolicyOverride, structured logging) exist in the type system and configuration schema today. Fleet-scale orchestration tooling that consumes these primitives is not yet implemented.
Overview
Fleet management treats each Open Sesame installation as an independently-operating node that can be configured, monitored, and audited from a central control plane. The design relies on three properties already present in the system:
- Every installation has a globally unique
InstallationId(UUID v4, generated atsesame init), defined incore-types/src/security.rs. - Installations can be grouped by
OrganizationNamespace(domain-derived UUID), enabling fleet-wide identity correlation. - System policy (
/etc/pds/policy.toml) is a static file that can be distributed by configuration management without requiring a running Open Sesame daemon.
Profile and Policy Distribution
Configuration Management Integration
Open Sesame’s configuration is file-based. Fleet-wide profile templates and security policies are distributed as files via existing configuration management tools:
Configuration Management (Ansible/Puppet/Chef/NixOS)
+-- /etc/pds/policy.toml System policy overrides
+-- ~/.config/pds/config.toml User configuration template
+-- ~/.config/pds/installation.toml Pre-seeded installation identity (optional)
The PolicyOverride type (core-config/src/schema.rs) supports locking any configuration
key to an enforced value with a source identifier:
# Enforced by fleet management
[[policy]]
key = "crypto.kdf"
value = "argon2id"
source = "fleet-security-baseline-2025"
[[policy]]
key = "crypto.minimum_peer_profile"
value = "governance-compatible"
source = "fleet-security-baseline-2025"
Pre-Seeded Installation Identity
For fleet provisioning, installation.toml can be pre-generated with a known UUID and
organizational namespace, then distributed to devices before sesame init runs. The
InstallationConfig (core-config/src/schema_installation.rs) fields are:
| Field | Purpose | Fleet Use |
|---|---|---|
id | UUID v4, unique per device | Asset tracking, audit correlation |
namespace | Derived UUID for deterministic profile IDs | Cross-device profile identity |
org.domain | Organization domain | Fleet grouping |
org.namespace | uuid5(NAMESPACE_URL, domain) | Deterministic namespace derivation |
machine_binding.binding_hash | BLAKE3 hash of machine identity material | Hardware attestation |
machine_binding.binding_type | machine-id or tpm-bound | Binding method |
Pre-seeding the org field ensures all fleet devices share a common organizational namespace,
enabling deterministic profile ID generation across the fleet.
Centralized Audit Log Collection
Each Open Sesame installation produces a BLAKE3 hash-chained audit log and structured log output. Fleet-scale audit aggregation uses the existing structured logging infrastructure.
journald and Log Shipping
# config.toml on fleet devices
[global.logging]
level = "info"
json = true
journald = true
With json = true and journald = true, all daemon log entries are structured JSON emitted
to the systemd journal. A log shipper (Promtail, Fluentd, Vector, Filebeat) forwards journal
entries to a central aggregator.
Each structured log entry includes:
installation_id– the device’s UUID frominstallation.toml.daemon_id– which daemon emitted the entry (DaemonIdfromcore-types/src/ids.rs).profile– active trust profile name.event– the operation performed.- Timestamp, severity, and span context.
Audit Chain Verification
The BLAKE3 hash-chained audit log provides tamper evidence at the device level. For fleet-wide integrity verification:
- Collect audit chain files from each device.
- Run
sesame audit verifyagainst each chain independently. - Cross-reference audit entries with centralized log aggregator records.
A broken hash chain on any device indicates tampering or data loss on that device.
Remote Unlock Patterns
Fleet devices may need to be unlocked without physical operator presence.
SSH Agent Forwarding
An operator connects to a fleet device and forwards their SSH agent:
ssh -A operator@fleet-device-042
sesame unlock -p production --factor ssh-agent
The SSH agent factor (AuthFactorId::SshAgent) derives a KEK from the forwarded key’s
deterministic signature without the private key leaving the operator’s machine.
Delegated Factors (Design Intent)
The DelegationGrant type (core-types/src/security.rs) models time-bounded,
scope-narrowed capability delegation. A fleet operator could issue a delegation grant to
an automation agent, authorizing it to unlock specific profiles on specific devices:
DelegationGrant {
delegator: <operator-agent-id>,
scope: CapabilitySet { Unlock },
initial_ttl: 3600s,
heartbeat_interval: 300s,
nonce: <16 random bytes>,
signature: <Ed25519 over grant fields>,
}
The grant’s scope is intersected with the delegator’s own capabilities, ensuring the
automation agent cannot exceed the operator’s authority. The initial_ttl and
heartbeat_interval fields enforce time-bounded access with mandatory renewal.
Fleet Health Monitoring
Daemon Health
All daemons use Type=notify with WatchdogSec=30. systemd restarts unhealthy daemons
automatically. Fleet monitoring collects systemd service states via standard node monitoring
(node_exporter, osquery, or equivalent).
Security Posture Signals
Key posture signals per device:
| Signal | Source | Meaning |
|---|---|---|
memfd_secret availability | Daemon startup log | Whether secrets are removed from kernel direct map |
| Landlock enforcement | Daemon startup log | Whether filesystem sandboxing is active |
| seccomp-bpf active | Daemon startup log | Whether syscall filtering is active |
| Kernel version | uname -r | Whether platform meets minimum requirements |
CONFIG_SECRETMEM=y | /boot/config-* | Kernel compiled with secret memory support |
Devices that log memfd_secret fallback at ERROR level are operating at a reduced security
posture. Fleet management should alert on this condition and schedule kernel upgrades.
Structured Alerting
With JSON-structured logging forwarded to a central aggregator, fleet operators can define alerts on:
- Vault unlock failures (rate limiting triggered).
- Audit chain verification failures.
- Daemon restart loops (watchdog failures).
- Security posture degradation (memfd_secret fallback).
- Policy override conflicts (user config conflicts with fleet policy).
Kubernetes
Design Intent. This page describes how Open Sesame can operate as a secret provider in Kubernetes environments. The type system primitives referenced below (
InstallationId,AgentIdentity,DelegationGrant,Attestation) exist today. The Kubernetes-specific integration components (sidecar container image, CSI driver, admission webhook) are not yet implemented.
Architecture
Open Sesame in Kubernetes operates as a per-pod or per-node secret provider. The headless
daemon set (daemon-profile, daemon-secrets) runs inside a sidecar container or as a
DaemonSet, providing secrets to application containers via environment injection or shared
volumes.
No desktop daemons are deployed. The open-sesame package alone is sufficient.
Sidecar Pattern
The sidecar pattern deploys an Open Sesame container alongside each application pod:
Pod
+-- app-container
| Reads secrets from shared volume or environment
+-- open-sesame-sidecar
daemon-profile, daemon-secrets
Mounts: /run/pds (shared tmpfs)
Mounts: /etc/pds/installation.toml (ConfigMap or Secret)
Mounts: /etc/pds/policy.toml (ConfigMap)
Secret Projection
The sidecar decrypts vault secrets and writes them to a shared tmpfs volume that the
application container mounts:
# Init container or sidecar entrypoint
sesame init --non-interactive --installation /etc/pds/installation.toml
sesame unlock -p $PROFILE --factor ssh-agent --non-interactive
sesame env -p $PROFILE --export-to /run/pds/secrets.env
Alternatively, the sidecar can project secrets as individual files:
/run/pds/secrets/
+-- database-url
+-- api-key
+-- tls-cert
The tmpfs mount ensures secrets are never written to persistent storage on the node.
Kubernetes Secret Objects (Design Intent)
A controller component could synchronize vault contents into native Kubernetes Secret
objects, enabling standard envFrom and volume mount patterns:
Open Sesame Vault (SQLCipher)
--> Controller watches vault changes
--> Creates/updates Kubernetes Secret objects
--> Pods consume via standard envFrom/volumeMount
This approach trades the stronger isolation of the sidecar pattern for compatibility with existing Kubernetes-native workflows.
Pod Identity
Installation ID per Pod
Each pod receives a unique InstallationId via a pre-seeded installation.toml. The
InstallationConfig (core-config/src/schema_installation.rs) for a pod includes:
| Field | Value | Purpose |
|---|---|---|
id | UUID v4, unique per pod instance | Audit trail attribution |
org.domain | Organization domain | Fleet grouping |
machine_binding.binding_type | machine-id | Pod identity binding |
machine_binding.binding_hash | BLAKE3 hash of pod UID + node ID | Anti-migration attestation |
The machine binding hash can incorporate the Kubernetes pod UID and node identity, binding the installation to a specific pod lifecycle. If the pod is rescheduled to a different node, the binding hash does not match, requiring re-attestation.
Workload Attestation (Design Intent)
The Attestation enum (core-types/src/security.rs) includes ProcessAttestation with an
exe_hash field. In Kubernetes, workload attestation extends this concept:
- Container image digest serves as the
exe_hash, verified against a signed manifest. - Service account token provides Kubernetes-native identity.
- Node attestation via TPM or machine binding provides hardware-rooted trust.
These attestation signals compose into a TrustVector (core-types/src/security.rs):
TrustVector {
authn_strength: High, // Service account + image signature
authz_freshness: <since last token rotation>,
delegation_depth: 1, // Delegated from cluster operator
device_posture: 0.8, // Node with TPM but no memfd_secret
network_exposure: Encrypted, // Noise IK over loopback or pod network
agent_type: Service { unit: "my-app-pod" },
}
DaemonSet Pattern (Design Intent)
For clusters where per-pod sidecars are too resource-intensive, a DaemonSet deploys one Open Sesame instance per node:
Node
+-- open-sesame DaemonSet pod
| daemon-profile, daemon-secrets
| Exposes: /run/pds/bus.sock (hostPath)
|
+-- app-pod-1 (mounts /run/pds/bus.sock)
+-- app-pod-2 (mounts /run/pds/bus.sock)
Application pods connect to the node-level IPC bus. Each connecting pod authenticates via
Attestation::UCred (UID/PID from the Unix domain socket) and receives capabilities scoped
to its service account identity.
The SecurityLevel hierarchy (core-types/src/security.rs) ensures that application pods
at Open or Internal clearance cannot read SecretsOnly messages on the shared bus.
Service Mesh Integration (Design Intent)
Open Sesame’s Noise IK transport (core-ipc) provides mutual authentication with forward
secrecy. In service mesh contexts, Noise IK can serve as an alternative to mTLS for
service-to-service communication:
| Property | mTLS (Istio/Linkerd) | Noise IK |
|---|---|---|
| Key exchange | X.509 certificates, CA hierarchy | X25519 static keys, clearance registry |
| Forward secrecy | Per-connection via TLS 1.3 | Per-connection via Noise IK |
| Identity binding | SPIFFE ID in SAN | AgentId + InstallationId |
| Revocation | CRL/OCSP, short-lived certs | Clearance registry generation counter |
| Trust model | Centralized CA | Peer-to-peer, registry-based |
The clearance registry (core-ipc/src/registry.rs) maps X25519 public keys to daemon
identities and security levels. In a Kubernetes context, the registry could be populated
from a shared ConfigMap or CRD, enabling cross-pod Noise IK authentication without a
certificate authority.
Resource Considerations
Sidecar Resources
Minimum resource requests for the Open Sesame sidecar:
| Resource | Request | Limit | Notes |
|---|---|---|---|
| CPU | 10m | 100m | Idle after vault unlock |
| Memory | 32Mi | 128Mi | LimitMEMLOCK=64M for secure memory |
| Ephemeral storage | 10Mi | 50Mi | Vault DB + audit log |
Security Context
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
The Open Sesame daemons apply their own seccomp-bpf filters in-process, layered on top of the Kubernetes-level seccomp profile.
memfd_secret in Containers
memfd_secret(2) requires CONFIG_SECRETMEM=y in the host kernel. Most managed Kubernetes
distributions (GKE, EKS, AKS) use kernels that do not enable this option by default. On these
platforms, Open Sesame falls back to mmap with mlock and logs the security posture
degradation at ERROR level. Operators running on custom node images or bare-metal Kubernetes
can enable CONFIG_SECRETMEM=y for full protection.
Air-Gapped Environments
Design Intent. This page describes operating Open Sesame in air-gapped, SCIF, and offline environments (IL5/IL6 and above). Core vault operations require no network access today. The key ceremony procedures and audit export tooling described below are architectural targets grounded in the existing type system and cryptographic primitives.
Offline-First Architecture
Open Sesame’s core functionality requires no network access. The secrets daemon
(daemon-secrets) runs with PrivateNetwork=yes in its systemd unit, enforcing network
isolation at the kernel level. All inter-daemon communication occurs over a local Unix domain
socket via the Noise IK protocol.
Operations that work fully offline:
- Vault creation, unlock, lock.
- Secret read, write, delete, list.
- Profile activation and switching.
- Audit log generation and verification.
- Application launching with secret injection.
- Clipboard isolation.
The only operations that require network access are SSH agent forwarding (which requires an SSH connection) and extension installation from OCI registries (which can be pre-staged).
memfd_secret as Security Floor
Air-gapped environments operating at IL5/IL6 or within SCIFs require memfd_secret(2) as a
mandatory security control. The kernel must be compiled with CONFIG_SECRETMEM=y.
Verification
# Verify kernel support
grep CONFIG_SECRETMEM /boot/config-$(uname -r)
# Expected: CONFIG_SECRETMEM=y
# Verify at runtime
sesame status --security-posture
On systems where memfd_secret is unavailable, Open Sesame logs at ERROR level with an
explicit compliance impact statement:
ERROR memfd_secret unavailable: secrets remain on kernel direct map.
Compliance impact: does not meet IL5/IL6, DISA STIG, PCI-DSS requirements
for memory isolation. Remediation: enable CONFIG_SECRETMEM=y in kernel config.
For air-gapped deployments, memfd_secret availability should be a deployment gate. Do not
proceed with secret enrollment on systems that report this fallback.
Kernel Configuration
Air-gapped systems should use a hardened kernel with at minimum:
CONFIG_SECRETMEM=y # memfd_secret(2) support
CONFIG_SECURITY_LANDLOCK=y # Landlock filesystem sandboxing
CONFIG_SECCOMP=y # seccomp-bpf syscall filtering
CONFIG_SECCOMP_FILTER=y # BPF filter programs for seccomp
Air-Gapped Key Ceremony
Master Key Generation
In an air-gapped environment, the initial key ceremony is performed on a physically isolated machine:
-
Preparation. Boot the ceremony machine from verified media. Verify kernel supports
memfd_secret. -
Initialization. Run
sesame initto generate theInstallationConfig:- UUID v4 installation identifier.
- Organization namespace (if enterprise-managed).
- Machine binding via
/etc/machine-idor TPM (MachineBindingTypeincore-types/src/security.rs).
-
Factor Enrollment. Enroll authentication factors per the site’s
AuthCombineModepolicy (core-types/src/auth.rs):Password– Argon2id KDF with 19 MiB memory, 2 iterations.SshAgent– Deterministic SSH signature-derived KEK.Fido2,Tpm,Yubikey– Hardware factors (defined inAuthFactorId; backends not yet implemented).
-
Policy Lock. Deploy
/etc/pds/policy.tomlto enforce cryptographic algorithm selection:[[policy]] key = "crypto.kdf" value = "argon2id" source = "airgap-key-ceremony-2025" [[policy]] key = "crypto.minimum_peer_profile" value = "leading-edge" source = "airgap-key-ceremony-2025" -
Verification. Run
sesame statusandsesame audit verifyto confirm the installation is healthy and the audit chain has a valid genesis entry.
Factor Enrollment for “All” Mode
For high-security environments, AuthCombineMode::All requires every enrolled factor to be
present at unlock time. The master key is derived from chaining all factor contributions:
BLAKE3 derive_key("pds v2 combined-master-key {profile}", sorted_factor_pieces)
--> Combined Master Key
This prevents any single compromised factor from unlocking the vault.
Factor Enrollment for “Policy” Mode
The AuthPolicy struct (core-types/src/auth.rs) supports threshold-based unlock:
[auth]
mode = "policy"
[auth.policy]
required = ["password"]
additional_required = 1
# Enrolled: password, ssh-agent, fido2
# Unlock requires: password + (ssh-agent OR fido2)
Audit Chain Export
The BLAKE3 hash-chained audit log provides tamper evidence that can be verified independently. For air-gapped environments where logs cannot be streamed to a central aggregator:
Export Procedure
-
Export. Copy the audit chain from the air-gapped machine to removable media:
cp -r ~/.config/pds/audit/ /media/audit-export/ -
Transfer. Move the removable media through the appropriate security boundary (data diode, manual review, or similar).
-
Verify. On the receiving side, verify the chain integrity:
sesame audit verify --path /media/audit-export/Verification checks that each entry’s BLAKE3 hash chains to the previous entry. Any modification, deletion, or reordering of entries breaks the chain.
Chain Properties
Each audit entry contains:
- Timestamp.
- Operation type (unlock, lock, secret read/write/delete, profile switch).
- Profile name.
- BLAKE3 hash of the previous entry (chain link).
- BLAKE3 hash of the current entry’s contents.
The chain starts from a genesis entry created at sesame init. The hash algorithm is
configurable via CryptoConfigToml.audit_hash (core-config/src/schema_crypto.rs):
BLAKE3 (default) or SHA-256 (governance-compatible).
Compliance Mapping
NIST 800-53
| Control | Open Sesame Mechanism |
|---|---|
| SC-28 (Protection of Information at Rest) | SQLCipher AES-256-CBC + HMAC-SHA512, Argon2id KDF |
| SC-12 (Cryptographic Key Establishment) | BLAKE3 domain-separated key derivation hierarchy |
| SC-13 (Cryptographic Protection) | Config-selectable algorithms via CryptoConfig; governance-compatible profile uses NIST-approved algorithms |
| AU-10 (Non-repudiation) | BLAKE3 hash-chained audit log |
| AC-3 (Access Enforcement) | Per-daemon SecurityLevel clearance, CapabilitySet authorization |
| IA-5 (Authenticator Management) | Multi-factor auth policy (AuthCombineMode), hardware factor support |
DISA STIG
| STIG Control | Open Sesame Mechanism |
|---|---|
| Encrypted storage at rest | SQLCipher vaults, per-profile encryption keys |
| Memory protection | memfd_secret(2), guard pages, volatile zeroize |
| Audit trail integrity | BLAKE3 hash chain, tamper detection |
| Least privilege | Landlock, seccomp-bpf, per-daemon clearance levels |
| No core dumps | LimitCORE=0, MADV_DONTDUMP |
Extension Pre-Staging
In air-gapped environments, WASI extensions cannot be fetched from OCI registries at runtime. Extensions are pre-staged during the provisioning phase:
-
On a connected machine, fetch the extension OCI artifact. The
OciReferencetype (core-types/src/oci.rs) captures registry, principal, scope, revision, and provenance digest:registry.example.com/org/extension:1.0.0@sha256:abc123 -
Transfer the artifact to the air-gapped machine via removable media.
-
Install from the local artifact:
sesame extension install --from-file /media/extensions/extension-1.0.0.wasm
The extension’s content hash (manifest_hash in AgentType::Extension, defined in
core-types/src/security.rs) is verified at load time regardless of how the artifact
was delivered.
Edge and Embedded
Design Intent. This page describes deploying Open Sesame on IoT, embedded, and resource-constrained environments. The headless daemon architecture and ARM64 build targets exist today. Embedded-specific optimizations (reduced memory profiles, static linking, busybox integration) are architectural targets.
Minimal Footprint
Edge deployments use the headless package only. The four headless daemons (daemon-profile,
daemon-secrets, daemon-launcher, daemon-snippets) provide secret management without
GUI dependencies.
For the most constrained environments, only daemon-profile and daemon-secrets are
required. The launcher and snippets daemons are optional if application launching and snippet
management are not needed.
Resource Profile
| Resource | Desktop Default | Edge Target |
|---|---|---|
LimitMEMLOCK | 64M | 8M–16M (configurable) |
MemoryMax (profile) | 128M | 32M |
MemoryMax (secrets) | 256M | 64M |
| IPC channel capacity | 1024 | 64–128 |
| Daemons | 7 | 2–4 |
| Vault count | Multiple profiles | Single profile typical |
The LimitMEMLOCK value in each daemon’s systemd unit controls the maximum memfd_secret
and mlock allocation. Edge devices with limited RAM should reduce this to match available
memory, trading maximum concurrent secret capacity for lower memory pressure.
The IPC channel capacity is configurable via global.ipc.channel_capacity in config.toml
(IpcConfig in core-config/src/schema.rs). Reducing it from the default 1024 lowers
per-subscriber memory usage.
ARM64 Native Builds
Open Sesame builds natively for aarch64-linux. The CI pipeline produces ARM64 .deb
packages and Nix derivations without cross-compilation or QEMU emulation, avoiding the
performance and correctness risks of emulated builds.
Supported Targets
| Target | Status | Use Case |
|---|---|---|
x86_64-linux | Supported | Desktop, server, cloud |
aarch64-linux | Supported | Edge, embedded, ARM servers, Raspberry Pi |
Building for ARM64
# Native build on an ARM64 host
cargo build --release --workspace
# Or install from the APT repository (ARM64 packages available)
sudo apt install open-sesame
Embedded Linux Considerations
systemd Environments
On embedded Linux systems running systemd, Open Sesame’s service files work without modification. Adjust resource limits in the service unit overrides:
systemctl --user edit open-sesame-secrets.service
[Service]
LimitMEMLOCK=16M
MemoryMax=64M
Non-systemd Environments (Design Intent)
Embedded systems using busybox init, OpenRC, or runit do not have systemd user services. For these environments, Open Sesame daemons can be started as supervised processes:
# Direct daemon startup (no systemd)
daemon-profile &
daemon-secrets &
The daemons use sd_notify for systemd integration but do not require it. On non-systemd
systems, the watchdog and notify protocols are inactive; the daemons start and run without
them.
Static Linking (Design Intent)
For minimal embedded root filesystems without a full glibc, static linking with musl is an architectural target:
# Target: static musl binary
cargo build --release --target aarch64-unknown-linux-musl
Static binaries eliminate shared library dependencies, simplifying deployment to embedded images. The primary obstacle is SQLCipher’s C dependency, which requires careful static linking configuration.
Secure Boot Chain
Edge devices in high-security deployments benefit from a layered protection model that roots trust in hardware.
TPM Integration (Design Intent)
The MachineBindingType::TpmBound variant (core-types/src/security.rs) represents
TPM-sealed key material:
MachineBinding {
binding_hash: BLAKE3(tpm_sealed_key || installation_id),
binding_type: TpmBound,
}
TPM-bound installations tie the vault master key to a specific device’s TPM PCR state. If the device’s boot chain is modified (firmware update, rootkit), the PCR values change and the TPM refuses to unseal the key, preventing vault unlock on a compromised device.
Self-Encrypting Drives (SED)
On devices with SED-capable storage, the layered protection model is:
Layer 1: SED hardware encryption (transparent, always-on)
Layer 2: SQLCipher vault encryption (application-level, per-profile keys)
Layer 3: memfd_secret(2) (runtime memory protection, kernel direct-map removal)
Each layer is independent. SED protects data at rest at the storage level. SQLCipher
protects vault files even if the drive is mounted on another system. memfd_secret
protects decrypted secrets in memory even if the OS kernel is partially compromised.
memfd_secret on Edge Kernels
Many embedded Linux distributions use custom or vendor kernels that may not include
CONFIG_SECRETMEM=y. Before deploying Open Sesame to edge devices, verify kernel support:
grep CONFIG_SECRETMEM /boot/config-$(uname -r)
# or, if /boot/config is not available:
zcat /proc/config.gz 2>/dev/null | grep SECRETMEM
For Yocto/Buildroot-based images, add CONFIG_SECRETMEM=y to the kernel defconfig. For
vendor kernels where this is not possible, Open Sesame operates in fallback mode with
mlock(2), logged at ERROR level.
Edge-Specific Configuration
# config.toml for edge deployment
[global]
default_profile = "device"
[global.ipc]
channel_capacity = 64
slow_subscriber_timeout_ms = 2000
[global.logging]
level = "warn" # Reduce log volume on constrained storage
json = true # Structured output for remote collection
journald = false # May not have journald on embedded systems
Connectivity Patterns
Edge devices are often intermittently connected. Open Sesame’s offline-first design means all core operations (vault unlock, secret access, profile switching) work without network connectivity. Network-dependent operations are limited to:
- SSH agent forwarding for remote unlock (requires SSH connection).
- Extension fetching from OCI registries (can be pre-staged).
- Log shipping to central aggregator (buffered locally, forwarded when connected).
- Audit chain export (manual transfer via removable media if never connected).
For permanently air-gapped edge devices, see the Air-Gapped Environments documentation.
Identity Model
Open Sesame’s identity model provides globally unique, collision-resistant identifiers for installations, organizations, profiles, and vaults. The model supports federation across devices and organizations without a central identity provider.
InstallationId
Every Open Sesame installation has a unique identity, defined as InstallationId in
core-types/src/security.rs:
#![allow(unused)]
fn main() {
pub struct InstallationId {
pub id: Uuid, // UUID v4, generated at sesame init
pub org_ns: Option<OrganizationNamespace>, // Enterprise namespace
pub namespace: Uuid, // Derived, for deterministic ID generation
pub machine_binding: Option<MachineBinding>, // Hardware attestation
}
}
The id field is a UUID v4 generated once at sesame init and persisted in
~/.config/pds/installation.toml (InstallationConfig in
core-config/src/schema_installation.rs). It never changes unless the user explicitly
re-initializes.
The namespace field is derived deterministically:
namespace = uuid5(org_ns.namespace || PROFILE_NS, "install:{id}")
This derived namespace seeds deterministic ProfileId generation, ensuring that the same
profile name on two different installations produces different profile IDs.
Properties
| Property | Value |
|---|---|
| Generation | UUID v4 for InstallationId.id; UUID v7 via Uuid::now_v7() for ProfileId, AgentId, and other define_id! types |
| Persistence | ~/.config/pds/installation.toml |
| Scope | One per user per machine |
| Collision resistance | 122 bits of randomness (UUID v4) |
Organization Namespace
The OrganizationNamespace (core-types/src/security.rs) groups installations by
organization:
#![allow(unused)]
fn main() {
pub struct OrganizationNamespace {
pub domain: String, // e.g., "braincraft.io"
pub namespace: Uuid, // uuid5(NAMESPACE_URL, domain)
}
}
The namespace UUID is derived deterministically from the domain string using UUID v5 with the URL namespace. Any installation that specifies the same organization domain produces the same namespace UUID, enabling cross-installation identity correlation without a central registry.
Enrollment
sesame init --org braincraft.io
This writes the OrgConfig to installation.toml:
[org]
domain = "braincraft.io"
namespace = "a1b2c3d4-..." # uuid5(NAMESPACE_URL, "braincraft.io")
Identity Hierarchy
The identity model forms a four-level hierarchy:
Organization (OrganizationNamespace)
+-- Installation (InstallationId)
+-- Profile (TrustProfileName -> ProfileId)
+-- Vault (SQLCipher DB, 1:1 with profile)
Each level narrows scope:
- Organization – optional grouping by domain. Two installations in the same org share a namespace for deterministic ID derivation.
- Installation – a single
sesame initon a single machine for a single user. Identified by UUID v4. - Profile – a trust context (e.g.,
work,personal,ci-production). TheTrustProfileNametype (core-types/src/profile.rs) is a validated, path-safe string: ASCII alphanumeric plus hyphens and underscores, max 64 bytes, no path traversal. TheProfileIdis a UUID v7 generated via thedefine_id!macro (core-types/src/ids.rs). - Vault – a SQLCipher database scoped to one profile. The vault file path is
vaults/{profile_name}.db. The encryption key is derived viaBLAKE3 derive_key("pds v2 vault-key {profile}")from the profile’s master key.
Device Identity
An installation can optionally be bound to a specific machine via MachineBinding
(core-types/src/security.rs):
#![allow(unused)]
fn main() {
pub struct MachineBinding {
pub binding_hash: [u8; 32], // BLAKE3 hash of machine identity material
pub binding_type: MachineBindingType, // MachineId or TpmBound
}
}
Two binding types are defined:
| Type | Source | Portability |
|---|---|---|
MachineId | BLAKE3 hash of /etc/machine-id + installation ID | Survives reboots, not disk clones |
TpmBound | TPM-sealed key material | Survives reboots, tied to hardware TPM |
Machine binding serves two purposes:
-
Attestation. The
Attestation::DeviceAttestationvariant (core-types/src/security.rs) includes aMachineBindingand a verification timestamp. This allows federation peers to verify that an identity claim originates from a specific physical device. -
Migration detection. If an
installation.tomlis copied to a different machine, the machine binding hash does not match/etc/machine-idon the new host. The system detects this and can require re-attestation.
Cross-Device Identity Correlation
Same Organization
Two installations in the same organization (same org.domain) share a derived namespace.
The ProfileRef type (core-types/src/profile.rs) fully qualifies a profile across
installations:
#![allow(unused)]
fn main() {
pub struct ProfileRef {
pub name: TrustProfileName,
pub id: ProfileId,
pub installation: InstallationId,
}
}
A ProfileRef uniquely identifies a profile in a federation context. Two devices with the
same organization and the same profile name work produce different ProfileRef values
because their installation.id fields differ.
Cross-Organization
Installations in different organizations have different namespace derivations. Cross-organization identity correlation requires explicit trust establishment (out-of-band key exchange or mutual attestation), not namespace collision.
ID Generation
The define_id! macro in core-types/src/ids.rs generates typed ID wrappers over UUID v7:
#![allow(unused)]
fn main() {
define_id!(ProfileId, "prof");
define_id!(AgentId, "agent");
define_id!(DaemonId, "dmon");
define_id!(ExtensionId, "ext");
// ... and others
}
Each ID type:
- Wraps a
Uuid(UUID v7 viaUuid::now_v7()). - Displays with a type prefix (e.g.,
prof-01234567-...,agent-89abcdef-...). - Implements
Serialize/Deserializeas a transparent UUID. - Is
Copy,Eq,Hash, andOrd.
UUID v7 is time-ordered, so IDs generated later sort after IDs generated earlier. This provides natural chronological ordering for audit logs and event streams without a separate timestamp field.
Installation Configuration on Disk
The InstallationConfig struct (core-config/src/schema_installation.rs) is the
TOML-serialized form of the installation identity:
# ~/.config/pds/installation.toml
id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
namespace = "fedcba98-7654-3210-fedc-ba9876543210"
[org]
domain = "braincraft.io"
namespace = "12345678-abcd-ef01-2345-6789abcdef01"
[machine_binding]
binding_hash = "a1b2c3d4e5f6..." # hex-encoded BLAKE3 hash
binding_type = "machine-id"
The org and machine_binding sections are optional. A personal desktop installation
without enterprise management or hardware binding omits both:
id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
namespace = "fedcba98-7654-3210-fedc-ba9876543210"
Agent Identity
Open Sesame models every entity that interacts with the system – human operators, AI agents, system services, and WASI extensions – as an agent with a typed identity, local process binding, and capability-scoped session.
AgentId and AgentType
The AgentId type (core-types/src/ids.rs) is a UUID v7 wrapper generated via
define_id!(AgentId, "agent"). Each agent receives a unique identifier at registration
time, displayed with the agent- prefix (e.g., agent-01941c8a-...).
The AgentType enum (core-types/src/security.rs) classifies what kind of entity the
agent is:
#![allow(unused)]
fn main() {
pub enum AgentType {
Human,
AI { model_family: String },
Service { unit: String },
Extension { manifest_hash: [u8; 32] },
}
}
| Variant | Description | Example |
|---|---|---|
Human | Interactive operator with keyboard/mouse | Desktop user |
AI { model_family } | LLM-based agent, API-driven | model_family: "claude-4" |
Service { unit } | systemd service or daemon process | unit: "daemon-launcher.service" |
Extension { manifest_hash } | WASI extension, content-addressed | SHA-256 of the WASM module |
AgentType is descriptive metadata, not a trust tier. An AI agent with proper attestations
and a delegation chain can have higher effective trust than a human agent without a security
key. Trust is evaluated via TrustVector, not AgentType.
Local Process Identity
The LocalAgentId enum (core-types/src/security.rs) binds an agent to a local process:
#![allow(unused)]
fn main() {
pub enum LocalAgentId {
UnixUid(u32),
ProcessIdentity { uid: u32, process_name: String },
SystemdUnit(String),
WasmHash([u8; 32]),
}
}
| Variant | Verification | Use Case |
|---|---|---|
UnixUid | UCred from Unix domain socket | Minimal identity, CLI tools |
ProcessIdentity | UCred + /proc/{pid}/exe inspection | Named processes |
SystemdUnit | systemd unit name lookup | Daemon services |
WasmHash | Content hash of WASM module bytes | Sandboxed extensions |
Local agent identity is established during IPC connection setup. When a process connects to the Noise IK bus, the server extracts UCred (pid, uid, gid) from the Unix domain socket and looks up the connecting process’s identity.
AgentIdentity
The AgentIdentity struct (core-types/src/security.rs) is the complete identity record
for an agent during a session:
#![allow(unused)]
fn main() {
pub struct AgentIdentity {
pub id: AgentId,
pub agent_type: AgentType,
pub local_id: LocalAgentId,
pub installation: InstallationId,
pub attestations: Vec<Attestation>,
pub session_scope: CapabilitySet,
pub delegation_chain: Vec<DelegationLink>,
}
}
| Field | Purpose |
|---|---|
id | Globally unique agent identifier (UUID v7) |
agent_type | Classification: Human, AI, Service, Extension |
local_id | Process-level binding on this machine |
installation | Which Open Sesame installation this agent belongs to |
attestations | Evidence accumulated during this session |
session_scope | Effective capabilities for this session |
delegation_chain | Chain of authority from the root delegator |
AgentMetadata
The AgentMetadata struct (core-types/src/security.rs) describes an agent’s type and the
attestation methods available to it:
#![allow(unused)]
fn main() {
pub struct AgentMetadata {
pub agent_type: AgentType,
pub available_attestation_methods: Vec<AttestationMethod>,
}
}
Available attestation methods vary by agent type:
| Agent Type | Typical Attestation Methods |
|---|---|
Human | MasterPassword, SecurityKey, DeviceAttestation |
AI | Delegation, ProcessAttestation |
Service | ProcessAttestation, DeviceAttestation |
Extension | ProcessAttestation (WASM hash verification) |
The AttestationMethod enum (core-types/src/security.rs) defines the methods:
MasterPassword– password-based, for human agents.SecurityKey– FIDO2/WebAuthn hardware token.ProcessAttestation– process identity verification via/procinspection.Delegation– authority delegated from another agent.DeviceAttestation– machine-level binding (TPM, machine-id).
Attestation
The Attestation enum (core-types/src/security.rs) captures the evidence used to verify
an agent’s identity claim. Each variant records the specific data for one verification
method:
| Variant | Evidence |
|---|---|
UCred | pid, uid, gid from Unix domain socket |
NoiseIK | X25519 public key, registry generation counter |
MasterPassword | Timestamp of successful verification |
SecurityKey | FIDO2 credential ID, verification timestamp |
ProcessAttestation | pid, SHA-256 of executable, uid |
Delegation | Delegator AgentId, granted CapabilitySet, chain depth |
DeviceAttestation | MachineBinding, verification timestamp |
RemoteAttestation | Remote InstallationId, nested remote device attestation |
HeartbeatRenewal | Original attestation type, renewal attestation, renewal timestamp |
Multiple attestations compose to strengthen trust. For example, UCred + MasterPassword
produces a higher TrustLevel in the TrustVector than either alone. The attestations
vector on AgentIdentity accumulates all attestation evidence for the current session.
Machine Agents
Service accounts and AI agents operate as machine agents with restricted capabilities. A
machine agent’s AgentIdentity is established as follows:
-
Registration. The agent is registered with an
AgentId,AgentType, and initialCapabilitySet. For example, a CI runner agent might receive:CapabilitySet { SecretRead { key_pattern: Some("ci/*") }, SecretList } -
Attestation. At connection time, the agent presents attestation evidence. For a
Serviceagent, this isAttestation::ProcessAttestation:#![allow(unused)] fn main() { Attestation::ProcessAttestation { pid: 12345, exe_hash: <SHA-256 of /usr/bin/ci-runner>, uid: 1001, } } -
Session scope. The agent’s
session_scopeis the intersection of its registered capabilities and any delegation grant’s scope. The agent cannot exceed the capabilities it was registered with, and delegation further narrows scope.
Agent Lifecycle
Registration
Agent registration creates an AgentId and associates it with an AgentType and initial
capability set. For built-in daemons, registration is automatic at IPC bus connection via
the clearance registry (core-ipc/src/registry.rs). Each daemon’s X25519 public key maps
to a DaemonId and SecurityLevel.
Key Rotation (Design Intent)
The clearance registry maintains a registry_generation counter. When an agent’s X25519
key pair is rotated:
- The new public key is registered with an incremented generation.
- The old public key is revoked (removed from the registry).
- Peers that cached the old key receive a registry update.
The Attestation::NoiseIK variant records the registry_generation at the time of
verification, enabling peers to detect stale attestations.
Revocation
Revoking an agent removes its public key from the clearance registry. Subsequent connection attempts with the revoked key are rejected. Active sessions using the revoked key continue until the next re-authentication interval.
Human-to-Agent Delegation
A human operator can delegate capabilities to a machine agent via DelegationGrant
(core-types/src/security.rs). The delegation:
- Narrows scope: the delegatee’s effective capabilities are
delegator_scope.intersection(grant.scope). - Is time-bounded:
initial_ttlsets the maximum grant lifetime. - Requires heartbeat:
heartbeat_intervalsets how often the delegatee must renew. - Is signed: Ed25519 signature over grant fields prevents tampering.
- Records depth:
DelegationLink.depthtracks how many hops from the root delegator (0 = direct from human).
See the Delegation documentation for the full delegation model.
Trust Evaluation
Agent trust is not determined by AgentType alone. The TrustVector
(core-types/src/security.rs) evaluates trust across multiple dimensions:
#![allow(unused)]
fn main() {
pub struct TrustVector {
pub authn_strength: TrustLevel, // None < Low < Medium < High < Hardware
pub authz_freshness: Duration, // Time since last authorization refresh
pub delegation_depth: u8, // 0 = direct human
pub device_posture: f64, // 0.0 = unknown, 1.0 = fully attested
pub network_exposure: NetworkTrust, // Local < Encrypted < Onion < PublicInternet
pub agent_type: AgentType, // Metadata, not a trust tier
}
}
Authorization decisions consume the TrustVector holistically. A Service agent on a
local Unix socket with Hardware-level authentication and zero delegation depth may be
trusted more than a Human agent on an encrypted network with Medium authentication
and a stale authorization token.
Delegation
Open Sesame implements capability delegation via the DelegationGrant type, enabling agents
to transfer a subset of their capabilities to other agents with time-bounded, scope-narrowed,
cryptographically signed grants.
DelegationGrant
The DelegationGrant struct is defined in core-types/src/security.rs:
#![allow(unused)]
fn main() {
pub struct DelegationGrant {
pub delegator: AgentId,
pub scope: CapabilitySet,
pub initial_ttl: Duration,
pub heartbeat_interval: Duration,
pub nonce: [u8; 16],
pub point_of_use_filter: Option<OciReference>,
pub signature: Vec<u8>, // Ed25519 signature over the grant fields
}
}
| Field | Purpose |
|---|---|
delegator | The AgentId of the agent issuing the grant |
scope | Maximum capabilities the delegatee may exercise |
initial_ttl | Time-to-live from grant creation; the grant expires after this duration |
heartbeat_interval | How often the delegatee must renew; missed heartbeat revokes the grant |
nonce | 16-byte anti-replay nonce, unique per grant |
point_of_use_filter | Optional OCI reference restricting where the grant can be used |
signature | Ed25519 signature over all other fields by the delegator |
Scope Narrowing
Delegation enforces a fundamental invariant: a delegatee can never exceed its delegator’s capabilities. The delegatee’s effective capabilities are computed as:
effective = delegator_scope.intersection(grant.scope)
The CapabilitySet type (core-types/src/security.rs) implements lattice operations:
| Operation | Method | Semantics |
|---|---|---|
| Union | a.union(b) | All capabilities from both sets |
| Intersection | a.intersection(b) | Only capabilities in both sets |
| Subset test | a.is_subset(b) | True if every capability in a is in b |
| Superset test | a.is_superset(b) | True if every capability in b is in a |
| Empty set | CapabilitySet::empty() | No capabilities |
| Full set | CapabilitySet::all() | All non-parameterized capabilities |
Example
A human operator holds { Admin, SecretRead, SecretWrite, SecretList, Unlock }. The
operator delegates to a CI agent with scope
{ SecretRead { key_pattern: Some("ci/*") }, SecretList }:
Delegator scope: { Admin, SecretRead, SecretWrite, SecretList, Unlock }
Grant scope: { SecretRead { key_pattern: "ci/*" }, SecretList }
Effective: { SecretRead { key_pattern: "ci/*" }, SecretList }
The CI agent can read secrets matching ci/* and list secret keys. It cannot write secrets,
unlock vaults, or perform admin operations, even though the delegator holds those
capabilities.
Parameterized Capabilities
Several capabilities accept optional parameters that further restrict scope:
#![allow(unused)]
fn main() {
Capability::SecretRead { key_pattern: Option<String> }
Capability::SecretWrite { key_pattern: Option<String> }
Capability::SecretDelete { key_pattern: Option<String> }
Capability::Delegate { max_depth: u8, scope: Box<CapabilitySet> }
}
A SecretRead with key_pattern: None permits reading any secret. A SecretRead with
key_pattern: Some("ci/*") restricts reads to keys matching the glob pattern. Delegation
intersection treats parameterized capabilities as more restrictive: the result uses the
narrower pattern.
Time-Bounded Grants
Every DelegationGrant has two temporal controls:
initial_ttl
The grant is valid for initial_ttl from creation time. After this duration, the grant
expires regardless of heartbeat activity. This prevents indefinite capability transfer.
heartbeat_interval
The delegatee must renew the grant at intervals not exceeding heartbeat_interval. A
missed heartbeat revokes the grant. This provides continuous verification that the delegatee
is still active and authorized.
The Attestation::HeartbeatRenewal variant (core-types/src/security.rs) records heartbeat
events:
#![allow(unused)]
fn main() {
Attestation::HeartbeatRenewal {
original_attestation_type: AttestationType,
renewal_attestation: Box<Attestation>,
renewed_at: u64,
}
}
Delegation Chains
Grants can be chained: agent A delegates to agent B, which delegates to agent C. The
DelegationLink struct tracks position in the chain:
#![allow(unused)]
fn main() {
pub struct DelegationLink {
pub grant: DelegationGrant,
pub depth: u8, // 0 = direct from human operator
}
}
The AgentIdentity.delegation_chain field (core-types/src/security.rs) stores the full
chain of DelegationLink entries from the root delegator to the current agent.
Chain Depth Control
The Capability::Delegate variant includes a max_depth field:
#![allow(unused)]
fn main() {
Capability::Delegate {
max_depth: u8,
scope: Box<CapabilitySet>,
}
}
max_depth limits how many times a delegation can be re-delegated. A grant with
max_depth: 2 allows:
Human (depth 0) -> Agent A (depth 1) -> Agent B (depth 2)
Agent B cannot further delegate because depth 2 equals max_depth. This prevents unbounded
delegation chains that would make audit trails difficult to follow.
Chain Verification
To verify a delegation chain:
- Start from the root delegator (depth 0). Verify the root is a known, trusted agent
(typically
AgentType::Human). - For each link in the chain:
- Verify the
signatureover theDelegationGrantfields using the delegator’s Ed25519 public key. - Verify that the grant has not expired (
initial_ttlnot exceeded). - Verify that the heartbeat is current (
heartbeat_intervalnot exceeded). - Verify that
depthdoes not exceed theDelegate.max_depthfrom the delegator’s capability. - Compute effective scope as
previous_scope.intersection(grant.scope).
- Verify the
- The final effective scope is the intersection of all grants in the chain.
Monotonic Narrowing
Each link in the chain can only narrow capabilities, never widen them. The intersection operation guarantees:
scope_n <= scope_{n-1} <= ... <= scope_0
where <= means “is a subset of.” This is a structural property of the lattice:
a.intersection(b).is_subset(a) is always true.
Anti-Replay
Each DelegationGrant contains a 16-byte nonce field. The nonce must be unique across all
grants from a given delegator. A delegation verifier maintains a set of observed nonces and
rejects grants with previously-seen nonces. This prevents replay attacks where a revoked or
expired grant is re-presented.
Point-of-Use Filter
The point_of_use_filter field is an optional OciReference (core-types/src/oci.rs) that
restricts where the delegation can be used:
#![allow(unused)]
fn main() {
pub struct OciReference {
pub registry: String,
pub principal: String,
pub scope: String,
pub revision: String,
pub provenance: Option<String>,
}
}
When present, the delegation is only valid in the context of the specified OCI artifact. This is intended for extension-scoped delegations: a grant that authorizes an extension to read secrets only when running as part of a specific, content-addressed WASM module.
The Delegate Capability
The Capability::Delegate variant is itself a capability that must be held to issue
delegations:
#![allow(unused)]
fn main() {
Capability::Delegate {
max_depth: u8,
scope: Box<CapabilitySet>,
}
}
An agent without Capability::Delegate in its session_scope cannot create
DelegationGrant entries. The scope field within the Delegate capability limits what
the agent can delegate, and max_depth limits the chain length. The ability to delegate is
itself subject to delegation narrowing.
Revocation
Delegation grants are revoked in the following scenarios:
- TTL expiry. The
initial_ttlhas elapsed since grant creation. - Missed heartbeat. The delegatee did not renew within
heartbeat_interval. - Delegator revocation. The delegator explicitly revokes the grant (removes it from the active grant set).
- Chain invalidation. Any link in the delegation chain is revoked, which invalidates all downstream links.
Revocation is immediate and does not require the delegatee’s cooperation. The delegatee’s next operation that requires the revoked capability is denied.
Multi-Cluster Federation
Design Intent. This page describes cross-cluster secret synchronization between Open Sesame installations. The primitives referenced below (
InstallationId,ProfileRef,OrganizationNamespace,CryptoConfig, Noise IK transport) exist in the type system and IPC layer today. The synchronization protocol, conflict resolution logic, and selective sync policies are architectural targets.
Overview
Multi-cluster federation enables multiple Open Sesame installations to share secrets and profiles across trust boundaries. Each installation operates independently and maintains full functionality without connectivity to peers. Synchronization is an additive capability layered on top of the existing single-installation model.
Prerequisites
Federated installations must share an OrganizationNamespace (core-types/src/security.rs).
Installations in different organizations cannot federate without explicit trust establishment.
The shared org namespace ensures deterministic profile ID derivation, so the same profile name
on different installations can be correlated.
Each peer must meet the minimum_peer_profile requirement from CryptoConfig
(core-types/src/crypto.rs):
#![allow(unused)]
fn main() {
pub struct CryptoConfig {
// ...
pub minimum_peer_profile: CryptoProfile, // LeadingEdge, GovernanceCompatible, or Custom
}
}
A peer advertising GovernanceCompatible algorithms (PBKDF2-SHA256, HKDF-SHA256, AES-GCM,
SHA-256) is rejected by an installation requiring LeadingEdge unless the policy explicitly
allows it.
Profile-Scoped Synchronization
Synchronization is scoped to individual trust profiles. The ProfileRef type
(core-types/src/profile.rs) fully qualifies a profile in a federation context:
#![allow(unused)]
fn main() {
pub struct ProfileRef {
pub name: TrustProfileName,
pub id: ProfileId,
pub installation: InstallationId,
}
}
Two installations with the profile work have different ProfileRef values because their
InstallationId fields differ. Federation maps these profiles to each other by matching on
TrustProfileName within the shared org namespace.
Selective Sync Policies (Design Intent)
Not all secrets in a profile need to be synchronized. Selective sync policies control which secrets replicate:
Sync Policy for profile "work":
- sync: secrets matching "shared/*"
- exclude: secrets matching "local/*"
- direction: bidirectional
- peers: [installation-uuid-1, installation-uuid-2]
Secrets matching the local/* pattern remain on the originating installation. Secrets
matching shared/* replicate to specified peers. The policy is configured per-profile and
per-installation.
Conflict Resolution (Design Intent)
When two installations modify the same secret independently (e.g., during a network partition), a conflict arises at synchronization time.
Last-Writer-Wins with Vector Clocks
Each secret carries a vector clock with one entry per installation that has modified it:
Secret "shared/api-key":
Installation A: version 3
Installation B: version 2
On synchronization:
-
No conflict. One vector clock strictly dominates the other (all entries greater or equal, at least one strictly greater). The dominating version wins.
-
Concurrent writes. Neither vector clock dominates. This is a true conflict. Resolution strategy:
- Default: last-writer-wins. The write with the latest wall-clock timestamp wins. The losing version is preserved in a conflict log for manual review.
- Configurable. Future policy options include: reject (require manual resolution), merge (for structured secret formats), or defer to a specific installation.
Conflict Log
All conflicts are recorded in the audit chain with both versions, their vector clocks, and
the resolution applied. The sesame audit verify command can surface unreviewed conflicts.
Split-Brain Handling (Design Intent)
When network connectivity between peers is lost, each installation continues operating independently. This is the normal mode of operation for Open Sesame – the system is designed for offline-first use.
Partition Behavior
During a partition:
- Each installation reads and writes its local vault without restriction.
- No synchronization occurs.
- The audit chain continues recording local operations.
Convergence on Reconnect
When connectivity is restored:
- Each peer advertises its vector clock state for each synchronized profile.
- Peers exchange only the secrets that have changed since the last synchronization point.
- Conflicts are resolved per the configured policy.
- Audit chains from both peers are cross-referenced to build a unified timeline.
The convergence protocol is idempotent: re-running synchronization after a successful sync produces no changes.
Encrypted Replication
All synchronization traffic between peers uses the Noise IK protocol, the same transport used for local IPC. This provides:
| Property | Mechanism |
|---|---|
| Mutual authentication | X25519 static keys, verified against clearance registry |
| Forward secrecy | Per-session Noise IK ephemeral keys |
| Encryption | ChaChaPoly (default) or AES-256-GCM (NoiseCipher in core-types/src/crypto.rs) |
| Integrity | Noise protocol MAC |
| Replay protection | Noise protocol nonce management |
Peer identity is established via the Attestation::RemoteAttestation variant
(core-types/src/security.rs):
#![allow(unused)]
fn main() {
Attestation::RemoteAttestation {
remote_installation: InstallationId,
remote_device_attestation: Box<Attestation>,
}
}
This nests the remote peer’s device attestation (e.g., machine binding, TPM) inside a remote attestation wrapper, providing end-to-end identity verification for the replication channel.
Topology
Federation supports multiple topologies:
Hub-Spoke
A central installation acts as the synchronization hub. Leaf installations sync with the hub only:
Hub
/ | \
A B C
Simpler to manage. The hub is a single point of failure for synchronization (not for local operation).
Mesh
Every installation syncs with every other installation:
A --- B
| X |
C --- D
No single point of failure. Higher bandwidth and complexity. See Mesh Topology for the full mesh design.
Partial Mesh
Selected installations sync with selected peers:
A --- B
|
C --- D
Supports organizational boundaries where teams share a subset of profiles.
Security Considerations
Trust Boundary
Each synchronized secret crosses a trust boundary at the profile level. An installation’s
SecurityLevel hierarchy (Open < Internal < ProfileScoped < SecretsOnly) applies locally.
A remote peer with access to a shared profile can read secrets at the ProfileScoped level
for that profile, but cannot escalate to SecretsOnly on the local installation.
Delegation for Sync Agents
The synchronization agent on each installation operates with a DelegationGrant scoped to
the secrets being synchronized:
DelegationGrant {
delegator: <local-operator>,
scope: { SecretRead { key_pattern: "shared/*" }, SecretWrite { key_pattern: "shared/*" } },
initial_ttl: 86400s,
heartbeat_interval: 3600s,
...
}
This ensures the sync agent cannot access local-only secrets, even if compromised.
Audit Trail
Every secret received from a remote peer is recorded in the local audit chain with the
remote peer’s InstallationId and the grant under which the sync occurred. This provides
a tamper-evident record of which secrets were replicated from where.
Human-Agent Orchestration
Design Intent. This page describes mixed workflows where human operators and AI/service agents collaborate on secret-bearing operations. The agent identity model (
AgentIdentity,AgentType,DelegationGrant,TrustVector) is defined in the type system today. The approval gate mechanisms, escalation protocols, and multi-party authorization described below are architectural targets.
Overview
Open Sesame treats human operators and machine agents as peers in the same identity system.
Both are AgentIdentity instances with typed identities, attestations, capability sets, and
delegation chains. The difference is not in system architecture but in the attestation methods
available and the trust policies applied.
The core principle: agents can perform secret-bearing operations only to the extent that a
human has authorized them, either directly (via DelegationGrant) or via policy.
Agent Types in Orchestration
The AgentType enum (core-types/src/security.rs) defines the entity classification:
| Type | Role in Orchestration |
|---|---|
Human | Approver, delegator, root of trust for capability chains |
AI { model_family } | Automated operations, LLM-driven workflows, copilot actions |
Service { unit } | Background processes, CI/CD pipelines, cron jobs |
Extension { manifest_hash } | WASI plugins operating in a content-addressed sandbox |
Approval Gates (Design Intent)
An approval gate is a policy that requires human authorization before an agent can access a secret or perform a privileged operation.
Gate Model
When an AI or Service agent requests a capability that requires approval:
- The agent submits a request specifying the capability needed and the context (profile, secret key pattern, operation type).
- The request is held in a pending state. The agent blocks or receives a pending response.
- One or more human operators are notified.
- The human reviews the request and either approves (issuing a
DelegationGrant) or denies. - On approval, the agent’s
session_scopeis updated with the granted capabilities for the duration ofinitial_ttl.
Gate Conditions
Approval gates are triggered by the gap between an agent’s session_scope and the
capabilities required for the requested operation:
Agent session_scope: { SecretList, StatusRead }
Requested operation: SecretRead { key_pattern: "production/db-*" }
Gap: { SecretRead { key_pattern: "production/db-*" } }
--> Approval gate triggered
If the agent already holds the required capability (e.g., from a prior delegation), no gate is triggered.
Escalation (Design Intent)
Escalation is the process by which an agent requests elevated capabilities beyond its current session scope.
Escalation Flow
1. Agent detects it needs Capability::Unlock for profile "production"
2. Agent does not hold Unlock in session_scope
3. Agent submits escalation request:
- Requested: { Unlock }
- Context: profile "production", reason "scheduled key rotation"
- Requested TTL: 300s
4. Human operator reviews escalation request
5. Human approves with narrowed scope:
DelegationGrant {
delegator: <human-agent-id>,
scope: { Unlock },
initial_ttl: 300s, // 5 minutes, not the 1 hour requested
heartbeat_interval: 60s,
nonce: <random>,
signature: <Ed25519>,
}
6. Agent's effective scope becomes:
session_scope.union(granted_scope).intersection(delegator_scope)
7. After 300s, the grant expires and the agent loses Unlock
The human can:
- Approve with the requested scope and TTL.
- Approve with a narrower scope or shorter TTL (the human always narrows, never widens).
- Deny the request.
Automatic Escalation Policies (Design Intent)
For well-defined, repetitive workflows, policies can pre-authorize escalation without human-in-the-loop:
# config.toml
[[agents.auto_escalation]]
agent_type = "service"
unit = "backup-agent.service"
capabilities = ["secret-read"]
key_pattern = "backup/*"
max_ttl = "1h"
require_device_attestation = true
This pre-authorization avoids interactive approval for routine operations while maintaining the capability lattice’s scope-narrowing invariant.
Audit Trail
All agent actions are attributed in the audit log. The audit entry for any operation includes:
| Field | Source |
|---|---|
| Agent ID | AgentIdentity.id |
| Agent type | AgentIdentity.agent_type |
| Delegation chain | AgentIdentity.delegation_chain – full chain from root delegator |
| Effective capabilities | AgentIdentity.session_scope at time of operation |
| Operation | The specific action performed (read, write, delete, unlock, etc.) |
| Profile | Which trust profile the operation targeted |
| Timestamp | Operation time |
| Attestations | Which attestation methods were active |
Chain Attribution
For delegated operations, the audit trail records the entire delegation chain:
Audit entry for SecretRead("production/api-key"):
Agent: agent-01941c8a-... (AI, model_family: "claude-4")
Delegation chain:
[0] Human operator-5678 -> DelegationGrant { scope: {SecretRead, SecretList}, ttl: 3600s }
[1] agent-01941c8a-... (current agent)
Attestations: [NoiseIK, Delegation]
This provides full provenance: who authorized the AI agent, what scope was granted, and when the delegation expires.
Multi-Party Authorization (Design Intent)
For critical operations (e.g., deleting a production secret, rotating a root key), multi-party authorization requires approval from multiple human operators.
N-of-M Model
A multi-party policy specifies:
- M – total number of designated approvers.
- N – minimum number who must approve.
- Timeout – how long to wait for approvals before the request expires.
Policy for Capability::SecretDelete { key_pattern: "production/*" }:
Approvers: [operator-A, operator-B, operator-C] (M = 3)
Required: 2 (N = 2)
Timeout: 1 hour
Authorization Flow
- An agent or human requests a capability that matches a multi-party policy.
- All M approvers are notified.
- Each approver independently reviews and approves or denies.
- When N approvals are collected, a composite
DelegationGrantis issued:- The
scopeis the intersection of all approvers’ individual scopes. - The
initial_ttlis the minimum of all approvers’ specified TTLs. - Each approver’s signature is recorded.
- The
- If the timeout expires before N approvals are collected, the request is denied.
Multi-Party Attestation
The Attestation::Delegation variant records the delegator’s AgentId and the granted
scope. For multi-party authorization, multiple Attestation::Delegation entries appear
in the agent’s attestations vector, one per approver.
Trust Vector in Orchestration
The TrustVector (core-types/src/security.rs) provides the quantitative basis for
authorization decisions in mixed human-agent workflows:
| Dimension | Effect on Orchestration |
|---|---|
authn_strength | Higher strength reduces approval gate friction |
authz_freshness | Stale authorization triggers re-approval |
delegation_depth | Deeper chains require stronger attestations at each link |
device_posture | Low posture (no memfd_secret, no TPM) may trigger additional approval requirements |
network_exposure | Remote agents (Encrypted, Onion, PublicInternet) face stricter policies than local agents |
agent_type | Metadata for policy matching, not a trust tier |
Worked Example: AI Copilot Accessing Secrets
-
A developer invokes an AI copilot to debug a production issue.
-
The copilot (
AgentType::AI,model_family: "claude-4") needs to read a database connection string. -
The copilot’s
session_scopedoes not includeSecretReadforproduction/*. -
An approval gate fires. The developer receives a prompt:
Agent "copilot-agent-01941c8a" (AI/claude-4) requests: SecretRead { key_pattern: "production/db-connection" } Reason: "Debugging connection timeout in production service" Approve for 10 minutes? [y/N] -
The developer approves. A
DelegationGrantis issued withinitial_ttl: 600s. -
The copilot reads the secret. The audit log records the read with the full delegation chain.
-
After 10 minutes, the grant expires. The copilot can no longer read production secrets.
Mesh Topology
Design Intent. This page describes a peer-to-peer federation mesh where Open Sesame installations synchronize state without a central authority. The identity model (
InstallationId,OrganizationNamespace), Noise IK transport (core-ipc), and attestation types (Attestation::RemoteAttestation) exist in the type system today. The gossip protocol, CRDT-based state merging, and convergence guarantees described below are architectural targets.
Overview
A mesh topology connects Open Sesame installations as peers where each node can communicate directly with any other node. There is no central server, certificate authority, or coordinator. Trust is established through mutual Noise IK authentication and device attestation. State convergence is achieved through gossip-based propagation and conflict-free replicated data types (CRDTs).
Trust Establishment
Initial Bootstrap
Two installations establish trust through an out-of-band key exchange:
-
Key display. Installation A displays its X25519 static public key and
InstallationId:sesame federation show-identity # Output: # Installation: a1b2c3d4-... # Org: braincraft.io # Public key: base64(X25519 static key) # Machine binding: machine-id (verified) -
Key import. Installation B imports A’s identity:
sesame federation trust --installation a1b2c3d4-... --pubkey base64(...) -
Mutual verification. Both installations perform a Noise IK handshake. Each peer verifies the other’s static key matches the imported value. The
Attestation::RemoteAttestationtype records the result:#![allow(unused)] fn main() { Attestation::RemoteAttestation { remote_installation: InstallationId { id: a1b2c3d4-..., ... }, remote_device_attestation: Box::new(Attestation::DeviceAttestation { binding: MachineBinding { binding_hash: [...], binding_type: MachineId }, verified_at: 1711234567, }), } }
Trust Anchors
Each installation maintains a set of trusted peer identities (public keys + installation IDs). This set is the trust anchor for the mesh. A peer not in the trust set is rejected during Noise IK handshake. Trust anchors can be:
- Manually established (out-of-band, as described above).
- Transitively established (A trusts B, B trusts C, A can choose to trust C based on B’s attestation).
- Organizationally established (all installations in the same
OrganizationNamespaceshare a common trust anchor via policy distribution).
Transitive trust is opt-in and policy-controlled. An installation is never forced to trust a peer it has not explicitly approved or that does not meet its configured policy.
Gossip Protocol (Design Intent)
State changes propagate through the mesh via a gossip protocol.
What is Gossiped
- Profile metadata. Profile names, IDs, and sync policies for synchronized profiles.
- Secret updates. Encrypted secret payloads for profiles configured for synchronization.
- Policy updates. Organization-wide policy changes from
/etc/pds/policy.toml. - Peer identity. New peer introductions (installation ID + public key) for mesh expansion.
- Revocation notices. Key revocation and delegation revocation events.
Gossip Mechanics
- A node produces a state change (e.g., writes a secret to a synchronized profile).
- The node selects a random subset of its known peers (fanout factor, typically 3–5).
- The node sends the update to the selected peers over Noise IK connections.
- Each receiving peer checks whether the update is new (vector clock comparison). If new, the peer applies the update locally and re-gossips to its own random subset of peers.
- Propagation continues until all nodes have seen the update.
Dissemination Guarantees
With a fanout factor of f and n nodes:
- Expected propagation rounds:
O(log_f(n)). - For 100 nodes with fanout 3: approximately 5 rounds to reach all peers.
- Probabilistic guarantee: with sufficient fanout, all nodes receive the update with high probability. Deterministic delivery is not guaranteed per round; convergence is eventual.
CRDT-Based State Merging (Design Intent)
To achieve convergence without coordination, synchronized state uses conflict-free replicated data types.
Secret State as a Map CRDT
Each synchronized profile’s secret store is modeled as a map from secret key to (value, vector clock) pairs:
Profile "work" secrets:
"shared/api-key" -> (encrypted_value, {install_A: 3, install_B: 2})
"shared/db-url" -> (encrypted_value, {install_A: 1})
The CRDT merge rule:
- Concurrent writes to the same key. Last-writer-wins based on wall-clock timestamp, with installation ID as tiebreaker. The losing value is preserved in a conflict log.
- Non-conflicting writes. Different keys or causally ordered writes merge automatically with no conflict.
- Deletes. A tombstone entry replaces the value. Tombstones are retained for a configurable duration (default: 30 days) to ensure propagation across partitioned nodes.
Convergence Properties
| Property | Guarantee |
|---|---|
| Eventual consistency | All connected peers converge to the same state |
| Commutativity | Updates can be applied in any order |
| Idempotency | Re-applying an update has no additional effect |
| Partition tolerance | Nodes operate independently during partitions |
Partition Tolerance
During Partition
Partitioned nodes continue operating independently. Each node:
- Reads and writes its local vault without restriction.
- Records all operations in its local audit chain.
- Queues outgoing gossip messages for delivery when connectivity is restored.
On Reconnect
When a partitioned node reconnects:
- The node exchanges vector clocks with peers to identify divergence.
- Missing updates are transferred in both directions.
- Conflicts (concurrent writes to the same key) are resolved per the CRDT merge rule.
- Audit chains from both sides are cross-referenced.
Convergence Verification
After reconnection, nodes can verify convergence:
sesame federation verify-convergence --profile work
This compares the local state hash with hashes reported by peers. A mismatch indicates an update still in transit or an unresolved conflict.
Peer Discovery and Mesh Expansion
Manual Peer Addition
sesame federation trust --installation <uuid> --pubkey <base64>
Organization-Scoped Discovery (Design Intent)
Within an OrganizationNamespace, peer discovery can be bootstrapped from a shared
configuration distributed via policy:
# /etc/pds/policy.toml
[[policy]]
key = "federation.bootstrap_peers"
value = [
{ installation = "a1b2c3d4-...", pubkey = "base64(...)" },
{ installation = "e5f6a7b8-...", pubkey = "base64(...)" },
]
source = "enterprise-fleet-management"
New installations in the org automatically discover existing peers from the bootstrap list. Each peer still performs mutual Noise IK authentication before sharing state.
Peer Removal
Removing a peer from the trust set:
sesame federation untrust --installation <uuid>
The removed peer’s public key is revoked. Gossip messages from the revoked peer are rejected. Secrets previously shared with the revoked peer remain encrypted in local vaults; they are not retroactively expunged from the peer’s copy.
Security Properties
No Central Authority
There is no CA, no coordinator, and no single point of compromise. Compromising one node does not grant access to other nodes’ local-only secrets. Synchronized secrets are limited to what was explicitly configured for sync.
Forward Secrecy
Each Noise IK connection uses ephemeral keys, providing forward secrecy per session. Compromising a node’s static key does not compromise past session traffic (though it does compromise future sessions until the key is rotated and the old key revoked in peers’ trust sets).
Minimum Peer Crypto Profile
The CryptoConfig.minimum_peer_profile field (core-types/src/crypto.rs) enforces a floor
on the cryptographic algorithms a peer must use:
Local: LeadingEdge (Argon2id, BLAKE3, ChaChaPoly, BLAKE2s)
Peer: GovernanceCompatible (PBKDF2-SHA256, HKDF-SHA256, AES-GCM, SHA-256)
If minimum_peer_profile = LeadingEdge:
--> Peer rejected (does not meet minimum)
If minimum_peer_profile = GovernanceCompatible:
--> Peer accepted
This prevents a mesh node with weak cryptographic configuration from weakening the overall mesh security posture.
Extension System
Open Sesame provides a WASM-based extension system composed of two crates: extension-host (the
runtime) and extension-sdk (the authoring toolkit). Extensions are distributed as OCI artifacts.
Current Implementation Status
Both crates are in early scaffolding phase. The extension-host crate declares its module-level
documentation and dependency structure but contains no runtime logic. The extension-sdk crate
declares its module-level documentation and enforces #![forbid(unsafe_code)] but contains no
bindings or type definitions beyond the crate root. The architectural contracts (crate boundaries,
dependency selections, WIT/OCI integration points) are established; functional implementation is
pending.
extension-host
The extension-host crate provides the Wasmtime-backed runtime for executing WASM component model
extensions with capability-based sandboxing. Each extension runs in its own Store with capabilities
enforced from its manifest.
Dependencies
| Crate | Purpose |
|---|---|
wasmtime | WebAssembly runtime engine with component model support |
wasmtime-wasi | WASI preview 2 implementation for Wasmtime |
core-types | Shared types for the extension/host boundary |
core-config | Configuration loading for extension manifests |
core-ipc | IPC bus client for extension-to-daemon communication |
extension-sdk | Shared type definitions between host and guest |
tokio | Async runtime for extension lifecycle management |
anyhow | Error handling for Wasmtime operations |
Planned Architecture
Based on the crate’s declared dependencies and documentation, the extension host is designed around these components:
- Wasmtime engine with pooling allocator: The
wasmtimedependency provides the core WebAssembly execution engine. Pooling allocation pre-allocates memory slots for extension instances, reducing per-instantiation overhead. - WASI component model: The
wasmtime-wasidependency provides WASI preview 2 support, giving extensions controlled access to filesystem, networking, clocks, and random number generation through capability handles. - Capability sandbox: Each extension’s
Storeis configured with capabilities declared in its manifest. Extensions cannot access resources beyond what their manifest declares. - IPC bus integration: The
core-ipcdependency allows extensions to communicate with daemon processes over the Noise IK encrypted bus, subject to clearance checks.
extension-sdk
The extension-sdk crate provides the types, host function bindings, and WIT interface definitions
that extension authors use to build WASM component model extensions targeting the extension host.
Dependencies
| Crate | Purpose |
|---|---|
core-types | Shared types for the extension/host boundary |
wit-bindgen | Code generation from WIT (WebAssembly Interface Type) definitions |
serde | Serialization for extension configuration and data exchange |
WIT Bindings
The wit-bindgen dependency generates Rust bindings from WIT interface definitions. WIT defines the
contract between extensions (guests) and the extension host: what functions the host exports to
extensions, what functions extensions must implement, and the types exchanged across the boundary.
The SDK crate enforces #![forbid(unsafe_code)] – all unsafe operations are confined to the
generated bindings and the host runtime.
OCI Distribution
Extensions are packaged and distributed as OCI (Open Container Initiative) artifacts. The
OciReference type in core-types (defined in core-types/src/oci.rs) provides the addressing
scheme:
registry/principal/scope:revision[@provenance]
Examples:
registry.example.com/org/extension:1.0.0registry.example.com/org/extension:1.0.0@sha256:abc123
The OciReference type parses and validates this format, requiring at least three path segments
(registry, principal, scope), a non-empty revision after :, and an optional provenance hash after
@. It implements FromStr, Display, Serialize, and Deserialize.
The OCI distribution model allows extensions to be:
- Published to any OCI-compliant registry (Docker Hub, GitHub Container Registry, self-hosted registries).
- Content-addressed via the optional provenance field for integrity verification.
- Version-pinned via the revision field for reproducible deployments.
- Scoped by principal (organization/user) and scope (extension name) for namespace isolation.
Extension Lifecycle
The planned extension lifecycle follows five phases:
- Discover: Resolve an
OciReferenceto a registry, pull the extension artifact, and verify its provenance hash if present. - Load: Parse the WASM component from the artifact. Validate the component’s WIT imports against what the host can provide.
- Sandbox: Create a Wasmtime
Storewith WASI capabilities scoped to the extension’s manifest. Configure resource limits (memory, fuel/instruction count, file descriptors). - Execute: Instantiate the component in the store. Call the extension’s exported entry points. The extension communicates with daemons via host-provided IPC functions.
- Teardown: Drop the store, releasing all resources. The pooling allocator reclaims the memory slot for reuse.
Extension Host Capabilities
The extension-host crate provides the Wasmtime-backed runtime that executes
WASM component model extensions. Each extension runs in an isolated Store
with capabilities enforced from its manifest.
Current Implementation Status
As of this writing, the extension host is scaffolded but not fully wired into
the daemon runtime. The crate declares dependencies on wasmtime,
wasmtime-wasi, core-types, core-config, core-ipc, and extension-sdk.
The public module (extension-host/src/lib.rs) contains documentation comments
describing the intended architecture but no exported functions or types yet.
The sections below describe the design that these crates are being built toward.
Wasmtime Runtime Configuration
The extension host uses Wasmtime as its WebAssembly runtime. The planned configuration includes:
- Cranelift compiler backend – Wasmtime’s default optimizing compiler. Extensions are compiled ahead of time on first load, then cached.
- Component model – Extensions are WASM components (not core modules). This enables typed interfaces via WIT and structured capability passing.
- Pooling allocator – When multiple extensions run concurrently, the
pooling instance allocator pre-reserves virtual address space for all
instances, avoiding per-instantiation
mmapoverhead. Configuration parameters (instance count, memory pages, table elements) are derived from the extension manifest’s declared resource limits.
WASI Sandbox
Each extension Store is configured with a WASI context that restricts what the guest can access. The sandbox follows a deny-by-default model:
| Resource | Default | With Capability Grant |
|---|---|---|
| Filesystem read | Denied | Scoped to declared directories |
| Filesystem write | Denied | Scoped to declared directories |
| Network sockets | Denied | Denied (no current grant path) |
| Environment variables | Denied | Filtered set from manifest |
| Clock (monotonic) | Allowed | Allowed |
| Clock (wall) | Allowed | Allowed |
| Random (CSPRNG) | Allowed | Allowed |
| stdin/stdout/stderr | Redirected to host log | Redirected to host log |
Extensions cannot access the host filesystem, network, or other extensions’ memory unless the host explicitly grants a capability through the WIT interface.
Capability Grants
The host exposes functionality to extensions through WIT-defined interfaces. An extension’s manifest declares which capabilities it requires; the host validates these at load time and links only the granted imports.
Planned capability categories:
- secret-read – Read a named secret from the active vault (routed through daemon-secrets via IPC). The extension never receives the vault master key.
- secret-write – Store or update a secret. Requires explicit user approval on first use.
- config-read – Read configuration values from
core-config. - ipc-publish – Publish an
EventKindmessage to the IPC bus at the extension’s clearance level. - clipboard-write – Write to the clipboard via daemon-clipboard.
- notification – Display a desktop notification.
Each capability is a separate WIT interface. An extension that declares
secret-read but not secret-write receives a linker that provides only
the read import; the write import is left unresolved, causing instantiation
to fail if the guest attempts to call it.
Resource Limits
The host enforces per-extension resource limits to prevent a misbehaving extension from affecting system stability:
- Memory – Maximum linear memory size, configured in the pooling allocator. The default is 64 MiB per extension instance.
- Fuel (CPU) – Wasmtime’s fuel metering limits the number of instructions an extension can execute per invocation. When fuel is exhausted, the call traps with a deterministic error.
- Table elements – Maximum number of indirect function table entries.
- Instances – Maximum number of concurrent component instances across all loaded extensions.
- Execution timeout – A wall-clock deadline per invocation. Implemented via Wasmtime’s epoch interruption mechanism: the host increments the epoch on a timer, and each Store is configured with a maximum epoch delta.
These limits are declared in the extension manifest and validated against
system-wide maximums set in core-config.
Example Extension
This page walks through creating a WASM component model extension for Open Sesame, from WIT interface definition through OCI packaging. Because the extension runtime is not yet fully wired, sections that describe design intent rather than working code are marked accordingly.
Prerequisites
-
Rust toolchain with the
wasm32-wasip2target:rustup target add wasm32-wasip2 -
wasm-toolsfor component composition:cargo install wasm-tools -
An OCI-compatible registry (e.g.,
ghcr.io) for publishing.
Step 1: Define the WIT Interface
Design intent. No
.witfiles ship in the repository yet. Theextension-sdkcrate will provide canonical WIT definitions; what follows is the planned schema.
Create a wit/ directory with the extension’s world:
// wit/world.wit
package open-sesame:example@0.1.0;
world greeting {
import open-sesame:host/config-read@0.1.0;
export greet: func(name: string) -> string;
}
The import line declares that this extension requires the config-read
capability from the host. The export line declares the function the host
will call.
Step 2: Implement the Guest in Rust
Create a new crate:
cargo new --lib greeting-extension
cd greeting-extension
Add dependencies to Cargo.toml:
[package]
name = "greeting-extension"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
wit-bindgen = "0.41"
The extension-sdk crate (extension-sdk/Cargo.toml) depends on
wit-bindgen for generating Rust bindings from WIT definitions. Guest code
uses the wit_bindgen::generate! macro:
#![allow(unused)]
fn main() {
// src/lib.rs
wit_bindgen::generate!({
world: "greeting",
path: "../wit",
});
struct Component;
impl Guest for Component {
fn greet(name: String) -> String {
// Read a greeting template from config (host-provided import).
let template = open_sesame::host::config_read::get("greeting.template")
.unwrap_or_else(|| "Hello, {}!".to_string());
template.replace("{}", &name)
}
}
export!(Component);
}
Step 3: Build the WASM Component
Compile to a core WASM module, then convert to a component:
cargo build --target wasm32-wasip2 --release
wasm-tools component new \
target/wasm32-wasip2/release/greeting_extension.wasm \
-o greeting.component.wasm
The resulting greeting.component.wasm is a self-describing component that
declares its imports and exports in the component model type system.
Step 4: Package as an OCI Artifact
Design intent. OCI distribution is defined in
core-types/src/oci.rsasOciReferencebut the pull/push workflow is not yet implemented.
Open Sesame identifies extensions by OCI references with the format:
registry/principal/scope:revision[@provenance]
For example:
ghcr.io/my-org/greeting-extension:0.1.0@sha256:abcdef1234567890
The OciReference struct parses this into five fields:
| Field | Example | Required |
|---|---|---|
registry | ghcr.io | Yes |
principal | my-org | Yes |
scope | greeting-extension | Yes |
revision | 0.1.0 | Yes |
provenance | sha256:abcdef1234567890 | No |
Push the component to a registry using an OCI-compatible tool:
oras push ghcr.io/my-org/greeting-extension:0.1.0 \
greeting.component.wasm:application/vnd.wasm.component.v1+wasm
Step 5: Write the Extension Manifest
Design intent. The manifest schema is not yet finalized.
The extension manifest declares metadata, capabilities, and resource limits:
[extension]
name = "greeting-extension"
version = "0.1.0"
oci = "ghcr.io/my-org/greeting-extension:0.1.0"
[capabilities]
config-read = true
[limits]
max_memory_mib = 16
max_fuel = 1_000_000
Place this file in ~/.config/pds/extensions/greeting-extension.toml.
Step 6: Load and Test
Design intent. The CLI subcommand for extension management is not yet implemented.
Once the extension host runtime is wired, the intended workflow:
# Install from OCI
sesame extension install ghcr.io/my-org/greeting-extension:0.1.0
# List installed extensions
sesame extension list
# Invoke directly for testing
sesame extension call greeting-extension greet "World"
Testing During Development
Until the full extension host is available, extensions can be tested with standalone Wasmtime:
wasmtime run --wasm component-model greeting.component.wasm \
--invoke greet "World"
For Rust-level unit tests, the extension-sdk crate includes proptest as
a dev-dependency for property-based testing of WIT type serialization.
Authentication Backends
The core-auth crate defines a pluggable authentication system for vault
unlock. Each authentication factor (password, SSH agent, platform keyring) is a struct that
implements the VaultAuthBackend trait. This page describes how to implement
a new backend.
The VaultAuthBackend Trait
The trait is defined in core-auth/src/backend.rs:
#![allow(unused)]
fn main() {
#[async_trait::async_trait]
pub trait VaultAuthBackend: Send + Sync {
fn factor_id(&self) -> AuthFactorId;
fn name(&self) -> &'static str;
fn backend_id(&self) -> &'static str;
fn is_enrolled(&self, profile: &TrustProfileName, layout: &Layout) -> Result<bool, AuthError>;
async fn can_unlock(
&self,
profile: &TrustProfileName,
layout: &Layout,
) -> Result<bool, AuthError>;
fn requires_interaction(&self) -> AuthInteraction;
async fn unlock(
&self,
profile: &TrustProfileName,
layout: &Layout,
keying: &VaultKeying,
) -> Result<UnlockOutcome, AuthError>;
async fn enroll(
&self,
profile: &TrustProfileName,
master_key: &SecureBytes,
layout: &Layout,
keying: &VaultKeying,
credential: Option<&str>,
) -> Result<(), AuthError>;
async fn revoke(&self, profile: &TrustProfileName, layout: &Layout) -> Result<(), AuthError>;
}
}
layout is the core_layout::Layout every vault file path derives from;
keying is the vault’s VaultKeying, its salt and the algorithms its keys
derive under (VaultMetadata::load_keying).
Method Descriptions
factor_id()
The AuthFactorId variant this backend provides. Used in policy evaluation,
in FactorSubmit, and in audit logging.
name()
Human-readable name for audit logs and overlay display ("SSH Agent").
backend_id()
Short machine-readable identifier for IPC messages and configuration
("ssh-agent", "password").
is_enrolled(profile, layout)
Whether the backend’s enrollment file exists. A failure to determine it (for
example, a permission error) is an error, not false.
can_unlock(profile, layout)
Whether the backend can unlock now: it is enrolled and its external
dependency is present. Must complete in under 100 ms. The SSH agent backend
reads its enrollment and checks that a reachable agent holds the enrolled
key; an unreachable agent is false, an agent that answers and fails the
protocol is an error, and an unparseable enrollment is
AuthError::InvalidBlob, naming the file. The platform keyring backend is
ready when enrolled; reaching the store happens in unlock(), which may
raise the keyring’s unlock prompt.
requires_interaction()
An AuthInteraction variant:
AuthInteraction::None– No user interaction (an SSH agent holding a software key, the platform keyring): clients submit the factor at once.AuthInteraction::PasswordEntry– Keyboard input: clients ask for the password.AuthInteraction::HardwareTouch– Physical touch on a hardware device. The CLI and the overlay report such a factor as unsupported.
unlock(profile, layout, keying)
Derives the backend’s key-encrypting key, unwraps the master key from the
enrollment file, and returns an UnlockOutcome. A missing enrollment is
AuthError::NotEnrolled; a wrong key or tampered file is
AuthError::UnwrapFailed.
enroll(profile, master_key, layout, keying, credential)
Wraps master_key under the backend’s key-encrypting key and writes the
enrollment file. credential names which of the backend’s credentials to
enroll: the SSH agent backend requires the key fingerprint (with or without
the SHA256: prefix) and fails with AuthError::BackendNotApplicable
without one. A backend with a single credential ignores it.
revoke(profile, layout)
Zero-fills and removes the enrollment file. An absent enrollment is not an error.
UnlockOutcome
A successful unlock() returns:
#![allow(unused)]
fn main() {
pub struct UnlockOutcome {
pub master_key: SecureBytes,
pub audit_metadata: BTreeMap<String, String>,
pub factor_id: AuthFactorId,
}
}
master_key– The unwrapped 32-byte master key, inSecureBytes(protected allocation, zeroized on drop).audit_metadata– Key-value pairs for audit logging (the SSH agent backend recordsbackend,ssh_fingerprint, andkey_type).factor_id– The factor this outcome represents.
UnlockOutcome::into_factor_submit(profile) produces the one unlock message,
EventKind::FactorSubmit, moving the master key into the message’s protected
allocation without a heap copy. Every backend unlocks this way: the key is
unwrapped client-side, and daemon-secrets receives it as one factor of the
vault’s auth policy.
FactorContribution
The FactorContribution enum states how a factor’s key material participates
in the vault’s policy. VaultMetadata::contribution_type() derives it from
the policy:
CompleteMasterKey(AnyandPolicymodes) – Each factor unwraps a complete, independently valid master key.FactorPiece(Allmode) – Each factor contributes a piece; the master key iscombine_factor_pieces(profile, hkdf, pieces), the vault’shkdfderivation withKeyContext::CombinedMasterKey(profile)over the pieces concatenated inAuthFactorIdorder. Vault creation and unlock both derive it with that one function.
Registration with AuthDispatcher
AuthDispatcher::new(credential_store) (core-auth/src/dispatcher.rs) is the
registry of backends, one per factor. A new backend is added to its list:
#![allow(unused)]
fn main() {
pub fn new(credential_store: Option<Arc<dyn CredentialStore>>) -> Self {
let mut backends: Vec<Box<dyn VaultAuthBackend>> = vec![
Box::new(SshAgentBackend::new()),
Box::new(PasswordBackend::new()),
Box::new(Fido2Backend::new()),
];
if let Some(store) = credential_store {
backends.push(Box::new(PlatformKeyringBackend::new(store)));
}
Self { backends }
}
}
A backend over a platform service does not reach the platform from
core-auth: it takes the service as a core_types interface, implemented by
the platform crate and passed in by the client, as PlatformKeyringBackend
takes the CredentialStore that core_daemon::credential_store() connects.
Without one, the factor has no backend, and a vault requiring it reports the
factor by name. A platform service a sandboxed daemon cannot reach (the
credential store is on the session D-Bus bus) is used through a broker
outside the sandbox, as daemon-wm has daemon-launcher submit the platform
keyring factor (KeyringUnlockRequest).
AuthDispatcher::backend(factor) finds the backend of each factor daemon-secrets
reports a vault still requires (core_auth::remaining_factors); the CLI and
the overlay act on its requires_interaction(). The dispatcher applies no
policy: daemon-secrets owns the vault’s policy. See
Factor Architecture.
Enrollment Files
A backend’s enrollment file lives in the vault directory beside the vault’s
other files, at a path the layout derives:
Layout::vault_file(profile, VaultFile::<Kind>), which is
<config dir>/vaults/<profile>.<extension>. The existing kinds are
PasswordWrap (.password-wrap), SshEnrollment (.ssh-enrollment), and
KeyringEnrollment (.keyring-enrollment); a
new backend adds its own VaultFile variant in core-layout, so the code
that opens the file and the daemon sandboxes that grant access to it derive
the same path.
Enrollment files hold wrapped key material, so they are written, scrubbed,
and removed only through core_layout::file, the one writer of files PDS
owns:
write(path, contents, Mode::OwnerOnly)– creates missing parents0700, writes<path>.tmpwith mode0600, syncs it, renames it overpath, and syncs the directory. On errorpathis unchanged and no temporary remains.destroy(path)– zero-fills the file in place, syncs, and removes it;falsewhen it was absent. A file that cannot be scrubbed is not removed.exists(path)– whether it exists; a failure to determine it is an error.
A backend whose file holds only the wrapped master key uses WrappedKey
(core-auth/src/wrapped_key.rs: version, nonce, AES-256-GCM ciphertext), as
the password and platform keyring backends do, choosing its file with the
VaultFile argument of WrappedKey::load and WrappedKey::save. A backend
that must also record a credential identifier defines its own format, as the
SSH agent backend’s EnrollmentBlob records the key fingerprint and type.
The factor’s command enrolls and revokes it through
open-sesame/src/enrollment.rs: the enrollment is proven by unlocking with it
before the vault metadata records the factor, and a failed enrollment is
revoked (Factor Architecture).
Example: Skeleton FIDO2 Backend
The skeleton below shows the structure of a hypothetical FIDO2 backend. It
assumes a VaultFile::Fido2Enrollment variant, an Fido2Enrollment blob
type, and platform helpers (authenticator_present, make_credential,
hmac_secret) that do not exist in the tree; it does not compile as is.
#![allow(unused)]
fn main() {
use core_auth::{AuthError, AuthInteraction, UnlockOutcome, VaultAuthBackend, VaultKeying};
use core_crypto::SecureBytes;
use core_layout::file::{self, Mode};
use core_layout::{Layout, VaultFile};
use core_types::{AuthFactorId, TrustProfileName};
use std::collections::BTreeMap;
use std::path::PathBuf;
pub struct Fido2Backend;
impl Fido2Backend {
fn enrollment_path(layout: &Layout, profile: &TrustProfileName) -> Result<PathBuf, AuthError> {
Ok(layout.vault_file(profile, VaultFile::Fido2Enrollment)?)
}
}
#[async_trait::async_trait]
impl VaultAuthBackend for Fido2Backend {
fn factor_id(&self) -> AuthFactorId {
AuthFactorId::Fido2
}
fn name(&self) -> &'static str {
"FIDO2 Token"
}
fn backend_id(&self) -> &'static str {
"fido2"
}
fn is_enrolled(&self, profile: &TrustProfileName, layout: &Layout) -> Result<bool, AuthError> {
Ok(file::exists(&Self::enrollment_path(layout, profile)?)?)
}
async fn can_unlock(
&self,
profile: &TrustProfileName,
layout: &Layout,
) -> Result<bool, AuthError> {
// Enrolled, and an authenticator is present; within 100 ms.
Ok(self.is_enrolled(profile, layout)? && authenticator_present().await)
}
fn requires_interaction(&self) -> AuthInteraction {
AuthInteraction::HardwareTouch
}
async fn unlock(
&self,
profile: &TrustProfileName,
layout: &Layout,
keying: &VaultKeying,
) -> Result<UnlockOutcome, AuthError> {
let data = std::fs::read(Self::enrollment_path(layout, profile)?)?;
let enrollment = Fido2Enrollment::deserialize(&data)?;
// The hmac-secret output (user touch) is the key-encrypting key.
let kek = hmac_secret(&enrollment.credential_id, &keying.salt).await?;
let master_key = core_crypto::EncryptionKey::from_bytes(kek.as_bytes())
.map_err(|_| AuthError::UnwrapFailed)?
.decrypt(&enrollment.nonce, &enrollment.ciphertext)
.map_err(|_| AuthError::UnwrapFailed)?;
Ok(UnlockOutcome {
master_key,
audit_metadata: BTreeMap::from([
("backend".into(), "fido2".into()),
("credential_id".into(), enrollment.credential_id_hex()),
]),
factor_id: AuthFactorId::Fido2,
})
}
async fn enroll(
&self,
profile: &TrustProfileName,
master_key: &SecureBytes,
layout: &Layout,
keying: &VaultKeying,
_credential: Option<&str>,
) -> Result<(), AuthError> {
let credential_id = make_credential().await?;
let kek = hmac_secret(&credential_id, &keying.salt).await?;
let (nonce, ciphertext) =
core_crypto::EncryptionKey::from_bytes(kek.as_bytes())?.seal(master_key.as_bytes())?;
let blob = Fido2Enrollment { credential_id, nonce, ciphertext };
file::write(&Self::enrollment_path(layout, profile)?, &blob.serialize()?, Mode::OwnerOnly)?;
Ok(())
}
async fn revoke(&self, profile: &TrustProfileName, layout: &Layout) -> Result<(), AuthError> {
file::destroy(&Self::enrollment_path(layout, profile)?)?;
Ok(())
}
}
}
Testing a New Backend
Tests build a Layout::under(tempdir), so every vault file lands beneath a
temporary root. A backend’s tests cover:
- Enrollment round-trip – Enroll with a known master key;
is_enrolled()istrueand the enrollment file is mode0600. - Unlock round-trip – After enrollment,
unlock()returns the original master key. - Wrong-key rejection – A tampered enrollment file or a different salt
makes
unlock()fail withAuthError::UnwrapFailed. - Damaged enrollment – An unparseable enrollment file is
AuthError::InvalidBlobnaming the file from bothcan_unlock()andunlock(), not a silentfalse. - Revocation – After
revoke(),is_enrolled()isfalseand the file is gone; revoking again succeeds. - Readiness –
can_unlock()isfalsewhen the backing resource is unavailable (no agent socket, no token). - Interaction declaration –
requires_interaction()returns the right variant; the CLI and the overlay use it to decide whether to submit the factor at once, ask for a password, or report a touch as unsupported.
Adding Platform Backends
This page describes how to add a new operating system backend or a new compositor backend within an existing platform crate.
Platform Crate Structure
Open Sesame uses one platform crate per operating system:
| Crate | Target | Status |
|---|---|---|
platform-linux | target_os = "linux" | Implemented: compositor backends, evdev input, D-Bus, systemd, Landlock/seccomp sandbox |
platform-macos | target_os = "macos" | Scaffolded: module declarations with no functional code |
platform-windows | target_os = "windows" | Scaffolded: module declarations with no functional code |
Each crate compiles as an empty library on non-target platforms. All public modules are gated with
#[cfg(target_os = "...")]. Platform crates contain no business logic – they provide safe Rust
abstractions consumed by daemon crates.
Compositor Trait and Factory Pattern
The platform-linux crate demonstrates the reference pattern for abstracting over multiple backends
within a single platform.
The Trait
The CompositorBackend trait in platform-linux/src/compositor.rs defines the interface:
#![allow(unused)]
fn main() {
pub trait CompositorBackend: Send + Sync {
fn list_windows(&self) -> BoxFuture<'_, core_types::Result<Vec<Window>>>;
fn list_workspaces(&self) -> BoxFuture<'_, core_types::Result<Vec<Workspace>>>;
fn activate_window(&self, id: &WindowId) -> BoxFuture<'_, core_types::Result<()>>;
fn set_window_geometry(&self, id: &WindowId, geom: &Geometry)
-> BoxFuture<'_, core_types::Result<()>>;
fn move_to_workspace(&self, id: &WindowId, ws: &CompositorWorkspaceId)
-> BoxFuture<'_, core_types::Result<()>>;
fn focus_window(&self, id: &WindowId) -> BoxFuture<'_, core_types::Result<()>>;
fn close_window(&self, id: &WindowId) -> BoxFuture<'_, core_types::Result<()>>;
fn name(&self) -> &str;
}
}
Methods return BoxFuture (Pin<Box<dyn Future<Output = T> + Send>>) instead of using async fn
in the trait. This is required for dyn-compatibility – the factory function returns
Box<dyn CompositorBackend> for runtime backend selection.
The Factory
detect_compositor() probes the runtime environment and returns the appropriate backend:
#![allow(unused)]
fn main() {
pub fn detect_compositor() -> core_types::Result<Box<dyn CompositorBackend>> {
// 1. Try COSMIC-specific protocols (if cosmic feature enabled)
// 2. Try wlr-foreign-toplevel-management-v1
// 3. Return Error::Platform if nothing works
}
}
Detection order matters: more specific backends are tried first (COSMIC), with generic fallbacks last
(WLR). Each backend’s connect() method probes for required protocols and returns an error if they
are unavailable, allowing the factory to fall through to the next candidate.
Backend Implementations
Each backend is a pub(crate) module containing a struct that implements CompositorBackend:
backend_cosmic.rs–CosmicBackendusingext_foreign_toplevel_list_v1+zcosmic_toplevel_{info,manager}_v1backend_wlr.rs–WlrBackendusingzwlr_foreign_toplevel_manager_v1
Backends are pub(crate) because callers interact with them only through
Box<dyn CompositorBackend> returned by the factory. The concrete types are not part of the
public API.
Adding a New Compositor Backend
To add support for a compositor that uses different protocols (e.g., GNOME/Mutter, KDE/KWin, Hyprland IPC):
Step 1: Create the Backend Module
Create platform-linux/src/backend_<name>.rs with a struct implementing CompositorBackend. The
struct must be Send + Sync.
For operations not supported by the compositor’s protocols, return Error::Platform with a
descriptive message:
#![allow(unused)]
fn main() {
fn set_window_geometry(&self, _id: &WindowId, _geom: &Geometry)
-> BoxFuture<'_, core_types::Result<()>>
{
Box::pin(async {
Err(core_types::Error::Platform(
"set_window_geometry not supported by <name> protocol".into(),
))
})
}
}
Provide a connect() constructor that probes for required protocols/interfaces and returns
core_types::Result<Self>.
Step 2: Register the Module
Add the module declaration to platform-linux/src/lib.rs:
#![allow(unused)]
fn main() {
#[cfg(all(target_os = "linux", feature = "<name>"))]
pub(crate) mod backend_<name>;
}
Step 3: Add the Detection Arm
Add a match arm to detect_compositor() in platform-linux/src/compositor.rs. Place it in the
detection order based on protocol specificity:
#![allow(unused)]
fn main() {
#[cfg(feature = "<name>")]
{
match crate::backend_<name>::<Name>Backend::connect() {
Ok(backend) => {
tracing::info!("compositor backend: <name>");
return Ok(Box::new(backend));
}
Err(e) => {
tracing::info!("<name> backend unavailable, trying next: {e}");
}
}
}
}
Step 4: Add the Feature Flag
In platform-linux/Cargo.toml, add a feature flag for the new backend:
[features]
<name> = [
"desktop",
"dep:<new-protocol-crate>",
]
If the new backend uses only existing dependencies (e.g., communicating via D-Bus with zbus), no
additional optional dependencies are needed.
Feature Gating and Conditional Compilation
Platform crates use a layered feature flag model:
- No features: Headless-safe modules only (sandbox, security, systemd, dbus, keyring, global_shortcuts, cosmic_keys). Suitable for server/container deployments.
desktop: Wayland compositor integration, clipboard capture, evdev input, focus monitoring. Pulls inwayland-client,wayland-protocols,wayland-protocols-wlr,wl-clipboard-rs,evdev.cosmic: COSMIC-specific protocols and the COSMIC theme. Impliesdesktop. Pulls incosmic-client-toolkit,cosmic-protocols(GPL-3.0),cosmic-theme, andcosmic-config.
This layering isolates build dependencies and license obligations. The cosmic feature flag
specifically isolates GPL-3.0 dependencies so that builds without COSMIC support remain under the
project’s base license.
Conditional compilation uses #[cfg(all(target_os = "linux", feature = "..."))] on module
declarations in lib.rs. Backend modules are pub(crate) so they remain internal implementation
details.
Adding a New OS Platform
To add a platform crate for a new operating system:
- Create
platform-<os>/withCargo.tomlandsrc/lib.rs. - Gate all modules with
#[cfg(target_os = "<os>")]. - Depend on
core-typesfor shared types (Window,WindowId,Error,Result). - Implement the same logical modules as the other platform crates (window management, clipboard, input, credential storage, daemon lifecycle). The specific API surface depends on what the OS provides.
- Use
pub(crate)for backend implementation modules; expose only traits and factory functions as the public API. - Add the crate to the workspace
Cargo.toml. - Update daemon crates to conditionally depend on the new platform crate via
[target.'cfg(target_os = "<os>")'.dependencies].
The platform crate should contain no business logic. It provides safe wrappers over OS APIs, and daemon crates compose these wrappers into application behavior.
Nix Packaging
Open Sesame provides a Nix flake (flake.nix) that produces two packages, an overlay, a Home Manager
module, and a development shell. The flake targets x86_64-linux and aarch64-linux.
Flake Structure
The flake uses nixpkgs (nixos-unstable) as its sole input. It exposes the following outputs:
| Output | Description |
|---|---|
packages.<system>.open-sesame | Headless package (CLI + 4 daemons) |
packages.<system>.open-sesame-desktop | Desktop package (3 GUI daemons); depends on headless |
packages.<system>.default | Alias for open-sesame-desktop |
overlays.default | Nixpkgs overlay adding both packages |
homeManagerModules.default | Home Manager module for declarative configuration |
devShells.<system>.default | Development shell with Rust toolchain and native dependencies |
Headless Package (nix/package.nix)
The headless package builds five binary crates with --no-default-features, disabling all
desktop/GUI code paths:
| Crate | Binary |
|---|---|
open-sesame | sesame |
daemon-profile | daemon-profile |
daemon-secrets | daemon-secrets |
daemon-launcher | daemon-launcher |
daemon-snippets | daemon-snippets |
Build dependencies:
- nativeBuildInputs:
pkg-config,installShellFiles - buildInputs:
openssl,libseccomp
The install phase copies the five binaries, the example configuration file, and five systemd user
units (the headless target plus four service files) into $out.
Source filtering uses lib.fileset.unions to include only Cargo.toml, Cargo.lock,
rust-toolchain.toml, config.example.toml, .cargo/, contrib/, and all crate directories
(matched by prefix: core-*, daemon-*, platform-*, extension-*, sesame-*, open-sesame,
xtask). Documentation, analysis files, and CI configuration are excluded.
Desktop Package (nix/package-desktop.nix)
The desktop package builds four binary crates with default features (desktop enabled):
| Crate | Binary |
|---|---|
open-sesame | sesame (rebuilt with desktop features) |
daemon-wm | daemon-wm |
daemon-clipboard | daemon-clipboard |
daemon-input | daemon-input |
Additional build dependencies beyond the headless set:
- nativeBuildInputs: adds
makeWrapper - buildInputs: adds
fontconfig,wayland,wayland-protocols,libxkbcommon - propagatedBuildInputs:
open-sesame(the headless package)
The propagatedBuildInputs declaration ensures the headless binaries (sesame, daemon-profile,
daemon-secrets, daemon-launcher, daemon-snippets) appear on PATH when the desktop package
is installed.
The daemon-wm binary is wrapped with wrapProgram to set XKB_CONFIG_ROOT to
${xkeyboard-config}/etc/X11/xkb. This is required because libxkbcommon needs evdev keyboard
rules at runtime, and the Nix store path differs from the system default.
The install phase copies the three desktop systemd user units (the desktop target plus wm, clipboard,
and input service files) into $out.
cargoLock.outputHashes
Both packages declare outputHashes for three git dependencies that Cargo.lock references:
outputHashes = {
"cosmic-client-toolkit-0.2.0" = "sha256-ymn+BUTTzyHquPn4hvuoA3y1owFj8LVrmsPu2cdkFQ8=";
"cosmic-protocols-0.2.0" = "sha256-ymn+BUTTzyHquPn4hvuoA3y1owFj8LVrmsPu2cdkFQ8=";
"nucleo-0.5.0" = "sha256-Hm4SxtTSBrcWpXrtSqeO0TACbUxq3gizg1zD/6Yw/sI=";
};
The headless package includes these hashes even though it does not build the COSMIC crates, because Cargo.lock references workspace members and Cargo resolves the entire lock file before building.
Home Manager Module
The Home Manager module is available at homeManagerModules.default. It configures Open Sesame
declaratively under programs.open-sesame.
Options
| Option | Type | Default | Description |
|---|---|---|---|
enable | bool | false | Enable the Open Sesame desktop suite |
headless | bool | false | Headless mode: only starts profile, secrets, launcher, and snippets daemons. Omits GUI daemons and graphical-session dependency. |
package | package | auto-selected | Defaults to open-sesame-desktop or open-sesame depending on headless |
settings | TOML attrset | {} | WM key bindings and settings for the default profile |
profiles | attrsOf (tomlFormat.type) | {} | Additional profile configuration keyed by trust profile name |
logLevel | enum | "info" | RUST_LOG level for all daemons. One of: error, warn, info, debug, trace |
Generated Configuration
When settings or profiles are non-empty, the module generates
~/.config/pds/config.toml (via xdg.configFile."pds/config.toml") with config_version = 3.
The settings option populates profiles.default.wm, while profiles allows defining additional
trust profiles with launch profiles and vault configuration.
Systemd Units
The module installs the packages’ own units: the files under $out/lib/systemd/user of
open-sesame (the headless target and the profile, secrets, launcher, and snippets services) and,
unless headless is set, of open-sesame-desktop (the desktop target and the wm, clipboard, and
input services). These are contrib/systemd, with ExecStart patched to the store path: the same
units the .deb, .rpm, and Arch packages ship, that tests/protocol_validation.sh runs every
daemon under, and that CI installs in its systemd containers. Every sandboxing directive
(ProtectSystem, ProtectHome, ReadWritePaths, RestrictAddressFamilies,
InaccessiblePaths, the *Directory= settings, limits, Type) is the unit’s own; the module
writes none.
The unit files are linked into ~/.config/systemd/user, where Home Manager links the units it
generates, together with the links systemctl enable creates from their [Install] sections:
| Link | Unit |
|---|---|
default.target.wants/ | open-sesame-headless.target |
open-sesame-headless.target.wants/ | the four headless services |
graphical-session.target.wants/ | open-sesame-desktop.target (desktop mode) |
open-sesame-desktop.target.wants/ | the three desktop services (desktop mode) |
sd-switch starts and restarts them on activation as it does Home Manager’s own units.
logLevel is a drop-in, <unit>.d/50-log-level.conf, setting Environment=RUST_LOG=<level> over
the unit’s RUST_LOG=info.
The flake’s checks.<system>.home-manager-module (nix/home-manager-check.nix, run by
nix flake check, mise run test:nix, and the Test workflow’s nix job) evaluates the module
through homeManagerConfiguration in desktop and headless mode. It fails if the module generates
an open-sesame unit of its own, links anything that is not a unit file of the mode’s packages,
leaves a shipped unit unlinked, enables a unit for a target other than its [Install] WantedBy=, or
omits a service’s logLevel drop-in.
tmpfiles.d Rules
The units’ ReadWritePaths are bind-mounted into each service’s mount namespace, so each source
directory must exist on the real filesystem. daemon-profile’s unit declares
ConfigurationDirectory=pds, CacheDirectory=open-sesame, and RuntimeDirectory=pds; the other
daemons’ units do not, and fail with 226/NAMESPACE until those directories exist. The module
creates them owner-only, as the daemons keep them:
d %t/pds 0700 - - -
d ${config.xdg.configHome}/pds 0700 - - -
d ${config.xdg.cacheHome}/open-sesame 0700 - - -
In desktop mode, an additional rule creates fontconfig’s cache, which open-sesame-wm.service
grants optionally (ReadWritePaths=-%C/fontconfig):
d ${config.xdg.cacheHome}/fontconfig 0755 - - -
SSH Agent Integration
The module sets systemd.user.sessionVariables.SSH_AUTH_SOCK = "${HOME}/.ssh/agent.sock" to provide
a stable socket path for systemd user services. The daemon-profile and daemon-wm units
additionally load EnvironmentFile=-%E/pds/ssh-agent.env (the leading - makes the file
optional).
Cachix Binary Cache
The flake declares a Cachix binary cache in its nixConfig:
nixConfig = {
extra-substituters = [ "https://scopecreep-zip.cachix.org" ];
extra-trusted-public-keys = [
"scopecreep-zip.cachix.org-1:LPiVDsYXJvgljVfZPN43zBWB7ZCGFr2jZ/lBinnPGvU="
];
};
Users who pass --accept-flake-config (or have the substituter trusted) automatically pull
pre-built binaries for both x86_64-linux and aarch64-linux.
CI pushes to the Cachix cache on every release via the nix.yml workflow using
cachix/cachix-action@v17 with the SCOPE_CREEP_CACHIX_PRIVATE_KEY secret. The same workflow
runs on pull requests for cache warming (build only, no push without the secret).
preCheck
Both packages set preCheck = "export HOME=$(mktemp -d)" to provide test isolation. Tests that
create configuration or runtime directories write to a temporary home instead of interfering with
the build sandbox.
Debian Packaging
Open Sesame ships as two .deb packages built with cargo-deb. The two-package model mirrors the
Nix split: a headless package for servers and containers, and a desktop package that adds GUI daemons
for COSMIC/Wayland.
Package Overview
open-sesame (headless)
Defined in open-sesame/Cargo.toml under [package.metadata.deb].
| Field | Value |
|---|---|
| Package name | open-sesame |
| Section | utils |
| Priority | optional |
| Depends | libc6, libgcc-s1, libseccomp2 |
| Recommends | openssh-client |
| Suggests | open-sesame-desktop |
Installed binaries (to /usr/bin/):
sesame(CLI)daemon-profiledaemon-secretsdaemon-launcherdaemon-snippets
Installed systemd units (to /usr/lib/systemd/user/):
open-sesame-headless.targetopen-sesame-profile.serviceopen-sesame-secrets.serviceopen-sesame-launcher.serviceopen-sesame-snippets.service
Additional assets:
- Man page:
/usr/share/man/man1/sesame.1.gz(generated by xtask) - Shell completions: bash (
/usr/share/bash-completion/completions/sesame), zsh (/usr/share/zsh/vendor-completions/_sesame), and fish (/usr/share/fish/vendor_completions.d/sesame.fish) - Example config:
/usr/share/doc/open-sesame/config.example.toml
Maintainer scripts are sourced from scripts/.
open-sesame-desktop
Defined in daemon-wm/Cargo.toml under [package.metadata.deb].
| Field | Value |
|---|---|
| Package name | open-sesame-desktop |
| Section | utils |
| Priority | optional |
| Depends | open-sesame, libc6, libgcc-s1, libseccomp2, libxkbcommon0, libwayland-client0, libfontconfig1, libfreetype6, fonts-dejavu-core |
| Recommends | xdg-utils, fontconfig |
| Suggests | cosmic-desktop |
The open-sesame dependency ensures the headless daemons and CLI are installed before the desktop
layer.
Installed binaries (to /usr/bin/):
daemon-wmdaemon-clipboarddaemon-input
Installed systemd units (to /usr/lib/systemd/user/):
open-sesame-desktop.targetopen-sesame-wm.serviceopen-sesame-clipboard.serviceopen-sesame-input.service
Maintainer scripts are sourced from scripts/desktop/.
Systemd Targets
open-sesame-headless.target
[Unit]
Description=Open Sesame Headless Suite
Documentation=https://github.com/scopecreep-zip/open-sesame
[Install]
WantedBy=default.target
The headless target is wanted by default.target, meaning it activates on every user login
regardless of whether a graphical session exists. The four headless services declare
PartOf=open-sesame-headless.target.
open-sesame-desktop.target
[Unit]
Description=Open Sesame Desktop Suite
Documentation=https://github.com/scopecreep-zip/open-sesame
Requires=open-sesame-headless.target
BindsTo=graphical-session.target
After=open-sesame-headless.target graphical-session.target
[Install]
WantedBy=graphical-session.target
The desktop target requires the headless target (for IPC bus and secrets infrastructure) and
uses BindsTo=graphical-session.target (for Wayland compositor access). BindsTo= is stronger
than Requires= — it propagates unexpected deactivation (compositor crash) back to the desktop
target, ensuring desktop services tear down when the graphical session exits ungracefully. It is
wanted by graphical-session.target, so it only activates when a graphical session starts.
Service Hardening
All services in contrib/systemd/ use Type=notify with WatchdogSec=30, Restart=on-failure,
RestartSec=5, and NoNewPrivileges=yes. Resource limits include LimitMEMLOCK=64M (for
mlock-backed protected allocations), LimitCORE=0 (prevents core dumps), and MemoryMax caps
per daemon.
The daemon-profile service, which hosts the IPC bus, sets ProtectHome=read-only and
ProtectSystem=strict with ReadWritePaths=%t/pds %h/.config/pds.
Maintainer Scripts
Headless Package
postinst (scripts/postinst):
- Enables services globally with
systemctl --global enablefor the four headless services and the headless target. This persists across future logins and new users. - Reloads all active user managers with
systemctl reload 'user@*.service'so they see the new unit files. - Iterates over all currently logged-in users (by parsing UIDs from
systemctl list-units 'user@*') and restarts each headless service usingsystemctl --user -M "$uid@"with aSYSTEMD_BUS_TIMEOUT=25stimeout.
prerm (scripts/prerm):
- On
remove|deconfigure: stops all headless services for active users in reverse dependency order (snippets, launcher, secrets, profile), then disables globally. - On
upgrade: stops services only (does not disable). The postinst of the new version restarts with new binaries.
postrm (scripts/postrm):
- On
remove|purge: reloads user managers to clear removed unit files. Prints a message noting that user configuration at~/.config/pds/is preserved.
Desktop Package
postinst (scripts/desktop/postinst):
- Enables desktop services globally:
open-sesame-wm.service,open-sesame-clipboard.service,open-sesame-input.service,open-sesame-desktop.target. - Reloads active user managers.
- Restarts desktop services for all active users.
- Prints a note that
daemon-inputrequiresinputgroup membership for keyboard capture.
prerm (scripts/desktop/prerm):
- On
remove|deconfigure: stops desktop services (input, clipboard, wm) for active users, then disables globally. - On
upgrade: stops services only.
postrm (scripts/desktop/postrm):
- On
remove|purge: reloads user managers. Notes that headless daemons remain installed.
User Iteration Pattern
All maintainer scripts use the same active_user_uids() helper to discover logged-in users:
active_user_uids() {
systemctl list-units 'user@*' --legend=no 2>/dev/null \
| sed -n 's/.*user@\([0-9]\+\)\.service.*/\1/p'
}
This pattern is derived from systemd-update-helper.in and ensures services are managed for all
active user sessions, not just the invoking user.
RPM Packaging
Open Sesame ships as two .rpm packages built with cargo-generate-rpm. The two-package model
mirrors the Nix and Debian splits: a headless package for servers and containers, and a desktop
package that adds GUI daemons for COSMIC/Wayland.
Package Overview
open-sesame (headless)
Defined in open-sesame/Cargo.toml under [package.metadata.generate-rpm].
| Field | Value |
|---|---|
| Package name | open-sesame |
| Vendor | scopecreep.zip |
| Requires | glibc, libgcc, libseccomp |
| Recommends | openssh-clients |
| Suggests | open-sesame-desktop |
Installed binaries (to /usr/bin/):
sesame(CLI)daemon-profiledaemon-secretsdaemon-launcherdaemon-snippets
Installed systemd units (to /usr/lib/systemd/user/):
open-sesame-headless.targetopen-sesame-profile.serviceopen-sesame-secrets.serviceopen-sesame-launcher.serviceopen-sesame-snippets.service
Installed preset (to /usr/lib/systemd/user-preset/):
90-open-sesame.preset
Additional assets:
- Man page:
/usr/share/man/man1/sesame.1.gz - Shell completions: bash, zsh (
site-functions), fish - Example config:
/usr/share/doc/open-sesame/config.example.toml
open-sesame-desktop
Defined in daemon-wm/Cargo.toml under [package.metadata.generate-rpm].
| Field | Value |
|---|---|
| Package name | open-sesame-desktop |
| Vendor | scopecreep.zip |
| Requires | glibc, libgcc, libseccomp, libxkbcommon, libwayland-client, fontconfig, freetype |
| Recommends | xdg-utils, dejavu-sans-fonts |
Installed binaries (to /usr/bin/):
daemon-wmdaemon-clipboarddaemon-input
Installed systemd units (to /usr/lib/systemd/user/):
open-sesame-desktop.targetopen-sesame-wm.serviceopen-sesame-clipboard.serviceopen-sesame-input.service
cargo-generate-rpm
Open Sesame uses cargo-generate-rpm instead of rpmbuild with spec files. This tool reads
package metadata from [package.metadata.generate-rpm] in Cargo.toml and produces .rpm files
directly using the rpm crate. No spec file, no rpmbuild dependency.
Key configuration:
auto-req = "no"disables automatic shared library dependency detection. CI builds run on Ubuntu runners wherelddproduces Debian-style soname dependencies rather than Fedora package names. Dependencies are declared explicitly in[package.metadata.generate-rpm.requires].- Payload compression defaults to zstd (compatible with Fedora 30+ / rpm 4.14+).
- Scriptlet fields accept file paths to external scripts under
scripts/rpm/.
Build workflow:
cargo build --release
cargo generate-rpm -p open-sesame
cargo generate-rpm -p daemon-wm
Output location: target/generate-rpm/*.rpm. With --target x86_64-unknown-linux-gnu:
target/x86_64-unknown-linux-gnu/generate-rpm/*.rpm.
RPM Scriptlet Semantics
RPM scriptlets receive a numeric $1 argument indicating the package count after the operation
completes. This differs from Debian maintainer scripts which receive string arguments like
configure or remove.
$1 Values
| Scriptlet | Install | Upgrade | Remove |
|---|---|---|---|
%pre | 1 | 2 | (N/A) |
%post | 1 | 2 | (N/A) |
%preun | (N/A) | 1 | 0 |
%postun | (N/A) | 1 | 0 |
%posttrans | 0 | 0 | (N/A) |
Upgrade Transaction Ordering
During a single-package upgrade, scriptlets execute in this order:
%pretransof new package%preof new package- (install new files)
%postof new package%preunof old package- (remove old files)
%postunof old package%posttransof new package
New %post runs BEFORE old %preun. This means during upgrade, new services are enabled before
old services are stopped. The %posttrans slot runs after all packages in the transaction
complete, making it the correct place for service restarts.
systemd-update-helper
Open Sesame RPM scriptlets call /usr/lib/systemd/systemd-update-helper directly. This is the
same helper that Fedora’s %systemd_user_post / %systemd_user_preun macros expand to.
cargo-generate-rpm embeds scriptlets verbatim without rpmbuild’s macro parser, so RPM macros
like %systemd_user_post would be inserted as literal non-functional text.
The helper manages preset-based enablement via install-user-units, removal via
remove-user-units, and restart marking via mark-restart-user-units. The [ -x ... ] guard
ensures graceful no-op on non-Fedora systems where the helper does not exist.
Scriptlet Design
%post: callsinstall-user-unitson first install ($1 -eq 1), reloads user managers, restarts services for all active users via per-uidsystemctl --user -M "$uid@"loop%preun: stops services for all active users in reverse dependency order, then callsremove-user-unitson final removal ($1 -eq 0)%postun: reloads user managers on final removal%posttrans: callsmark-restart-user-unitsto restart services after transaction completes
All scriptlets exit zero unconditionally (trailing :). Non-zero exits from RPM scriptlets
stop processing of that package in the transaction with no rollback capability.
Preset File
Each package ships its own preset file to avoid RPM file conflicts:
| Preset | Package | Units |
|---|---|---|
90-open-sesame.preset | open-sesame | profile, secrets, launcher, snippets, headless target |
90-open-sesame-desktop.preset | open-sesame-desktop | wm, clipboard, input, desktop target |
Both install to /usr/lib/systemd/user-preset/. systemd-update-helper install-user-units
reads these files to determine default enablement state. Administrators override via
higher-priority presets in /etc/systemd/user-preset/.
DNF Repository
The DNF repository is hosted on GitHub Pages alongside the APT repository and documentation.
Generated by the ci:release:rpm-repo mise task during the publish job.
Repository Structure
gh-pages/
repo/
*.rpm
repodata/
repomd.xml
primary.xml.gz
filelists.xml.gz
other.xml.gz
manifest.txt
RPM-GPG-KEY
index.html
RPM-GPG-KEY
Client Configuration
Create /etc/yum.repos.d/open-sesame.repo:
[open-sesame]
name=Open Sesame RPMs (GitHub Pages)
baseurl=https://scopecreep-zip.github.io/open-sesame/repo/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-open-sesame
Import the GPG key:
sudo curl -fsSL https://scopecreep-zip.github.io/open-sesame/RPM-GPG-KEY \
-o /etc/pki/rpm-gpg/RPM-GPG-KEY-open-sesame
Install:
sudo dnf install -y open-sesame open-sesame-desktop
Signing
RPM packages are signed at build time using cargo-generate-rpm --signing-key, which produces
V4 RSA/SHA256 header+payload signatures via the rpm crate’s signature-pgp feature. The same
GPG key used for APT Release signing is exported to a temporary file and passed to
cargo generate-rpm in the CI build job. The scripts/rpm/sign-rpms.sh script provides an
alternative rpmsign-based signing path for environments where native cargo-generate-rpm signing
is unavailable (e.g., re-signing after the fact).
Metadata Generation
Repository metadata is generated by createrepo_c (installed from Ubuntu’s universe
repository). Version 0.17.3 defaults to gzip compression for metadata. All RPMs regardless of
architecture are indexed into a single repodata/ set — DNF filters by $basearch at install
time from each package’s arch tag.
Verification
Package Signature
rpm --checksig -v open-sesame-linux-x86_64.rpm
SLSA Build Provenance
gh attestation verify open-sesame-linux-x86_64.rpm --owner ScopeCreep-zip
Checksum
sha256sum -c SHA256SUMS.txt
Comparison with Debian Scriptlets
| Concern | Debian (dpkg) | RPM |
|---|---|---|
| Argument type | String (configure, remove, upgrade) | Numeric ($1: package count) |
| Install detection | case "$1" in configure) | if [ "$1" -eq 1 ] |
| Remove detection | case "$1" in remove) | if [ "$1" -eq 0 ] |
| Upgrade ordering | old prerm → new postinst | new %post → old %preun |
| End-of-transaction | (none) | %posttrans |
| Failure behavior | Configurable via set -e | Non-zero stops package processing, no rollback |
| Macro expansion | Debhelper #DEBHELPER# | rpmbuild %macros (not available in cargo-generate-rpm) |
Arch Linux Packaging
Open Sesame provides binary packages for Arch Linux via the AUR and a self-hosted pacman repository on GitHub Pages. The two-package split mirrors the Debian, RPM, and Nix distributions.
Package Overview
open-sesame-bin (AUR)
Split pkgbase producing two packages from release tarballs:
| Package | Description |
|---|---|
open-sesame-bin | Headless: sesame CLI, 4 daemon binaries, systemd units, preset, man page, completions |
open-sesame-desktop-bin | Desktop: 3 GUI daemons, systemd units, preset. Depends on open-sesame (satisfied by either -bin or source) |
provides=('open-sesame') / provides=('open-sesame-desktop') and
conflicts=('open-sesame' 'sesame') / conflicts=('open-sesame-desktop').
The sesame conflict is declared because AUR package sesame (an xdg-open replacement)
installs /usr/bin/sesame at the same path.
Dependencies
| Dependency | Arch package |
|---|---|
| C library | glibc |
| GCC runtime | gcc-libs |
| seccomp | libseccomp |
| Wayland client | wayland |
| XKB | libxkbcommon |
| fontconfig | fontconfig |
| freetype | freetype2 |
| SSH client | openssh (optional) |
| DejaVu font | ttf-dejavu (optional) |
Installation
AUR (recommended)
Using an AUR helper:
yay -S open-sesame-bin open-sesame-desktop-bin
Or manually:
git clone https://aur.archlinux.org/open-sesame-bin.git
cd open-sesame-bin
makepkg -si
Self-hosted pacman repository
Import the GPG key:
curl -fsSL https://scopecreep-zip.github.io/open-sesame/gpg.key | sudo pacman-key --add -
sudo pacman-key --lsign-key $(curl -fsSL https://scopecreep-zip.github.io/open-sesame/gpg.key | gpg --show-keys --with-colons 2>/dev/null | awk -F: '/^pub/{print $5; exit}')
Add to /etc/pacman.conf:
[open-sesame]
SigLevel = Required DatabaseRequired
Server = https://scopecreep-zip.github.io/open-sesame/arch/$arch
Install:
sudo pacman -Syu open-sesame-bin open-sesame-desktop-bin
Direct download
VERSION=$(curl -fsSL https://api.github.com/repos/ScopeCreep-zip/open-sesame/releases/latest | jq -r .tag_name | sed 's/^v//')
sudo pacman -U "https://github.com/ScopeCreep-zip/open-sesame/releases/download/v${VERSION}/open-sesame-bin-${VERSION}-1-x86_64.pkg.tar.zst"
Systemd Integration
Arch’s systemd package ships a pacman hook that runs systemctl --user daemon-reload
for installed user units. No .install scriptlet is needed for unit reload.
The .install file prints setup instructions:
post_install:sesame init,systemctl --user enable --now open-sesame-headless.targetpost_upgrade:systemctl --user restart open-sesame-headless.targetpost_remove: config preservation note
Arch policy does not auto-enable services from .install. The preset file
(90-open-sesame.preset) declares default enablement for users who run
systemctl --user preset-all.
Release Tarballs
Each release produces standalone tarballs with FHS-standard directory layout:
open-sesame-v<ver>-x86_64.tar.gz
usr/bin/{sesame,daemon-profile,daemon-secrets,daemon-launcher,daemon-snippets}
usr/lib/systemd/user/{*.service,*.target}
usr/lib/systemd/user-preset/90-open-sesame.preset
usr/share/man/man1/sesame.1.gz
usr/share/bash-completion/completions/sesame
usr/share/zsh/site-functions/_sesame
usr/share/fish/vendor_completions.d/sesame.fish
usr/share/doc/open-sesame/config.example.toml
usr/share/licenses/open-sesame/LICENSE
These tarballs serve the AUR -bin PKGBUILD and are also usable for manual
installation on any Linux distribution.
Self-hosted Repository Structure
gh-pages/arch/
x86_64/
open-sesame-bin-<ver>-1-x86_64.pkg.tar.zst
open-sesame-bin-<ver>-1-x86_64.pkg.tar.zst.sig
open-sesame-desktop-bin-<ver>-1-x86_64.pkg.tar.zst
open-sesame-desktop-bin-<ver>-1-x86_64.pkg.tar.zst.sig
open-sesame.db
open-sesame.db.tar.gz
open-sesame.files
open-sesame.files.tar.gz
aarch64/
(same structure)
repo-add generates open-sesame.db and open-sesame.files. Symlinks are
replaced with copies before GitHub Pages deployment (Pages serves via tar
artifact, symlinks do not resolve).
Verification
Package signature
VERSION=$(curl -fsSL https://api.github.com/repos/ScopeCreep-zip/open-sesame/releases/latest | jq -r .tag_name | sed 's/^v//')
pacman-key --verify "open-sesame-bin-${VERSION}-1-x86_64.pkg.tar.zst.sig"
SLSA build provenance
VERSION=$(curl -fsSL https://api.github.com/repos/ScopeCreep-zip/open-sesame/releases/latest | jq -r .tag_name | sed 's/^v//')
gh attestation verify "open-sesame-v${VERSION}-x86_64.tar.gz" --owner ScopeCreep-zip
Checksum
sha256sum -c SHA256SUMS.txt
Distribution
Open Sesame uses semantic-release for automated versioning, GitHub Actions for building, SLSA attestations for supply chain security, and GitHub Pages for hosting APT and DNF repositories alongside documentation.
Semantic Release
Version management is configured in release.config.mjs. Semantic-release runs on pushes to main
and analyzes conventional commits to determine version bumps.
Release Rules
| Commit type | Release |
|---|---|
feat | minor |
fix | patch |
perf | patch |
revert | patch |
docs (scope: README) | patch |
refactor, style, chore, test, build, ci | no release |
Any scope no-release | no release |
Plugin Pipeline
The semantic-release plugin chain executes in order:
@semantic-release/commit-analyzer– Analyzes commits using theconventionalcommitspreset to determine the version bump type.@semantic-release/exec– Generates a release header from.github/templates/RELEASE_HEADER.md.@semantic-release/release-notes-generator– Generates release notes from commits, categorized by type.@semantic-release/changelog– UpdatesCHANGELOG.md.@semantic-release/exec– Updates the[workspace.package]version inCargo.tomlusingsed, then runscargo generate-lockfileto updateCargo.lock.@semantic-release/git– CommitsCHANGELOG.md,Cargo.toml, andCargo.lockwith messagechore(release): <version> [skip ci].@semantic-release/github– Creates the GitHub release.
Release Pipeline DAG
The release workflow (release.yml) runs on pushes to main and defines the following job
dependency graph:
semantic-release
├── build (amd64) ─┐
├── build (arm64) ─┤
├── build-rpm (amd64) ─┼──► attest
├── build-rpm (arm64) ─┤
├── build-arch (amd64) ─┤
├── build-arch (arm64) ─┤
│ ├──► verify-packages (amd64 deb, rpm, pkg.tar.zst)
│ └──► upload-assets (after verify-packages) ──► aur-publish
├── nix-cache
├── build-docs
│
└── [all above] ─────────────► publish ──► cleanup
All downstream jobs gate on needs.semantic-release.outputs.new_release == 'true'. If
semantic-release determines no version bump is needed, the pipeline stops after the first job.
Job Details
semantic-release: Checks out with fetch-depth: 0, installs Node.js via mise, runs
npx semantic-release. Outputs new_release, version, and tag.
build: Runs on a dual-architecture matrix (ubuntu-24.04 for amd64, ubuntu-24.04-arm for
arm64). Installs Rust and cargo-deb via mise. Raises RLIMIT_MEMLOCK to 256 MiB with prlimit
before building (required by ProtectedAlloc). Builds .deb packages via mise tasks
(ci:build:deb / ci:build:deb:arm64), renames them with architecture suffixes, and uploads as
artifacts.
verify-packages: A matrix over the amd64 deb-amd64, rpm-amd64, and arch-amd64 artifacts.
Each is downloaded into packages/ and installed by scripts/docker/verify-install.sh in its
distribution’s systemd container (ubuntu-local, fedora-local, arch-local: systemd as PID 1,
a lingering user), which picks the headless package by its metadata, starts its units
(scripts/docker/post-install.sh), and fails unless every headless daemon is active, the default
vault is unlocked, and no doctor check fails. upload-assets and publish depend on it. The Test
workflow’s install job runs the same check on every push, before semantic-release can tag.
nix-cache: Calls the reusable nix.yml workflow with the release tag. Builds both open-sesame
and open-sesame-desktop for each architecture and pushes to Cachix.
build-docs: Builds rustdoc and mdBook documentation via mise run ci:docs:all and
mise run ci:docs:combine, then uploads as an artifact.
build-rpm: Runs on the same dual-architecture matrix as the deb build. Installs Rust and
cargo-generate-rpm via mise. Builds .rpm packages via mise tasks (ci:build:rpm /
ci:build:rpm:arm64), renames them with architecture suffixes, and uploads as artifacts.
build-arch: Runs on the same dual-architecture matrix. Installs makepkg and
pacman-package-manager from Ubuntu universe. Builds release tarballs via
scripts/arch/build-tarball.sh, then .pkg.tar.zst packages via scripts/arch/build-pkg.sh
using Ubuntu’s native makepkg with CARCH and PKGEXT environment overrides.
attest: Downloads SHA256SUMS.txt from the GitHub Release (produced by upload-assets)
and generates SLSA build provenance attestations via actions/attest@v4 with
subject-checksums. Covers all artifact formats in a single attestation.
upload-assets: Downloads .deb, .rpm, .tar.gz, and .pkg.tar.zst artifacts, generates
SHA256SUMS.txt covering all packages, renders install instructions from a template with
per-architecture checksums for all formats, and uploads everything to the GitHub release.
publish: Downloads all artifacts and documentation, imports the GPG signing key,
generates the APT repository via mise run ci:release:apt-repo, the DNF repository via
mise run ci:release:rpm-repo, and the pacman repository via mise run ci:release:arch-repo.
Merges all repository trees with documentation into a single
gh-pages/ directory, and deploys to GitHub Pages. Includes post-deploy verification polling
for both APT Release and RPM repomd.xml endpoints. The publish job has a 30-minute timeout
and runs within a pages-deploy concurrency group with cancel-in-progress: false to prevent
mid-deploy corruption.
cleanup: Deletes old releases, keeping the 10 most recent. Uses
dev-drprasad/delete-older-releases@v0.3.4. Tags are preserved.
APT Repository
The APT repository is hosted on GitHub Pages and generated by the ci:release:apt-repo mise task
during the publish job. See Debian Packaging for details.
DNF Repository
The DNF repository is hosted on GitHub Pages alongside the APT repository, generated by the
ci:release:rpm-repo mise task during the publish job. The process:
- Installs
createrepo-cfrom Ubuntu’s universe repository. - Copies
.rpmpackages intorpm-site/repo/. - Signs packages using
rpmsigninside a Fedora container whenGPG_PRIVATE_KEYis set. - Runs
createrepo_cto generaterepodata/metadata. - Generates
manifest.txtand HTML index viascripts/rpm/generate-repo-index.sh. - Merges
rpm-site/into thegh-pages/tree alongside APT and documentation.
See RPM Packaging for client configuration, scriptlet semantics, and verification.
Repository Hosting
Both APT and DNF repositories share a single GitHub Pages site. The process:
- Downloads all
.debartifacts into apackages/directory. - Imports the GPG private key (
GPG_PRIVATE_KEYsecret) usingcrazy-max/ghaction-import-gpg@v6. - Generates the
Packagesindex and signs the repository with GPG. - Combines the APT repository with the documentation site into a single
gh-pages/directory. - Deploys to GitHub Pages using
actions/deploy-pages@v5.
The publish job runs in the github-pages environment and requires pages: write and
id-token: write permissions.
SLSA Build Provenance
Every .deb and .rpm artifact receives a SLSA build provenance attestation generated by
actions/attest@v4. This runs in the attest job after both deb and rpm builds
complete. The workflow declares attestations: write permission at the top level.
Attestations provide a cryptographic link between each package file and its GitHub Actions build, allowing consumers to verify that artifacts were produced by the CI pipeline and not tampered with.
Checksum Verification
The upload-assets job generates SHA256SUMS.txt containing SHA-256 hashes for all .deb and
.rpm files:
sha256sum ./*.deb ./*.rpm > SHA256SUMS.txt
The checksums file is uploaded alongside the packages to the GitHub release. Per-architecture checksums for both formats are interpolated into the release body template for inline verification instructions.
Workflow Permissions
The release workflow requests the following permissions:
| Permission | Purpose |
|---|---|
contents: write | Create GitHub releases, push version commits |
pages: write | Deploy APT + DNF repos and docs to GitHub Pages |
id-token: write | OIDC token for Pages deployment and attestations |
attestations: write | SLSA build provenance |
issues: write | Semantic-release issue comments |
pull-requests: write | Semantic-release PR comments |
Packaging for New Distributions
This guide covers the requirements for packaging Open Sesame on distributions not yet officially supported. For existing packages see: Debian, RPM, Arch, Nix.
Common Requirements
Regardless of distribution, all packages must satisfy the following.
Two-Package Split
Open Sesame ships as two logical packages:
- open-sesame (headless) – Contains the
sesameCLI,daemon-profile,daemon-secrets,daemon-launcher,daemon-snippets, and their systemd user service units. Has no GUI dependencies. - open-sesame-desktop (requires open-sesame) – Contains
daemon-wm,daemon-clipboard,daemon-input, and the COSMIC/Wayland compositor integration. Depends onlibwayland-client,libxkbcommon,fontconfig,freetype.
systemd User Services
All daemons run as systemd user services (systemctl --user). Packages must
install unit files to /usr/lib/systemd/user/. The services use:
Type=notifywithsd_notifyreadiness.Restart=on-failurewithRestartSec=2.- Ordering via
After=andRequires=(daemon-profile starts first as the IPC bus host; all others depend on it). BindsTo=graphical-session.targeton the desktop target (notRequires=) to tear down desktop services when the compositor exits unexpectedly.
Preset files ship under /usr/lib/systemd/user-preset/ – one per package
to avoid file conflicts between headless and desktop.
LimitMEMLOCK
daemon-secrets requires mlock for secret memory. The systemd unit sets
LimitMEMLOCK=64M. Packages that install systemd overrides or distributions
that set system-wide limits below this threshold will cause vault operations
to fail. The corresponding PAM/security limit is:
# /etc/security/limits.d/open-sesame.conf
* soft memlock 65536
* hard memlock 65536
Binary Paths
All binaries install to /usr/bin/. Configuration lives under
~/.config/pds/ (per XDG Base Directory specification).
Scriptlet Helpers
Deb and RPM scriptlets share a common helper library at
scripts/common/scriptlet-helpers.sh containing active_user_uids() and
reload_user_managers(). New packaging formats that need systemd lifecycle
management during install/upgrade/removal should use the same functions.
The helpers are concatenated into scriptlets at build time by the
cargo:assemble-scriptlets mise task. SESAME_BUS_TIMEOUT=15s matches the
upstream systemd-update-helper default (UPDATE_HELPER_USER_TIMEOUT_SEC).
Patchelf (nix devShell builds only)
Binaries built inside the nix devShell have nix store interpreters and RPATHs.
The cargo:patchelf mise task strips these before packaging. CI builds use
rustup and produce FHS-standard binaries. New packaging formats that build
from the nix devShell must run patchelf; formats that build from rustup or
system Rust do not.
Alpine Linux
Static Linking and musl
Alpine uses musl libc. Open Sesame compiles against musl with the
x86_64-unknown-linux-musl target. Considerations:
- SQLCipher: Must be compiled against musl. Alpine’s
sqlcipherpackage provides this. - OpenSSL vs. rustls: If the build uses OpenSSL for TLS, link against
Alpine’s
openssl-dev(which is musl-compatible). Alternatively,rustlsavoids the system OpenSSL dependency entirely. - Static binary: For maximum portability, build fully static binaries
with
RUSTFLAGS='-C target-feature=+crt-static'. This produces binaries that run on any Linux kernel >= 3.17 (formlock2and Landlock). - No systemd: Alpine uses OpenRC by default. Provide OpenRC init scripts
as an alternative to systemd user services. The init scripts must set
the
MEMLOCKulimit and run daemons as the logged-in user, not root.
APKBUILD
The APKBUILD follows the same two-package split. Use subpackages for
the desktop variant. Alpine’s Rust packaging infrastructure supports
cargo auditable build for SBOM embedding.
Flatpak: Not Applicable
Open Sesame is a host-level system integration tool. The Flatpak sandbox model is architecturally incompatible with the project’s design:
- Wayland privileged protocols.
daemon-wmrequires toplevel-info/management, layer-shell, keyboard-shortcut-inhibit, andext_background_effect_v1(blur). Flatpak 1.16+ routes sandboxed clients through a security-context-tagged Wayland socket so compositors can filter these privileged globals. - No systemd user units. Flatpak exports
.desktopfiles and D-Bus services but never installs systemd unit files. Open Sesame’s lifecycle model (targets, presets,BindsTo=, per-user restart on upgrade) has no Flatpak equivalent. /dev/inputaccess.daemon-inputrequires/dev/inputfor keyboard capture. Flatpak’s--device=inputpermission exposes this but defeats the sandbox’s purpose.- IPC in
XDG_RUNTIME_DIR. ThesesameCLI communicates with daemons via Unix sockets inXDG_RUNTIME_DIR. Flatpak remaps this path inside the sandbox. The CLI would requireflatpak run --command=sesameinvocations, which is unusable for a CLI-first tool without host-side wrappers that reintroduce host packaging.
The correct relationship between Open Sesame and Flatpak is provider, not tenant.
Future work: implement org.freedesktop.impl.portal.Secret backed by
daemon-secrets so sandboxed Flatpak apps get per-app secrets from the vault
through the XDG Secret portal. That is a host-installed D-Bus service shipped by
existing deb/rpm/pacman/nix packages.
Users on immutable desktops (Fedora Silverblue/Kinoite) can layer the RPM package
via rpm-ostree install from the DNF repository.
See issue #34 for the full evaluation.
Homebrew (macOS)
When platform-macos Is Implemented
Open Sesame currently targets Linux with COSMIC/Wayland. A platform-macos
crate is planned but not yet implemented. When it becomes available:
- Formula structure: A single formula covering the headless components (there is no separate desktop package on macOS; window management uses native Accessibility APIs).
- launchd: Replace systemd user services with
launchdplist files installed to~/Library/LaunchAgents/. - Keychain integration: The macOS keychain can serve as an auth backend
(similar to SSH agent), replacing
mlock-based secret memory with Secure Enclave operations where available. - Dependencies:
sqlcipheris available via Homebrew. No Wayland dependencies are needed.
This section will be expanded when platform-macos reaches a functional
state.
Testing Methodology
Open Sesame uses a layered testing strategy: unit tests beside the code they cover, integration tests per crate, and property-based tests for wire and identifier types.
Test Categories
Unit Tests
Unit tests are embedded in source files using #[cfg(test)] modules. They cover pure logic such as
hint assignment, the overlay controller state machine, configuration validation, cryptographic
derivation, rate limiting, ACL enforcement, audit logging, IPC routing, and type conversions. About
1,180 test functions exist in src/ modules across 127 source files in the workspace.
Integration Tests
Integration tests live in <crate>/tests/ directories and test cross-module behavior:
| File | Test Count | Scope |
|---|---|---|
core-ipc/tests/socket_integration.rs | 24 | Noise IK encrypted IPC: suites, connect, pub/sub, request/response, clearance enforcement, identity binding, unicast routing, key rotation |
open-sesame/tests/cli_integration.rs | 18 | CLI argument parsing, help output, exit codes (no running daemon required) |
core-ipc/tests/daemon_keypair.rs | 5 | Keypair persistence, file permissions, tamper detection, bus endpoint record |
core-memory/tests/guard_page_sigsegv.rs | 4 | Guard page SIGSEGV verification via subprocess harness |
Property-Based Tests (proptest)
core-types uses proptest to generate random inputs for serialization round-trips (postcard and
JSON) of identifiers (ProfileId, WindowId, AgentId, AppId, TrustProfileName), geometry, and
sensitivity classes.
Test Isolation
Filesystem Locations
Every location a daemon or the CLI uses comes from a core_layout::Layout. Tests build one with
Layout::under(root) over a temporary directory, so they never read or mutate the process
environment and run in parallel without races:
#![allow(unused)]
fn main() {
let root = tempfile::tempdir().unwrap();
let layout = core_layout::Layout::under(root.path());
}
The Nix packages additionally set HOME=$(mktemp -d) in preCheck (nix/package.nix,
nix/package-desktop.nix). The desktop package also points XKB_CONFIG_ROOT at xkeyboard-config
and FONTCONFIG_FILE at a DejaVu font configuration: daemon-input’s tests compile the default XKB
keymap and daemon-wm’s text tests shape with real fonts.
RLIMIT_MEMLOCK Requirement
The ProtectedAlloc allocator uses mlock to pin secret-holding pages in physical memory,
preventing swap exposure. This requires a sufficient RLIMIT_MEMLOCK limit.
In CI, prlimit raises the limit before test execution:
sudo prlimit --pid $$ --memlock=268435456:268435456
This sets both soft and hard limits to 256 MiB.
Tests that allocate ProtectedAlloc instances fail with ENOMEM if the memlock limit is
insufficient. The systemd service units set LimitMEMLOCK=64M for production use.
Test Execution
CI Pipeline
Tests run via mise run ci:test in the test.yml workflow on both ubuntu-24.04 (amd64) and
ubuntu-24.04-arm (arm64): format check, clippy with warnings denied, tests, and a debug build. The
qa job runs mise run ci:qa in the Nix devshell (TOML, Markdown, links, shell, workflows, and
cargo deny).
Nix Builds
The Nix packages run cargo tests during the build phase:
- Headless: tests the five headless crates with
--no-default-features - Desktop: tests the entire workspace with
--workspace
Local Execution
Developers can run the full test suite with:
sudo prlimit --pid $$ --memlock=268435456:268435456
cargo test --workspace
The prlimit invocation is required for core-memory and any crate that transitively uses
ProtectedAlloc.
Security Tests
Open Sesame includes targeted security tests that verify memory protection, cryptographic isolation, IPC authentication, and authorization enforcement. These tests validate security invariants that, if broken, would compromise secret confidentiality.
Guard Page SIGSEGV Verification
File: core-memory/tests/guard_page_sigsegv.rs
ProtectedAlloc wraps sensitive data in page-aligned memory with guard pages on both sides. The
guard page tests verify that out-of-bounds access triggers SIGSEGV (signal 11) rather than silently
reading adjacent memory.
Subprocess Harness Pattern
Direct SIGSEGV in a test process would kill the entire test runner. The tests use a subprocess harness:
- The parent test (
overflow_hits_trailing_guard_page,underflow_hits_leading_guard_page) spawns the test binary as a child process, targeting a specific harness function with--exactand passing an environment variable__GUARD_PAGE_HARNESSto gate execution. - The child harness (
overflow_harness,underflow_harness) checks for the environment variable. If absent, it returns immediately (no-op when run as part of the normal test suite). If present, it allocates aProtectedAlloc, performs a deliberate out-of-bounds read, and callsexit(1)as unreachable fallback. - The parent inspects the child’s exit status. On Unix, it checks
status.signal()for SIGSEGV (11) or SIGBUS (7). As a fallback for platforms that encode signal death as exit code 128+signal, it also checks the exit code.
Test Coverage
- Trailing guard page: reads one byte past
ptr.add(len), triggering SIGSEGV on the guard page after the data region. - Leading guard page: reads one full page before the data pointer (
ptr.sub(page_size)), past any canary and padding, into the guard page between the metadata region and data region. Accepts both SIGSEGV (11) and SIGBUS (7).
Canary Verification
File: core-memory/src/alloc.rs (unit tests)
ProtectedAlloc writes a canary value into the metadata region during allocation. Unit tests verify
canary behavior:
canary_is_consistent: verifies that canary derivation is deterministic – the same allocation size always produces the same canary.alloc_canary_plus_data_spans_page_boundary: verifies correct behavior when the canary plus user data cross a page boundary.
The canary is checked on Drop. If the canary has been corrupted (indicating a buffer underflow or
use-after-free into the metadata region), the allocator detects the tampering.
Postcard Wire Format Compatibility
File: core-types/src/sensitive.rs
SensitiveBytes provides custom Serialize and Deserialize implementations to maintain wire
compatibility with postcard (the IPC serialization format). The serializer writes raw bytes directly
from protected memory via serialize_bytes. The deserializer implements a custom Visitor with two
paths:
- Zero-copy path (
visit_bytes): copies directly from the deserializer’s borrowed input buffer into aProtectedAlloc. No intermediate heapVec<u8>is created. This is the path postcard uses for in-memory deserialization. - Owned path (
visit_byte_buf): accepts an ownedVec<u8>, copies intoProtectedAlloc, then zeroizes theVec<u8>before dropping it.
This ensures that SensitiveBytes and Vec<u8> produce identical wire representations, maintaining
backward compatibility with any code that previously used plain byte vectors.
Cross-Profile Vault Isolation
File: core-secrets/src/sqlcipher.rs (unit tests)
SQLCipher vaults are encrypted with per-profile vault keys derived via BLAKE3 domain separation. Three tests verify isolation:
-
cross_profile_keys_are_independent: derives vault keys for profiles “work” and “personal” from the same master key. Asserts the derived keys differ. Opens a vault with the “work” key, stores a secret, then attempts to reopen the same database file with the “personal” key. TheSqlCipherStore::opencall must return an error because SQLCipher cannot decrypt pages with the wrong key. -
cross_profile_secret_access_returns_error: creates two separate vault databases for “work” and “personal” profiles. Stores a secret in the “work” vault, then attempts to read the same key name from the “personal” vault. The result must beErr(core_types::Error::NotFound(_)). -
vault_key_derivation_domain_separation: verifies thatcore_crypto::derive_vault_keyproduces distinct keys for different profile names, confirming the BLAKE3 domain separation functions correctly.
IPC Authentication and Authorization
File: core-ipc/tests/socket_integration.rs
The IPC integration tests verify several security invariants of the Noise IK transport and bus server:
Noise Handshake Rejection
noise_handshake_rejects_wrong_key: a client connects expecting an incorrect server public key.
The Noise IK handshake fails because the client’s static key lookup does not match the server’s
actual identity.
Clearance Escalation Blocking
clearance_escalation_blocked: a client registered at SecurityLevel::Open attempts to publish a
message at SecurityLevel::Internal. The bus server silently drops the frame. An
Internal-clearance receiver does not receive it.
Sender Identity Binding
sender_identity_change_blocked: after a client’s first message binds its DaemonId to the
connection, any subsequent message with a different DaemonId is dropped. This prevents a
compromised client from impersonating another daemon mid-session.
Verified Sender Name Stamping
verified_sender_name_stamped: messages routed through the bus carry a verified_sender_name field
stamped by the server from the Noise IK registry lookup. The sender cannot self-declare this field.
The test verifies the stamped name matches the registry entry ("test-client-0"), not anything the
sender included in the message payload.
Unicast Response Routing
secret_response_not_received_by_bystander: when a request/response pair uses correlation IDs, the
response is unicast-routed to the original requester only. A bystander client connected to the same
bus does not receive the correlated response.
Orphan Response Dropping
uncorrelated_response_is_dropped: a message with a fabricated correlation_id (no matching
pending request) is silently dropped by the bus server and not broadcast to any client.
Ephemeral Client UCred Validation
ephemeral_client_gets_secrets_only_clearance: an unregistered key (ephemeral CLI connection) that
passes UCred same-UID validation receives SecretsOnly clearance, allowing it to send unlock and
secret CRUD messages without being pre-registered in the key registry.
Clearance-Level Message Filtering
secrets_only_message_not_delivered_to_internal_daemon: a message published at SecretsOnly level
is not delivered to Internal-clearance recipients, since Internal < SecretsOnly in the clearance
hierarchy.
Keypair Persistence Security
File: core-ipc/tests/daemon_keypair.rs
This test verifies filesystem security invariants for daemon keypair storage:
- The keys directory has
0700permissions. - Private key files (
.key) have0600permissions. - Public key files (
.pub) have0644permissions. - Bus keypair files (
bus.key,bus.pub,bus.checksum) have correct permissions. - Corrupting the checksum file triggers a
TAMPER DETECTEDerror on the next read, preventing use of tampered keypairs.
Seccomp Allowlist
Each daemon applies a seccomp filter via platform_linux::sandbox::apply_seccomp. The function uses
libseccomp to install a BPF filter with a default-deny policy (SCMP_ACT_ERRNO(EPERM)), adding
only the syscalls required by each daemon’s SeccompProfile. This prevents an attacker who gains
code execution within a daemon from making arbitrary system calls.
Seccomp is combined with Landlock filesystem restrictions in the apply_sandbox function, which
each daemon calls during initialization. Per-daemon sandbox configurations are defined in each
daemon’s sandbox.rs module (e.g., daemon-secrets/src/sandbox.rs, daemon-wm/src/sandbox.rs).
Daemons that do not need network access (e.g., daemon-secrets) additionally set
PrivateNetwork=true at the systemd level.
IPC Integration Tests
The core-ipc crate includes a comprehensive integration test suite in
core-ipc/tests/socket_integration.rs. All tests exercise the full Noise IK
encrypted transport – there is no plaintext transport path in the codebase.
Test Infrastructure
Helpers
The test suite provides three helper functions:
-
start_server_with_clients(n)– Creates a temporary directory, generates a server keypair, registersnclient keypairs atSecurityLevel::Internalin aClearanceRegistry, binds aBusServerto a Unix socket, and returns the server, temp directory, server public key, and client keypairs. -
start_server()– Convenience wrapper that registers a single client at Internal clearance. -
connect_with_keypair(id, sock, server_pub, kp)– Connects aBusClientviaconnect_encryptedwith the givenDaemonIdand keypair.
All tests create isolated Unix sockets in tempfile::TempDir instances,
ensuring no shared state between tests.
Test Coverage
Server Lifecycle
server_bind_creates_socket_file – Verifies that BusServer::bind
creates the Unix socket file on disk, including parent directory creation.
client_connect_and_server_accept – Verifies that after a client
performs a Noise IK handshake, the server reports a connection count of 1.
Publish-Subscribe
publish_subscribe_roundtrip – Client A publishes a DaemonStarted
event at Internal level. Client B receives it and verifies the event kind
matches. Confirms that broadcast delivery works end-to-end over encrypted
transport.
sender_does_not_receive_own_message – A client publishes a message
and then attempts to receive. The receive times out, confirming that the bus
server does not echo messages back to the sender.
multiple_clients_receive_broadcast – One sender, two receivers. Both
receivers get the ConfigReloaded event, verifying fan-out broadcast.
Request-Response
request_response_correlation – Client A sends a SecretList request
via client.request(). Client B receives it, constructs a
SecretListResponse with .with_correlation(request_msg.msg_id), and sends
it back. Client A’s request() future resolves with the correlated response.
Verifies that correlation ID routing works correctly.
launch_execute_response_roundtrip – End-to-end test of the
LaunchExecute / LaunchExecuteResponse request-response pair, simulating
the CLI sending a launch command and daemon-launcher responding with a PID.
launch_execute_error_roundtrip – Same as above, but the launcher
responds with error: Some("desktop entry 'nonexistent' not found") and
denial: Some(LaunchDenial::EntryNotFound). Verifies error propagation
through the correlated response path.
request_timeout – A client sends a StatusRequest with a 100 ms
timeout. No responder exists. The request() call returns an error
containing “timed out”.
Unicast Routing
secret_response_not_received_by_bystander – Three clients: a
requester, a bystander, and a simulated secrets daemon. The requester sends
a SecretList request. Both the bystander and the secrets daemon receive
the broadcast request. The secrets daemon responds with a correlated
SecretListResponse. The requester receives it, but the bystander does not.
This verifies that correlated responses are unicast-routed to the original
requester, not broadcast.
uncorrelated_response_is_dropped – A client sends a response message
with a fabricated correlation ID that matches no pending request. The bus
server drops it; no other client receives it. This prevents response
injection attacks.
Noise Handshake Security
noise_handshake_rejects_wrong_key – A client attempts to connect
using a server public key that does not match the actual server. The Noise IK
handshake fails, and connect_encrypted returns an error. This is a
fundamental authentication property of the IK pattern: the initiator pins
the responder’s static key.
client_connect_retry_on_missing_socket – A client attempts to connect
to a nonexistent socket path. The connection fails with an error containing
“failed to connect” rather than hanging or panicking.
Clearance Enforcement
clearance_escalation_blocked – Two clients are registered: one at
SecurityLevel::Open, one at SecurityLevel::Internal. The Open-clearance
client publishes a message at Internal level. The Internal-clearance client
does not receive it. The bus server silently drops frames that exceed the
sender’s clearance.
secrets_only_message_not_delivered_to_internal_daemon – A client
registered at SecurityLevel::SecretsOnly publishes at SecretsOnly level.
A client registered at SecurityLevel::Internal does not receive it. This
verifies the lattice property: Internal clearance is below SecretsOnly, so
Internal recipients are excluded from SecretsOnly-level messages. This
isolation ensures that daemon-secrets traffic is partitioned from general
daemon traffic.
ephemeral_client_gets_secrets_only_clearance – A client connects with
an unregistered keypair (not in the ClearanceRegistry). The connection
succeeds via UCred same-UID validation, and the server reports 1 connection.
Ephemeral clients (typically sesame CLI invocations) receive SecretsOnly
clearance, allowing them to interact with daemon-secrets without being
pre-registered.
Sender Identity
sender_identity_change_blocked – A client sends a first message with
DaemonId(20), binding that identity to the connection. It then sends a
second message with DaemonId(99). The receiver gets the first message but
not the second. The bus server drops messages where the sender’s DaemonId
does not match the identity bound on the first message, preventing identity
spoofing mid-session.
verified_sender_name_stamped – A client registered as
"test-client-0" sends a message. The receiver inspects
msg.verified_sender_name and finds it set to Some("test-client-0"). This
field is stamped by the server from the Noise IK registry lookup, not
self-declared by the sender. Recipients can trust this field for
authorization decisions.
Cross-Daemon Routing
registered_client_overlay_reaches_daemon_wm – A CLI client registered
at Internal clearance publishes WmActivateOverlay. A simulated daemon-wm
client receives it. Verifies the overlay activation path from CLI to window
manager.
Graceful Shutdown
shutdown_flushes_publish_before_disconnect – A CLI client publishes
WmActivateOverlay then calls client.shutdown().await. A daemon-wm
client receives the event after the CLI has disconnected. This verifies that
shutdown() flushes outbound frames before closing the connection.
drop_without_shutdown_may_lose_message – A CLI client publishes then
immediately drops the client handle without calling shutdown(). The test
documents that this races the I/O task and message delivery is
non-deterministic. This test exists as a regression companion to the
shutdown_flushes test: it demonstrates the data loss that shutdown() was
introduced to prevent.
CI Pipeline
Open Sesame uses four GitHub Actions workflows for testing, documentation, release, and Nix builds.
Workflow Overview
| Workflow | File | Triggers | Purpose |
|---|---|---|---|
| Test | test.yml | Push to main/master, PRs | Format check, clippy, tests, and debug build on dual architectures; QA checks; package install in systemd containers; lifecycle under the shipped units; PKGBUILD lint |
| Docs | docs.yml | Push to main/master, PRs | Build rustdoc and mdBook |
| Release | release.yml | Push to main, manual dispatch | Semantic-release, build, attest, publish |
| Nix | nix.yml | Called by release.yml, PRs | Build Nix packages and push to Cachix |
test.yml
The test workflow runs on every push to main/master and on pull requests targeting those
branches.
Dual-Architecture Matrix
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
Both runners use Ubuntu 24.04. ARM builds use GitHub’s native ubuntu-24.04-arm runner (not
emulation).
Execution
- Checks out the repository.
- Installs the Rust toolchain via
jdx/mise-action@v4with caching enabled. - Raises
RLIMIT_MEMLOCKto 256 MiB withsudo prlimit --pid $$ --memlock=268435456:268435456. This is required becauseProtectedAllocusesmlockto pin secret-holding memory pages. - Runs
mise run ci:test:cargo:fmt:check,cargo:clippy(--all-targets --all-features -D warnings),cargo:test, andcargo:build:debug.
The MISE_AUTO_INSTALL environment variable is set to "false" to prevent automatic tool
installation outside the explicit mise-action step.
QA Job
The qa job runs on ubuntu-24.04. It installs Nix via cachix/install-nix-action@v31, reads
the scopecreep-zip Cachix cache, and runs nix develop --accept-flake-config -c mise run ci:qa.
ci:qa depends on qa:toml, qa:markdown, qa:links (offline), qa:shell, and qa:actions.
Their tools (taplo, markdownlint-cli2, lychee, shellcheck, shfmt, actionlint) and mise itself come
from the flake devshell, so mise installs nothing.
MISE_TRUSTED_CONFIG_PATHS is set to the checkout: mise refuses an untrusted .mise.toml, and a
fresh runner has trusted nothing.
PKGBUILD Lint Job
The lint-pkgbuild job runs scripts/arch/lint-pkgbuild.sh (namcap) in an
archlinux:base-devel container.
Install Job
The install job builds each amd64 package as the release builds it (ci:build:deb,
ci:build:rpm, ci:build:arch) and runs scripts/docker/verify-install.sh on it: the
distribution’s compose service (ubuntu-local, fedora-local, arch-local; systemd as PID 1, a
lingering user) installs the headless package, and scripts/docker/post-install.sh starts
open-sesame-headless.target and sesame-init.service. The job fails unless every headless daemon
is active under its installed unit, the default vault is unlocked, and no doctor check fails
(sesame status --doctor --exit-code exit 1; warnings, exit 2, are reported and accepted). On
failure the container’s system and user journals are printed. The release workflow runs only after
this workflow succeeds, so no version is tagged whose packages do not start.
Nix Job
The nix job runs mise run test:nix (nix flake check) in the flake devshell: the flake is
evaluated, both packages are built, and checks.x86_64-linux.home-manager-module checks the Home
Manager module against the units the packages ship (see Nix Packaging).
Lifecycle Job
The lifecycle job runs tests/protocol_validation.sh (mise run test:lifecycle, in the flake
devshell) on ubuntu-24.04: every daemon runs as a transient service of the runner user’s service
manager (started by loginctl enable-linger) under the [Service] sandboxing of its shipped unit,
against a headless sway (WLR_BACKENDS=headless), on the runner’s own kernel. A daemon that fails
to start under its unit fails the job. The lefthook pre-push hook runs the same task; it needs a
Wayland session and the user’s service manager, and exits 2 without them.
docs.yml
The docs workflow runs on pushes and PRs to main/master. It runs on ubuntu-latest (single
architecture).
- Checks out the repository.
- Installs Nix and the
scopecreep-zipCachix cache. - Runs
mise run ci:docsin the flake devshell, which provides the toolchain, the system libraries, and mdbook.
This workflow validates that documentation builds succeed but does not deploy. Deployment occurs in
the release workflow’s build-docs and publish jobs.
release.yml
The release workflow is the primary CI/CD pipeline. It triggers on pushes to main and supports
manual dispatch with a dry-run option.
Permissions
The workflow declares the following permissions:
contents: write– GitHub release creation, version commitspages: write– GitHub Pages deploymentid-token: write– OIDC tokens for Pages and attestationsattestations: write– SLSA build provenanceissues: write,pull-requests: write– semantic-release comments
Job Dependency Graph
semantic-release ──┬──► build / build-rpm / build-arch ──┬──► attest
│ ├──► verify-packages ──┐
│ └──────────────────────┴──► upload-assets
├──► nix-cache
├──► build-docs
│
└──► [builds + verify-packages + upload-assets + build-docs] ──► publish ──► cleanup
All jobs after semantic-release are gated on new_release == 'true'. verify-packages installs
the release’s own amd64 .deb, .rpm, and .pkg.tar.zst artifacts with
scripts/docker/verify-install.sh, as the Test workflow’s install job does; upload-assets and
publish depend on it, so no asset or repository is published for a package that does not start.
Build Job
The build job uses the same dual-architecture matrix as the test workflow. It installs rust and
cargo:cargo-deb via mise, raises the memlock limit, and runs architecture-specific mise tasks:
| Architecture | Build Task | Rename Task |
|---|---|---|
| amd64 | ci:build:deb | ci:release:rename-deb |
| arm64 | ci:build:deb:arm64 | ci:release:rename-deb:arm64 |
The rename task adds architecture suffixes to the .deb filenames. Artifacts are uploaded with
1-day retention.
Nix Cache Job
Calls the reusable nix.yml workflow, passing the release tag and the
SCOPE_CREEP_CACHIX_PRIVATE_KEY secret.
Build Docs Job
Checks out the release tag, runs mise run ci:docs:all and mise run ci:docs:combine to produce
a combined rustdoc and mdBook site. The result is uploaded as a documentation artifact.
Publish Job
The publish job:
- Downloads
.debartifacts and documentation. - Imports the GPG signing key via
crazy-max/ghaction-import-gpg@v6. - Runs
mise run ci:release:apt-repoto generate the signed APT repository. - Deploys the combined APT repository and documentation to GitHub Pages via
actions/deploy-pages@v5.
This job runs in the github-pages environment.
nix.yml
The Nix workflow serves dual purposes:
- Reusable workflow: called by
release.ymlwith a tag input to build and push release artifacts to Cachix. - Standalone PR workflow: runs on PRs to
mainfor cache warming (builds packages but the Cachix action only pushes when the auth token is available).
Matrix
matrix:
include:
- system: x86_64-linux
runner: ubuntu-24.04
- system: aarch64-linux
runner: ubuntu-24.04-arm
Execution
- Checks out at the specified tag (or current ref for PRs).
- Installs Nix via
cachix/install-nix-action@v31. - Configures Cachix via
cachix/cachix-action@v17with thescopecreep-zipcache name. - Raises the memlock limit.
- Builds both
open-sesameandopen-sesame-desktopfor the matrix system with--accept-flake-config -L.
Mise Task Runner
All workflows run tasks through mise. Except for the qa job, which takes every tool from the Nix
devshell, they install tools with jdx/mise-action@v4. Mise manages:
- Rust toolchain version (from
rust-toolchain.tomlor mise config) - Node.js (for semantic-release in the release workflow)
cargo-deb(for.debpackaging in the build job)
Task names follow the convention ci:<category>:<action> (e.g., ci:test, ci:build:deb,
ci:docs:all, ci:release:apt-repo).
Environment Variables
| Variable | Value | Purpose |
|---|---|---|
CARGO_TERM_COLOR | always | Colored cargo output in CI logs |
MISE_AUTO_INSTALL | false | Prevent implicit tool installation |
MISE_TRUSTED_CONFIG_PATHS | ${{ github.workspace }} (qa job) | Trust the repository’s .mise.toml |
Compliance Framework Mapping
This page maps Open Sesame’s security controls to specific requirements in NIST 800-53, DISA STIG, PCI-DSS, SOC 2, and FedRAMP. Controls that are fully implemented cite the source crate or configuration. Controls that depend on design-intent features are marked accordingly.
NIST 800-53 Rev. 5
AC – Access Control
| Control | Title | Open Sesame Mechanism | Status |
|---|---|---|---|
| AC-3 | Access Enforcement | SecurityLevel clearance hierarchy (core-types/src/security.rs): Open < Internal < ProfileScoped < SecretsOnly. Each daemon registers at a clearance level; messages are routed only to peers at sufficient clearance. CapabilitySet enforces per-agent authorization. | Implemented |
| AC-4 | Information Flow Enforcement | IPC bus enforces sender clearance: a daemon cannot emit messages above its own SecurityLevel. Recipient filtering ensures low-clearance daemons never receive high-clearance messages (core-ipc/src/server.rs). | Implemented |
| AC-6 | Least Privilege | Per-daemon Landlock filesystem sandboxing, seccomp-bpf syscall allowlists, systemd NoNewPrivileges=yes, empty capability bounding set, ProtectSystem=strict. | Implemented |
| AC-6(1) | Authorize Access to Security Functions | Capability::Admin, Capability::Unlock, Capability::Lock restricted to agents with explicit grants. Delegation narrows scope via CapabilitySet.intersection(). | Implemented |
| AC-6(9) | Log Use of Privileged Functions | BLAKE3 hash-chained audit log records all vault operations (core-profile). | Implemented |
| AC-17 | Remote Access | Noise IK mutual authentication for all IPC. SSH agent forwarding for remote vault unlock. PrivateNetwork=yes on secrets daemon. | Implemented |
AU – Audit and Accountability
| Control | Title | Open Sesame Mechanism | Status |
|---|---|---|---|
| AU-2 | Event Logging | Structured JSON logging (global.logging.json = true), journald integration. Events include: unlock/lock, secret CRUD, profile activation, daemon lifecycle. | Implemented |
| AU-3 | Content of Audit Records | Each entry includes: timestamp, agent identity, operation, profile, security level. AgentIdentity provides agent type, delegation chain, attestations. | Implemented |
| AU-10 | Non-repudiation | BLAKE3 hash-chained audit log. Each entry’s hash chains to the previous. sesame audit verify detects tampering. | Implemented |
| AU-11 | Audit Record Retention | Audit chain files persist on disk indefinitely. Retention policy is delegated to the operating environment. | Implemented (storage) |
| AU-12 | Audit Record Generation | All daemons emit structured log events. The audit chain is generated by core-profile’s audit logger. | Implemented |
IA – Identification and Authentication
| Control | Title | Open Sesame Mechanism | Status |
|---|---|---|---|
| IA-2 | Identification and Authentication (Organizational Users) | AuthFactorId enum: Password, SshAgent, Fido2, Tpm, Fingerprint, Yubikey (core-types/src/auth.rs). Password and SshAgent backends implemented. | Partially Implemented |
| IA-2(1) | Multi-Factor Authentication to Privileged Accounts | AuthCombineMode: Any, All, Policy (core-types/src/auth.rs). Policy mode supports threshold-based MFA (N required factors + M additional). | Implemented |
| IA-2(6) | Access to Accounts – Separate Device | Hardware security keys (FIDO2, YubiKey) as separate physical devices. SSH agent forwarding uses the operator’s local key. | Partially Implemented (SSH agent implemented; FIDO2/YubiKey defined but backends not yet implemented) |
| IA-5 | Authenticator Management | Argon2id KDF (19 MiB, 2 iterations) for password. BLAKE3 domain-separated key derivation. Per-profile salts. | Implemented |
| IA-5(2) | Public Key-Based Authentication | Noise IK X25519 static keys for IPC. SSH agent Ed25519/RSA keys for vault unlock. | Implemented |
SC – System and Communications Protection
| Control | Title | Open Sesame Mechanism | Status |
|---|---|---|---|
| SC-8 | Transmission Confidentiality and Integrity | Noise IK protocol: X25519 + ChaChaPoly + BLAKE2s with forward secrecy. All IPC authenticated and encrypted. | Implemented |
| SC-12 | Cryptographic Key Establishment and Management | BLAKE3 domain-separated key hierarchy. Master key derived from auth factors. Sub-keys derived via BLAKE3 derive_key with unique context strings per purpose. | Implemented |
| SC-13 | Cryptographic Protection | CryptoConfig (core-types/src/crypto.rs) with configurable algorithm selection. GovernanceCompatible profile uses NIST-approved algorithms (PBKDF2-SHA256, HKDF-SHA256, AES-GCM, SHA-256). | Implemented |
| SC-28 | Protection of Information at Rest | SQLCipher: AES-256-CBC + HMAC-SHA512 per page. Per-profile encryption keys. | Implemented |
| SC-28(1) | Cryptographic Protection (at Rest) | Vault files are encrypted at rest with keys derived from Argon2id KDF output through BLAKE3 domain-separated derivation. | Implemented |
| SC-39 | Process Isolation | Per-daemon systemd services with Landlock, seccomp-bpf, NoNewPrivileges, ProtectSystem=strict. Secrets daemon: PrivateNetwork=yes. | Implemented |
SI – System and Information Integrity
| Control | Title | Open Sesame Mechanism | Status |
|---|---|---|---|
| SI-7 | Software, Firmware, and Information Integrity | GPG-signed APT packages. SLSA build provenance. OciReference with provenance digest for extensions. WASM extensions identified by content hash (AgentType::Extension { manifest_hash }). | Implemented |
| SI-16 | Memory Protection | memfd_secret(2) removes pages from kernel direct map. Guard pages (PROT_NONE). Volatile zeroize on drop. LimitCORE=0, MADV_DONTDUMP. | Implemented |
DISA STIG
| STIG Requirement | Open Sesame Mechanism | Status |
|---|---|---|
| Encrypted storage at rest | SQLCipher AES-256-CBC + HMAC-SHA512, per-profile encryption keys | Implemented |
| Memory protection for credentials | memfd_secret(2), guard pages, canary verification, volatile zeroize | Implemented |
| Audit trail integrity | BLAKE3 hash chain with tamper detection via sesame audit verify | Implemented |
| Least privilege process isolation | Landlock, seccomp-bpf, per-daemon clearance levels, systemd hardening | Implemented |
| No core dumps | LimitCORE=0 in all daemon services, MADV_DONTDUMP on secure allocations | Implemented |
| Authentication strength | Argon2id with memory-hard parameters (19 MiB). Multi-factor support. | Implemented |
| Access control for sensitive data | SecurityLevel hierarchy, CapabilitySet authorization | Implemented |
| Session management | Heartbeat-based delegation with TTL expiry, TrustVector.authz_freshness | Implemented (types); Design Intent (runtime enforcement) |
PCI-DSS v4.0
Requirement 3: Protect Stored Account Data
| Sub-Requirement | Open Sesame Mechanism |
|---|---|
| 3.5.1 Restrict access to cryptographic keys | Master key held in memfd_secret(2) memory, accessible only to the owning daemon process. Key derivation hierarchy: master key -> per-profile vault key -> SQLCipher page key. |
| 3.5.1.2 Store secret keys in fewest possible locations | One master key per installation, derived into per-profile keys. Master key exists only in protected memory; never on disk in plaintext. |
| 3.6.1 Key management procedures | sesame init generates keys. AuthCombineMode defines unlock policy. Key rotation via re-enrollment. |
Requirement 7: Restrict Access to System Components and Cardholder Data
| Sub-Requirement | Open Sesame Mechanism |
|---|---|
| 7.2.1 Access control system | CapabilitySet per agent. SecurityLevel per daemon. DelegationGrant for scoped access transfer. |
| 7.2.2 Assign access based on job classification | Trust profiles map to roles. Each profile has its own vault with its own secrets. |
Requirement 8: Identify Users and Authenticate Access
| Sub-Requirement | Open Sesame Mechanism |
|---|---|
| 8.3.1 All user access authenticated | All IPC authenticated via Noise IK. Vault unlock requires enrolled factor(s). |
| 8.3.2 Strong authentication for all access | Argon2id (memory-hard). Multi-factor via AuthCombineMode. Hardware factors defined. |
| 8.6.1 System and application accounts managed | AgentIdentity with typed AgentType, capability scoping, delegation chains. |
Requirement 10: Log and Monitor All Access
| Sub-Requirement | Open Sesame Mechanism |
|---|---|
| 10.2.1 Audit logs capture events | BLAKE3 hash-chained audit log, structured JSON logging. |
| 10.2.1.2 All actions by administrative accounts | Capability::Admin operations logged with full agent identity and delegation chain. |
| 10.3.1 Audit log protected from tampering | Hash chain provides tamper evidence. sesame audit verify detects modification. |
SOC 2 Trust Service Criteria
| Criteria | Category | Open Sesame Mechanism |
|---|---|---|
| CC6.1 | Logical and Physical Access Controls | SecurityLevel hierarchy, CapabilitySet, Noise IK authentication, per-daemon sandbox |
| CC6.2 | Prior to Issuing System Credentials | sesame init with factor enrollment. AgentIdentity creation with attestation. |
| CC6.3 | Based on Authorization | CapabilitySet intersection for delegation. Policy-based approval gates (Design Intent). |
| CC6.6 | Restrict Access | Landlock, seccomp-bpf, PrivateNetwork=yes (secrets daemon), ProtectHome=read-only |
| CC6.7 | Restrict Transmission | Noise IK encryption for all IPC. No plaintext secret transmission. |
| CC6.8 | Prevent or Detect Unauthorized Software | WASM extensions identified by manifest_hash. OciReference with provenance. GPG-signed packages. |
| CC7.1 | Monitor Infrastructure | systemd watchdog (WatchdogSec=30), structured logging, sesame status |
| CC7.2 | Monitor for Anomalies | Rate-limited vault unlock attempts. Audit chain verification. |
| CC8.1 | Changes to Infrastructure | Configuration layered inheritance with PolicyOverride audit trail |
FedRAMP
FedRAMP baselines inherit from NIST 800-53. The controls mapped in the NIST 800-53 section above apply to FedRAMP at the corresponding baseline level (Low, Moderate, High).
Cryptographic Algorithm Compliance
FedRAMP requires FIPS 140-validated cryptographic modules. Open Sesame provides a
GovernanceCompatible crypto profile (core-types/src/crypto.rs) that selects
NIST-approved algorithms:
| Component | LeadingEdge (Default) | GovernanceCompatible |
|---|---|---|
| KDF | Argon2id | PBKDF2-SHA256 (600K iterations) |
| HKDF | BLAKE3 | HKDF-SHA256 |
| Noise cipher | ChaChaPoly | AES-256-GCM |
| Noise hash | BLAKE2s | SHA-256 |
| Audit hash | BLAKE3 | SHA-256 |
The GovernanceCompatible profile uses algorithms that have FIPS 140-validated
implementations in widely-used cryptographic libraries. Open Sesame itself is not
FIPS-validated; deployments requiring FIPS validation must use a FIPS-validated
cryptographic provider at the library level. See
Cryptographic Inventory for the full algorithm inventory.
Cryptographic Inventory
This page provides an exhaustive inventory of every cryptographic algorithm used in Open Sesame, where it is used, the key sizes and parameters, and the relevant standards references.
Algorithm Summary
| Algorithm | Purpose | Key Size | Standard | Crate |
|---|---|---|---|---|
| Argon2id | Password -> password KEK | 32 bytes output | RFC 9106 | core-crypto (kdf.rs) |
| PBKDF2-SHA256 | Password -> password KEK (governance-compatible) | 32 bytes output | NIST SP 800-132, RFC 8018 | core-crypto (kdf.rs) |
| BLAKE3 derive_key | Key material -> per-purpose keys | 32 bytes output | BLAKE3 spec (domain-separated KDF mode) | core-crypto (derive.rs) |
| HKDF-SHA256 | Key material -> per-purpose keys (governance-compatible) | 32 bytes output | RFC 5869, NIST SP 800-56C | core-crypto (derive.rs) |
| AES-256-GCM | Key wrapping (WrappedKey, EnrollmentBlob), per-entry vault encryption | 256-bit key | NIST SP 800-38D, FIPS 197 | core-crypto (encryption.rs) |
| OS random source | Platform keyring KEK (256-bit), salts, nonces | 32 bytes (KEK) | getrandom(2) | core-crypto (random.rs) |
| AES-256-CBC + HMAC-SHA512 | SQLCipher page encryption | 256-bit key (encrypt) + 512-bit key (MAC) | FIPS 197, FIPS 198-1 | SQLCipher (via rusqlite) |
| X25519 | Noise IK key agreement | 256-bit (32 bytes) | RFC 7748 | snow (via core-ipc) |
| ChaChaPoly | Noise IK transport encryption (default) | 256-bit key | RFC 7539 | snow (via core-ipc) |
| BLAKE2s | Noise IK hashing (default) | 256-bit output | RFC 7693 | snow (via core-ipc) |
| AES-256-GCM (Noise) | Noise IK transport encryption (governance-compatible) | 256-bit key | NIST SP 800-38D | snow (via core-ipc) |
| SHA-256 (Noise) | Noise IK hashing (governance-compatible) | 256-bit output | FIPS 180-4 | snow (via core-ipc) |
| BLAKE3 | Audit log hash chain (default) | 256-bit output | BLAKE3 spec | core-profile |
| SHA-256 | Audit log hash chain (governance-compatible) | 256-bit output | FIPS 180-4 | core-profile |
| Ed25519 | Delegation grant signatures | 256-bit key (32 bytes) | RFC 8032 | core-types (security.rs) |
Argon2id
Standard: RFC 9106
Purpose: Derives the password key-encrypting key (KEK), which wraps the vault’s master
key, from a user-supplied password and the vault’s salt. Used by the Password
authentication factor (AuthFactorId::Password in core-types/src/auth.rs).
Parameters:
| Parameter | Value | Rationale |
|---|---|---|
| Memory | 19 MiB (19,456 KiB) | Memory-hard to resist GPU/ASIC attacks |
| Iterations | 2 | Balanced with memory cost for interactive use |
| Parallelism | 1 | Single-threaded derivation |
| Output | 32 bytes | 256-bit AES-256-GCM KEK |
| Salt | 16 bytes, per-profile, random | Unique per vault |
Implementation: core-crypto/src/kdf.rs, function derive_password_key with
KdfAlgorithm::Argon2id.
Known residual: The Argon2id working memory (19 MiB) resides on the unprotected heap
during derivation. This is an upstream limitation of the argon2 crate. See GitHub
issue #14.
BLAKE3 Key Derivation
Standard: BLAKE3 specification, KDF mode
Purpose: Derives per-purpose keys from key material (a master key, a vault key, a salt, a
signature, or factor pieces) using domain-separated context strings. Every context string is
declared once, as a KeyContext variant in core-crypto/src/derive.rs.
Context strings used in the system:
| Context String | Purpose | Derived From |
|---|---|---|
"pds v2 vault-key {profile}" | SQLCipher page key | Master key |
"pds v2 ipc-encryption-key {profile}" | IPC field encryption key | Master key |
"pds v2 combined-master-key {profile}" | Master key of an All-policy vault | Factor pieces |
"pds v2 ssh-challenge {profile}" | Challenge the SSH agent signs | Vault salt |
"pds v2 ssh-vault-kek {profile}" | KEK of the SSH enrollment | Challenge signature |
"pds v2 entry-encryption-key" | Per-entry AES-256-GCM key | SQLCipher page key |
Implementation: core-crypto/src/derive.rs, functions derive_key and
derive_encryption_key, under the vault’s HkdfAlgorithm (blake3::derive_key for BLAKE3).
BLAKE3’s KDF mode internally derives a context key from the context string, then uses it as keying material with extract-then-expand semantics equivalent to HKDF.
HKDF-SHA256
Standard: RFC 5869, NIST SP 800-56C
Purpose: Governance-compatible alternative to BLAKE3 key derivation. Used when
CryptoConfigToml.hkdf = "hkdf-sha256" (core-config/src/schema_crypto.rs).
Implementation: core-crypto/src/derive.rs, the HkdfAlgorithm::HkdfSha256 arm of the
derivation. Uses the hkdf crate with sha2::Sha256.
The same context strings listed above for BLAKE3 are used as the HKDF info parameter. No salt is given (RFC 5869 then uses a zero-filled salt). Output is 32 bytes.
AES-256-GCM (Key Wrapping)
Standard: NIST SP 800-38D, FIPS 197
Purpose: Wraps and unwraps the master key under a key-encryption key (KEK) derived from an authentication factor.
Used in:
WrappedKey(core-auth/src/wrapped_key.rs) – the master key wrapped under a KEK, in two vault files:<profile>.password-wrap: under the password KEK (the vault’s password KDF, Argon2id or PBKDF2-SHA256);<profile>.keyring-enrollment: under a random 256-bit KEK held in the platform credential store (the Secret Service on Linux).
EnrollmentBlob(<profile>.ssh-enrollment) – the master key wrapped under the KEK derived from the SSH agent’s challenge signature.
Parameters:
| Parameter | Value |
|---|---|
| Key size | 256 bits (32 bytes) |
| Nonce | 96 bits (12 bytes), random per encryption (EncryptionKey::seal) |
| Tag | 128 bits (16 bytes) |
AES-256-CBC + HMAC-SHA512 (SQLCipher)
Standard: FIPS 197 (AES), FIPS 198-1 (HMAC), FIPS 180-4 (SHA-512)
Purpose: SQLCipher page-level encryption for vault databases. Each page in the SQLite database is independently encrypted and authenticated.
Parameters:
| Parameter | Value |
|---|---|
| Encryption | AES-256-CBC per page |
| Authentication | HMAC-SHA512 per page |
| Key derivation | Per-page key from vault key via SQLCipher’s internal KDF |
| Page size | 4096 bytes (SQLCipher default) |
| KDF iterations | Controlled by SQLCipher; the vault key itself is pre-derived via Argon2id + BLAKE3 |
Implementation: SQLCipher via the rusqlite crate with the bundled-sqlcipher feature.
Noise IK (IPC Transport)
Standard: Noise Protocol Framework (noiseprotocol.org), pattern IK
Purpose: All inter-daemon communication on the IPC bus. Provides mutual authentication, encryption, and forward secrecy.
Pattern: IK (Initiator knows responder’s static key)
Default cipher suite: Noise_IK_25519_ChaChaPoly_BLAKE2s
| Component | Default (LeadingEdge) | Governance-Compatible |
|---|---|---|
| Key agreement | X25519 (RFC 7748) | X25519 (RFC 7748) |
| Cipher | ChaChaPoly (RFC 7539) | AES-256-GCM (NIST SP 800-38D) |
| Hash | BLAKE2s (RFC 7693) | SHA-256 (FIPS 180-4) |
Additional binding: The UCred (pid, uid, gid) of the connecting process is bound into the Noise prologue, preventing a process from impersonating another process’s Noise session.
Implementation: core-ipc, using the snow crate. Cipher suite selection is configured
via CryptoConfigToml.noise_cipher and CryptoConfigToml.noise_hash in
core-config/src/schema_crypto.rs.
Ed25519 (Delegation Signatures)
Standard: RFC 8032
Purpose: Signs DelegationGrant structs to prevent tampering with capability
delegations. The 64-byte signature is stored in DelegationGrant.signature
(core-types/src/security.rs).
Key size: 256-bit private key, 256-bit public key.
FIPS Path
The following table summarizes FIPS 140 validation status for each algorithm:
| Algorithm | FIPS-Validated Implementations Available | Open Sesame Profile |
|---|---|---|
| Argon2id | No FIPS 140 validation exists | LeadingEdge only |
| PBKDF2-SHA256 | Yes (multiple vendors) | GovernanceCompatible |
| BLAKE3 | No FIPS 140 validation exists | LeadingEdge only |
| HKDF-SHA256 | Yes (via HMAC-SHA256) | GovernanceCompatible |
| AES-256-GCM | Yes (multiple vendors) | Both profiles |
| AES-256-CBC | Yes (multiple vendors) | Both profiles (SQLCipher) |
| HMAC-SHA512 | Yes (multiple vendors) | Both profiles (SQLCipher) |
| X25519 | Partial (some FIPS modules include it) | Both profiles |
| ChaChaPoly | No FIPS 140 validation exists | LeadingEdge only |
| AES-256-GCM (Noise) | Yes (multiple vendors) | GovernanceCompatible |
| BLAKE2s | No FIPS 140 validation exists | LeadingEdge only |
| SHA-256 | Yes (multiple vendors) | GovernanceCompatible |
| Ed25519 | Partial (some FIPS modules include it) | Both profiles |
For deployments requiring full FIPS 140 compliance, set the crypto profile to
governance-compatible:
[crypto]
kdf = "pbkdf2-sha256"
hkdf = "hkdf-sha256"
noise_cipher = "aes-gcm"
noise_hash = "sha256"
audit_hash = "sha256"
minimum_peer_profile = "governance-compatible"
This configuration uses only algorithms with widely available FIPS 140-validated implementations. Open Sesame itself is not a FIPS-validated module; the FIPS boundary is at the cryptographic library level.
Crypto Agility
All cryptographic algorithm selections are config-driven via CryptoConfigToml
(core-config/src/schema_crypto.rs). The to_typed() method converts string-based
configuration into validated CryptoConfig enum variants.
Adding a new algorithm requires:
- Adding a variant to the relevant enum in
core-types/src/crypto.rs(e.g.,KdfAlgorithm::Scrypt). - Adding the string mapping in
core-config/src/schema_crypto.rs. - Implementing the algorithm in the corresponding
core-cryptofunction.
The minimum_peer_profile field in CryptoConfig is the floor an installation is to
accept from federation peers. It is parsed and validated but read by nothing: federation is
not implemented, so it constrains no connection today.
PBKDF2-SHA256
Standard: NIST SP 800-132, RFC 8018
Purpose: Governance-compatible alternative to Argon2id for password-based key derivation.
Used when CryptoConfigToml.kdf = "pbkdf2-sha256".
Parameters:
| Parameter | Value |
|---|---|
| Hash | SHA-256 |
| Iterations | 600,000 |
| Output | 32 bytes |
| Salt | 16 bytes, per-profile, random |
Implementation: core-crypto/src/kdf.rs, function derive_password_key with
KdfAlgorithm::Pbkdf2Sha256.
PBKDF2-SHA256 provides FIPS 140 compliance for the KDF layer but is significantly less resistant to GPU/ASIC attacks than Argon2id due to its lack of memory-hardness. It should be selected only when FIPS compliance is a hard requirement.
Zero Trust Posture
This page describes how Open Sesame applies zero trust principles to its architecture. Zero trust in this context means that no component, process, or network path is implicitly trusted. Every interaction is authenticated, authorized, and audited, regardless of origin.
Principles
Never Trust, Always Verify
Every IPC message on the bus is authenticated via the Noise IK protocol. There is no unauthenticated communication path between daemons.
Implementation: When a daemon connects to the IPC bus hosted by daemon-profile, the
Noise IK handshake verifies the connecting daemon’s X25519 static public key against the
clearance registry (core-ipc/src/registry.rs). UCred (pid, uid, gid) from the Unix domain
socket is bound into the Noise prologue, preventing a compromised process from reusing
another process’s Noise session.
Unregistered clients (e.g., the sesame CLI) receive Open clearance. They can send and
receive Open-level messages but are excluded from Internal, ProfileScoped, and
SecretsOnly traffic.
The SecurityLevel enum (core-types/src/security.rs) defines the clearance hierarchy:
#![allow(unused)]
fn main() {
pub enum SecurityLevel {
Open, // Visible to all, including extensions
Internal, // Authenticated daemons only
ProfileScoped, // Daemons with current profile's security context
SecretsOnly, // Secrets daemon only
}
}
A message at SecretsOnly level is delivered only to daemons registered at SecretsOnly
clearance. A daemon at Internal clearance never sees it. This is enforced in the IPC
server’s message routing loop (core-ipc/src/server.rs): the server checks
conn.security_clearance >= msg.security_level before delivering each message, and checks
conn.security_clearance >= msg.security_level before accepting each sent message from a
daemon.
Least Privilege
Each daemon operates with the minimum privileges required for its function. Privilege boundaries are enforced at multiple layers:
Per-Daemon Clearance
| Daemon | Clearance | Rationale |
|---|---|---|
daemon-secrets | SecretsOnly | Holds decrypted vault keys; must not leak to other daemons |
daemon-clipboard | ProfileScoped | Handles clipboard content scoped to the active profile |
daemon-profile | Internal | IPC bus host; sees all Internal-level and below |
daemon-wm | Internal | Window management; no access to secrets |
daemon-launcher | Internal | Application launching; receives secrets only via env injection |
daemon-input | Internal | Keyboard/mouse capture; no secret access |
daemon-snippets | Internal | Snippet management; no secret access |
Filesystem Sandboxing (Landlock)
Each daemon restricts its own filesystem access at startup via Landlock. The secrets daemon,
for example, can access only $XDG_RUNTIME_DIR/pds/ and ~/.config/pds/. Attempts to read
or write outside these paths return EACCES.
Partially-enforced Landlock is a fatal error. If the kernel supports Landlock but enforcement is incomplete (e.g., missing filesystem support), the daemon aborts rather than operating with degraded isolation.
Syscall Filtering (seccomp-bpf)
Each daemon installs a seccomp-bpf filter with a per-daemon syscall allowlist. Unallowed
syscalls terminate the offending thread (SECCOMP_RET_KILL_THREAD). A SIGSYS handler logs
the denied syscall before the thread dies, providing visibility into unexpected syscall
usage.
systemd Hardening
All daemon services apply:
| Directive | Effect |
|---|---|
NoNewPrivileges=yes | Prevents privilege escalation via setuid/setgid binaries |
ProtectSystem=strict | Root filesystem mounted read-only |
ProtectHome=read-only | Home directory read-only except explicit ReadWritePaths |
LimitCORE=0 | Core dumps disabled |
LimitMEMLOCK=64M | Locked memory budget for memfd_secret and mlock |
MemoryMax | Per-daemon memory ceiling |
The secrets daemon additionally uses PrivateNetwork=yes, which creates a network namespace
with only a loopback interface. The secrets daemon has no path to any network socket.
Capability-Based Authorization
The CapabilitySet type (core-types/src/security.rs) implements fine-grained,
capability-based authorization. Each agent’s session_scope defines exactly which
operations it can perform. The 16 defined capabilities are:
Admin,SecretRead,SecretWrite,SecretDelete,SecretListProfileActivate,ProfileDeactivate,ProfileList,ProfileSetDefaultStatusRead,AuditRead,ConfigReloadUnlock,LockDelegate,ExtensionInstall,ExtensionManage
Delegation narrows scope via lattice intersection:
effective = delegator_scope.intersection(grant.scope). A delegatee can never exceed the
delegator’s capabilities.
Continuous Verification
Trust is not established once and cached. Multiple mechanisms provide ongoing verification:
Watchdog
All daemons report health to systemd via WatchdogSec=30. If a daemon fails to report
within 30 seconds, systemd restarts it. This detects hung processes and ensures daemon
liveness.
Audit Chain
The BLAKE3 hash-chained audit log provides a tamper-evident record of all operations. Each
entry hashes the previous entry’s hash, forming a chain from the genesis entry at
sesame init to the most recent operation. Verification via sesame audit verify detects:
- Modified entries (hash mismatch).
- Deleted entries (chain gap).
- Reordered entries (hash mismatch).
- Inserted entries (hash mismatch).
The hash algorithm is configurable: BLAKE3 (default) or SHA-256 (governance-compatible),
via CryptoConfigToml.audit_hash (core-config/src/schema_crypto.rs).
Authorization Freshness
The TrustVector.authz_freshness field (core-types/src/security.rs) tracks how long
since the last authorization refresh. Delegated capabilities expire via
DelegationGrant.initial_ttl and require periodic renewal via heartbeat_interval. A
stale authorization is equivalent to no authorization.
Heartbeat Renewal
The Attestation::HeartbeatRenewal variant records heartbeat events for time-bounded
attestations. Missing a heartbeat revokes the corresponding delegation.
Device Health as Posture Signal
The availability of memfd_secret(2) is a binary posture signal. A system with
memfd_secret removes secret pages from the kernel direct map; a system without it leaves
secrets accessible to any process that can read /proc/pid/mem or perform DMA.
| Posture Signal | Value | Meaning |
|---|---|---|
memfd_secret available | device_posture: 1.0 | Secrets removed from kernel direct map |
memfd_secret unavailable | device_posture: 0.5 | Secrets on kernel direct map (mlock fallback) |
| No mlock | device_posture: 0.0 | Secrets may be swapped to disk |
The TrustVector.device_posture field (core-types/src/security.rs) is a f64 from 0.0
(unknown) to 1.0 (fully attested). In a federation context, a peer with low device posture
may be restricted from receiving high-sensitivity secrets.
Additional posture signals include:
- Landlock enforcement status – whether the filesystem sandbox is active.
- seccomp-bpf status – whether syscall filtering is active.
- Machine binding – whether the installation is bound to specific hardware via
MachineBindingType::TpmBoundorMachineBindingType::MachineId. - Kernel version – whether the kernel meets minimum requirements for all security controls.
Microsegmentation via Profile Isolation
Trust profiles are the microsegmentation boundary in Open Sesame. Each profile is an isolated trust context:
| Boundary | Isolation Mechanism |
|---|---|
| Secrets | Separate SQLCipher vault per profile (vaults/{name}.db) |
| Encryption keys | Separate BLAKE3-derived vault key per profile |
| Clipboard | Profile-scoped clipboard history |
| Audit | Profile attribution in every audit entry |
| Frecency | Separate frecency database per profile |
| Environment | Profile-scoped secret injection via sesame env -p {profile} |
Cross-profile access is not possible without explicit configuration. A daemon operating in
the work profile cannot read secrets from the personal profile’s vault. The vault
encryption keys are derived from different BLAKE3 context strings
("pds v2 vault-key work" vs. "pds v2 vault-key personal"), so even with the master key,
the derived keys are distinct.
The LaunchProfile type (core-types/src/profile.rs) allows explicit profile stacking for
applications that need secrets from multiple profiles:
#![allow(unused)]
fn main() {
pub struct LaunchProfile {
pub trust_profiles: Vec<TrustProfileName>,
pub conflict_policy: ConflictPolicy,
}
}
When multiple profiles are stacked, the ConflictPolicy determines how secret key
collisions are handled: Strict (abort), Warn (log and use higher-precedence), or Last
(silently use higher-precedence). The default is Strict, preventing accidental secret
leakage across profile boundaries.
Explicit Security Posture
Open Sesame does not degrade silently. Security controls that fail are fatal, with one documented exception:
- Landlock enforcement failure: fatal. Daemon does not start.
- seccomp-bpf installation failure: fatal. Daemon does not start.
memfd_secretunavailability: non-fatal. Daemon starts withmlockfallback. Logged at ERROR level with an explicit compliance impact statement naming affected frameworks (IL5/IL6, DISA STIG, PCI-DSS) and the exact remediation command.
The memfd_secret exception exists because the feature depends on kernel configuration that
application software cannot control. The ERROR-level log ensures the operator is informed of
the reduced posture, and the compliance impact statement provides actionable remediation
guidance.
Network Trust Model
The NetworkTrust enum (core-types/src/security.rs) classifies the trust level of the
network path:
#![allow(unused)]
fn main() {
pub enum NetworkTrust {
Local, // Unix domain socket, same machine
Encrypted, // Noise IK, TLS, WireGuard
Onion, // Tor, Veilid
PublicInternet, // Unencrypted or minimally authenticated
}
}
The ordering represents decreasing trust: Local is most trusted (no network traversal),
PublicInternet is least trusted.
In the current implementation, all IPC communication uses Local (Unix domain socket). In
a federation context (Design Intent), Encrypted (Noise IK over TCP) would be used for
cross-machine communication. The TrustVector.network_exposure field allows authorization
policies to require stronger authentication for less-trusted network paths.
Linux Platform
The platform-linux crate wraps the Linux APIs the daemons use: Wayland toplevel and clipboard
protocols, evdev input, D-Bus, the Secret Service, systemd notification, Landlock, and seccomp. It
holds no business logic. Every module is compiled only on Linux (#[cfg(target_os = "linux")]).
Feature Flags
| Feature | Modules | Dependencies |
|---|---|---|
| none (default) | cosmic_keys, dbus, global_shortcuts, keyring, sandbox, security, systemd | zbus, ashpd, oo7, landlock, libseccomp, sd-notify, rustix |
desktop | adds compositor, backend_wlr, clipboard, input, wayland | wayland-client, wayland-protocols, wayland-protocols-wlr, wl-clipboard-rs, evdev |
cosmic | implies desktop; adds backend_cosmic, cosmic_theme | cosmic-client-toolkit, cosmic-protocols, cosmic-theme, cosmic-config (GPL-3.0) |
The cosmic feature isolates the GPL-3.0 obligation of the COSMIC crates to builds that opt in.
daemon-wm builds with cosmic; daemon-clipboard, daemon-input, and daemon-profile (with its own
desktop feature) build with desktop; the headless daemons use the default.
Compositor
The CompositorBackend Trait
compositor.rs defines the toplevel operations of the compositor backends. The trait is
Send + Sync and synchronous: the window list is a registry a dispatch thread maintains, and a
request takes the registry lock and flushes the dispatch connection, so async callers run it on a
blocking thread.
| Method | Result |
|---|---|
list_windows() | The open toplevels as core_types::Windows, in the compositor’s announcement order |
activate_window(id) | The window brought to the foreground with input focus |
close_window(id) | The window asked to close |
name() | cosmic or wlr, for diagnostics |
An unknown window or an undeliverable request is core_types::Error::Platform.
detect_compositor(activations) returns the first backend that connects: with the cosmic
feature the COSMIC backend, then the wlr backend; neither is Error::Platform (“no supported
compositor backend”). daemon-wm and daemon-profile each detect one at startup.
Activation Reports
Every backend reports each window activation the compositor makes on the Activations channel
passed to detect_compositor: the activated Window, as committed, once per transition of a
toplevel to activated, in the compositor’s order, starting with the window focused when the backend
connects. The channel is unbounded, so the dispatch thread never blocks and no report is dropped.
The compositor activates at most one toplevel per seat: cosmic-comp marks the last window of the
focused output’s active workspace focus stack (Shell::update_active), and no window while a lock
surface or a tiling group holds focus or the workspace is empty. The reports are therefore the
compositor’s focus history, whatever caused each change: pointer, keyboard shortcut, a newly mapped
window, a workspace switch, or an activation request.
- daemon-wm records each report in its MRU stack, the one writer of window recency.
- daemon-profile sends
ContextSignal::AppFocusedwhen the focused app changes.
Shared Wayland Plumbing
wayland.rs holds what both backends share:
Toplevels<H>: the registry, shared between the dispatch thread and the callers. Entries keep the compositor’s announcement order;commitreplaces an entry in place or appends it and sends the activation report,closeremoves it,windows()lists every entry with an app id.His the protocol handle requests are sent on.request(toplevels, conn, id, f)sendsfon the handle ofidand flushesconn.dispatch_forever(conn, queue, state, name): the loop of a dedicated event thread, in the orderwayland_client::EventQueuedocuments for an external poll loop: flush,dispatch_pending,prepare_read,poll(2)on the socket for at most 50 ms, read. A failed step is logged with the connection’s protocol error and backs off exponentially from 100 ms to 30 s.ToplevelState::decode(packed, values): the activated, minimized, and fullscreen flags of a wlr toplevelstateevent’s packed array of native-endianu32values (a trailing partial element is ignored), underWLR_STATE.
COSMIC Backend
backend_cosmic.rs uses cosmic-client-toolkit on one connection, dispatched on the
cosmic-dispatch thread:
ToplevelInfoStatebindsext_foreign_toplevel_list_v1(version 1) andzcosmic_toplevel_info_v1(versions 2 to 3, required: without it no toplevel state is known), requests each toplevel’s cosmic handle, and reports a toplevel new or updated at itsext_foreign_toplevel_handle_v1.done, once its cosmic state has arrived. Each report commits the toplevel;toplevel_closedremoves it.ToplevelManagerStatebindszcosmic_toplevel_manager_v1(versions 1 to 4). Activate and close are sent on the toplevel’s cosmic handle with the seat and flushed.
Two roundtrips at connection deliver the existing toplevels and their state. WindowId is UUID v5
of the protocol identifier in a fixed namespace (the bytes of open-sesame-wind), so a toplevel
keeps its id across connections and daemon restarts.
wlr Backend
backend_wlr.rs binds wlr-foreign-toplevel-management-v1 (versions 1 to 3) and wl_seat
(versions 1 to 9), and dispatches on the wlr-dispatch thread. Pending per-toplevel state
(app_id, title, state) is committed on each done, the protocol’s commit point; closed removes
the toplevel and destroys its handle. The protocol names no stable identifier, so WindowIds are
UUIDv7s minted per handle, for the connection’s lifetime. Activate and close are sent on the
handle’s proxy (proxies are Send + Sync in wayland-client 0.31). The protocol is offered by sway,
Hyprland, niri, Wayfire, and cosmic-comp.
Clipboard
clipboard::spawn_capture(tx) captures the regular clipboard for daemon-clipboard through
wl-clipboard-rs’s Watcher, over ext-data-control-v1 or wlr-data-control-v1. cosmic-comp,
sway, Hyprland, niri, and KWin offer data-control to clients outside a security context; Mutter does
not, and there spawn_capture returns Error::Platform (“clipboard capture unavailable”).
- Thread: the watcher’s blocking wait runs on the
clipboard-capturethread; each selection is sent totxas aCapture { content_type, text, password_manager_hint }(itsDebugshows the length, never the text). - Selection: the text type wl-paste reads (
select_mime_type(_, MimeType::Text): UTF-8 plain text first). A selection without text, with non-UTF-8 text, or larger thanMAX_CAPTURE_BYTES(1 MiB) is skipped, never truncated. - Source deadline: the source client has 2 seconds to deliver a selection through its pipe
(
poll(2)bounded reads). - Secrets:
password_manager_hintis set when the source offersx-kde-passwordManagerHintwith the contentsecret. - Recovery: a Wayland failure after the start reconnects with backoff from 1 to 30 seconds; the
thread ends when
txcloses.
Input
input.rs reads evdev devices for daemon-input:
enumerate_devices(): the/dev/input/event*devices the process can open (the evdev crate’s enumerator skips the rest), each a keyboard when it hasKEY_A,KEY_Z, andKEY_ENTER, a pointer when it hasBTN_LEFT.open_keyboard_stream(path): the device as an asyncEventStream(AsyncFdunderneath).
Devices are not grabbed (EVIOCGRAB): events also reach the compositor. Access requires input
group membership, never root. Nothing is injected; there is no uinput device.
D-Bus: the NetworkManager SSID Monitor
dbus::ssid_monitor(system_bus, tx) reports the active Wi-Fi SSID for daemon-profile’s context
engine. It connects to the system bus socket at system_bus (Layout::system_bus_socket, from
DBUS_SYSTEM_BUS_ADDRESS or /var/run/dbus/system_bus_socket) through
zbus::connection::Builder::unix_stream, on zbus with default-features = false, features = ["tokio", "proxy"], so all I/O runs on the daemon’s tokio runtime.
It subscribes to NetworkManager’s StateChanged first and then reads the SSID, so a change between
the two is not missed; each state change re-reads it, and an SSID that differs from the last one
sent is sent. The read walks typed #[zbus::proxy] proxies, each built with
CacheProperties::No so every read is a fresh Properties.Get:
- The primary connection (
/means none). - Its type, which must be
802-11-wireless. - Its first device.
- The device’s active access point (
/means none). - The SSID bytes, as UTF-8 text.
A non-UTF-8 SSID, a Wi-Fi connection without a device, or a D-Bus failure fails that read; monitoring continues with the next state change.
Secret Service: keyring
keyring::SecretServiceStore is the Linux core_types::CredentialStore, over oo7: the freedesktop
Secret Service default collection (gnome-keyring, KWallet, oo7-daemon, KeePassXC) on the host, or
the Secret portal’s file keyring inside a Flatpak. connect() uses the session bus;
with_connection(conn) uses a given connection.
- Items: credentials are items with the attributes
serviceandusername(CredentialId), the convention libsecret’ssecret-tooland keyring-rs share. - Unlocking: a locked collection is unlocked before every operation (possibly raising the keyring’s own prompt), so a locked keyring is never read as an empty one.
- Ambiguity: more than one item for an id is
CredentialError::Ambiguous, never a guess. - Errors: a dismissed prompt is
Dismissed, a locked collection or portal keyring isLocked, and anything else isPlatform.
The sandboxed daemons have no session bus; daemon-launcher reads the platform keyring factor (Platform Keyring).
Overlay Shortcuts
The four overlay activations are core_types::OverlayRequest. Each request owns its bus event
(WmActivateOverlay…), its id, its description, its sesame arguments (wm overlay with
--launcher and --backward), and its shortcut, OverlayRequest::trigger(launcher):
| Request | Shortcut |
|---|---|
Forward | Alt+Tab |
Backward | Alt+Shift+Tab |
Launcher | [global] launcher_key (default alt+space) |
LauncherBackward | the launcher key with Shift |
The launcher key is a core_types::KeyCombo. Its modifiers are super (mod, logo, win),
ctrl (control), alt, and shift, and its key is an XKB keysym name. An invalid
combination fails the configuration load with the accepted modifiers named.
The Backend
One backend binds a session’s shortcuts, never both, so a key cannot fire twice. It is chosen
by what the session and the system provide, not by the calling shell’s environment
(open-sesame/src/keybinding.rs):
- The
GlobalShortcutsportal, when the session’s portal implementsorg.freedesktop.portal.GlobalShortcuts(KDE, GNOME 48 and later, Hyprland). - COSMIC’s shortcut configuration, when COSMIC’s shortcut defaults are installed
(
cosmic/com.system76.CosmicSettings.Shortcutsunder a system data directory,Layout::cosmic_shortcut_defaults). xdg-desktop-portal-cosmic does not implement GlobalShortcuts. - Neither:
sesame setup-keybindingnames both conditions, andsesame initreports the step and continues.
sesame setup-keybinding [KEY], remove-keybinding, and keybinding-status act through the
chosen backend; sesame init binds the configured key.
Portal: global_shortcuts
daemon-launcher holds the portal session, since it is outside the sandboxes and on the session bus. At start it creates a session and binds every request:
- Binding: each request is bound under its id and description, with its trigger in the XDG
shortcuts format as the preferred trigger (
ALT+Tab,ALT+SHIFT+Tab,ALT+space,ALT+SHIFT+space). The desktop assigns the final keys, may ask the user to confirm them, and lets the user change them in its settings. The assigned triggers are logged. - Activation: each
Activatedsignal becomes the request of its id, published to daemon-wm. - Lifetime: the session lives on daemon-launcher’s session-bus connection.
- Rebinding: a reloaded configuration with another
launcher_keyends the session and binds a new one, because a portal session binds once.
Without a session bus or a portal implementing the interface, daemon-launcher logs it and binds nothing.
COSMIC: cosmic_keys
setup_keybinding(layout, launcher), remove_keybinding(layout), and keybinding_status(layout)
manage the bindings in COSMIC’s shortcut configuration under Layout::cosmic_config_dir, in
com.system76.CosmicSettings.Shortcuts/v1/:
system_actions:WindowSwitcherandWindowSwitcherPreviousrun theForwardandBackwardrequests’ commands. COSMIC’s own Alt+Tab binding then runs sesame and consumes the key at the compositor, where a competingSpawnbinding would race the default and leak Alt to applications.custom:Spawnbindings for theLauncherandLauncherBackwardrequests at their triggers.
Commands are rendered from OverlayRequest::command_args, modifiers as COSMIC names them
(Super, Ctrl, Alt, Shift), and keys lowercased, since cosmic-comp matches lowercase keysym
names. Values are escaped for RON. Every write first copies the file to <file>.bak, and a failed
backup aborts the write. Removing the bindings deletes a system_actions file left empty, so
COSMIC falls back to its system defaults. cosmic-comp watches both files and reloads them on
change.
COSMIC Theme: cosmic_theme (feature cosmic)
cosmic_theme::CosmicTheme::load(cosmic_dir) reads the theme of the COSMIC configuration under
cosmic_dir (Layout::cosmic_config_dir) for daemon-wm’s overlay: the mode from
com.system76.CosmicTheme.Mode, then com.system76.CosmicTheme.Dark or .Light. It returns the
container, component, and accent colors as 8-bit RGBA, the medium corner radii, the frosted
settings and the blurred-container alpha, and the interface font family.
- No writes: a config is opened only when its version directory exists, so nothing is created
and a non-COSMIC desktop is
None. cosmic-config’sConfig::newrunscreate_dir_all. - No
get_active:Theme::get_activereads the mode from thecom.system76.CosmicThemeconfig, which COSMIC does not write, so the theme is not loaded through it. - Fallbacks: an unreadable config entry is logged and its defaults are used.
systemd: systemd
Built on sd-notify, which leaves NOTIFY_SOCKET set so later notifications keep working; outside
systemd every notification is a no-op.
| Function | Notification |
|---|---|
notify_ready() | READY=1 (Type=notify) |
notify_reloading() | RELOADING=1 with MONOTONIC_USEC in one datagram (Type=notify-reload; systemd 253 and later require the timestamp); followed by notify_ready() |
notify_watchdog() | WATCHDOG=1 keepalive |
notify_status(status) | STATUS= shown by systemctl status |
Sandbox and Process Hardening: sandbox, security
security::harden_process() sets PR_SET_DUMPABLE(0) and RLIMIT_CORE 0;
security::apply_resource_limits sets RLIMIT_NOFILE and RLIMIT_MEMLOCK. Both log a failure
and continue.
sandbox holds the one Landlock ruleset definition (every access right and scope of ABI 10,
best-effort, so the kernel enforces the part it supports; landlock_gaps() names each
core_types::SandboxProtection it does not, and the configured floor, [global.sandbox] require, is a hard requirement) and the seccomp filter
(default action kill-process, other architectures killed, socket/socketpair only for AF_UNIX,
synchronized onto every thread). apply_sandbox(rules, seccomp) applies both. The grants and
allowlists each daemon passes are described in Sandbox Model.
Adding a Compositor Backend
- Create
backend_<name>.rsimplementingCompositorBackend(Send + Sync, synchronous methods) over awayland::Toplevelsregistry its dispatch thread (wayland::dispatch_forever) commits into at the protocol’s commit point; the registry sends the activation reports. - Add
pub(crate) mod backend_<name>;tolib.rsunder its feature. - Add it to
detect_compositor(), more specific protocols before generic ones. - Add the feature and its protocol dependencies to
Cargo.toml.
An operation the compositor’s protocols do not offer is Error::Platform naming it.
macOS Platform
The platform-macos crate provides safe Rust abstractions over macOS-specific APIs consumed by the
daemon crates. It contains no business logic. All modules are gated with #[cfg(target_os = "macos")];
on other platforms the crate compiles as an empty library with no exports.
Implementation Status
The crate is scaffolded with module declarations only. macOS implementations are deferred until the Linux platform is validated on Pop!_OS / COSMIC. The module structure, API boundaries, and dependency selections are defined. No functional code exists.
Dependencies
The Cargo.toml declares macOS-specific dependencies:
| Crate | Purpose |
|---|---|
core-types | Shared types (Window, WindowId, Error, etc.) |
security-framework | Keychain Services API (create/read/delete keychain items) |
objc2 | Objective-C runtime bindings for Accessibility and AppKit APIs |
core-foundation | CFString, CFDictionary, CFRunLoop interop |
core-graphics | CGEventTap, CGEventPost for input monitoring and injection |
serde | Serialization for configuration types |
tokio | Async runtime integration |
tracing | Structured logging |
Module Structure
accessibility
Window management via the Accessibility API (AXUIElement). This module will provide the macOS
equivalent of the Linux compositor backends: window enumeration, activation, geometry manipulation,
and close operations. On macOS, all window management goes through the Accessibility framework rather
than compositor-specific protocols.
clipboard
Clipboard access via NSPasteboard. This module will provide read, write, and change-notification
functionality equivalent to the Linux DataControl trait. macOS clipboard access does not require
special permissions.
input
Input monitoring via CGEventTap (listen-only) and input injection via CGEventPost. Both operations
require the Accessibility permission in TCC. The module will provide keyboard event observation
equivalent to the Linux evdev module. Unlike Linux evdev, macOS input monitoring is global by default
and does not require group membership – it requires a TCC permission grant instead.
keychain
Per-profile named keychains via the security-framework crate (Keychain Services API). This module
will store wrapped key-encryption keys, equivalent to the Linux SecretServiceProxy in the dbus
module. macOS uses per-user keychains rather than a D-Bus Secret Service.
launch_agent
LaunchAgent plist generation and launchctl lifecycle management. This is the macOS equivalent of
systemd service units. The module will generate property list files for
~/Library/LaunchAgents/, register them with launchctl, and manage daemon lifecycle (start, stop,
status). Unlike systemd’s Type=notify, LaunchAgents use process lifecycle for readiness signaling.
tcc
Transparency, Consent, and Control (TCC) permission state introspection. This module will query the TCC database to determine whether Accessibility and Input Monitoring permissions have been granted before attempting operations that require them. This allows the system to provide actionable error messages rather than silently failing.
Platform-Specific Considerations
Accessibility API vs. Wayland Protocols
On Linux, window management is mediated by compositor-specific Wayland protocols. On macOS, the
Accessibility API (AXUIElement) provides a single, compositor-independent interface for window
enumeration, activation, geometry, and close operations. The trade-off is that Accessibility access
requires an explicit TCC permission grant from the user, and the API surface is significantly
different from Wayland protocols.
TCC Permissions
macOS requires explicit user consent for two operations that Open Sesame uses:
- Accessibility: Required for window management (
AXUIElement) and input injection (CGEventPost). - Input Monitoring: Required for keyboard event observation (
CGEventTapin listen-only mode).
These permissions cannot be granted programmatically. The application must be added to the relevant
TCC lists in System Settings. The tcc module exists to detect permission state and guide the user
through the grant process.
launchd vs. systemd
macOS uses launchd instead of systemd for daemon management. Key differences:
- Readiness signaling: systemd supports
Type=notifywithsd_notify(READY=1). launchd uses process lifecycle – a LaunchAgent is considered ready when the process is running. - Watchdog: systemd supports
WatchdogSecwith periodic keepalive pings. launchd hasKeepAlivewhich restarts crashed processes but does not support health-check pings. - Socket activation: systemd supports
ListenStreamfor socket-activated services. launchd supportsSocketsin the plist for equivalent functionality. - Configuration format: systemd uses INI-style unit files. launchd uses XML property lists in
~/Library/LaunchAgents/. - Dependency ordering: systemd supports
After=,Requires=,Wants=. launchd has limited dependency support viaWatchPathsandQueueDirectories.
Keychain vs. Secret Service
Linux uses the freedesktop Secret Service API (org.freedesktop.secrets) over D-Bus for credential
storage. macOS uses the Keychain Services API directly. Both provide encrypted-at-rest storage scoped
to the user session, but the API surfaces are entirely different. The keychain module will present
the same logical operations (store, retrieve, delete, has) as the Linux SecretServiceProxy.
Windows Platform
The platform-windows crate provides safe Rust abstractions over Windows-specific APIs consumed by
the daemon crates. It contains no business logic. All modules are gated with
#[cfg(target_os = "windows")]; on other platforms the crate compiles as an empty library with no
exports.
Implementation Status
The crate is scaffolded with module declarations only. Windows implementations are deferred until the Linux and macOS platforms are validated. The module structure, API boundaries, and dependency selections are defined. No functional code exists.
Dependencies
The Cargo.toml declares Windows-specific dependencies:
| Crate | Purpose |
|---|---|
core-types | Shared types (Window, WindowId, Error, etc.) |
windows | Official Microsoft Windows API bindings (Win32, COM, WinRT) |
serde | Serialization for configuration types |
tokio | Async runtime integration |
tracing | Structured logging |
Module Structure
clipboard
Clipboard monitoring via AddClipboardFormatListener. This module will provide clipboard change
notifications and read/write operations, equivalent to the Linux DataControl trait. Windows
clipboard access uses the Win32 clipboard API and does not require elevated privileges.
credential
Credential storage via CryptProtectData (DPAPI) and CredRead/CredWrite (Credential Manager).
This module will store wrapped key-encryption keys, equivalent to the Linux SecretServiceProxy in
the dbus module. DPAPI provides user-scoped encryption tied to the Windows login credentials. The
Credential Manager provides a higher-level API for named credentials visible in the Windows
Credential Manager UI.
hotkey
Global hotkey registration via RegisterHotKey/UnregisterHotKey. This module will provide
compositor-independent hotkey capture, equivalent to the Linux Global Shortcuts portal or COSMIC key
injection. On Windows, global hotkeys are registered per-thread and deliver WM_HOTKEY messages to
the registering thread’s message loop.
input_hook
Input capture via SetWindowsHookEx(WH_KEYBOARD_LL). This module will provide low-level keyboard
monitoring equivalent to the Linux evdev module. Low-level keyboard hooks see all keyboard input
system-wide. The crate documentation notes that EDR (Endpoint Detection and Response) disclosure is
required – low-level keyboard hooks are flagged by security software and must be documented for
enterprise deployment.
named_pipe
IPC bootstrap via Named Pipes. This is the Windows equivalent of Unix domain sockets used by the Noise IK IPC bus on Linux. Named Pipes provide the transport layer for inter-daemon communication on Windows. Security descriptors on the pipe control which processes can connect.
policy
Enterprise policy reading via Group Policy registry keys. This module will read
HKLM\Software\Policies\OpenSesame\ for enterprise-managed configuration overrides. This has no
direct Linux equivalent – the closest analog is /etc/pds/ system configuration, but Group Policy
provides domain-joined management capabilities.
task_scheduler
Daemon autostart via Task Scheduler COM API. This is the Windows equivalent of systemd user services and macOS LaunchAgents. The module will create scheduled tasks that run at user logon to start the daemon processes.
ui_automation
Window management and enumeration via UI Automation COM API. This module provides the Windows equivalent of the Linux compositor backends. UI Automation exposes the desktop automation tree, allowing enumeration of all top-level windows, reading their properties (title, class, process), and performing actions (activate, minimize, close, move, resize).
virtual_desktop
Workspace management via the Virtual Desktop COM API. This module will provide workspace enumeration
and window-to-desktop movement, equivalent to the Linux list_workspaces and move_to_workspace
compositor operations. The Windows Virtual Desktop API is undocumented and version-fragile – COM
interface GUIDs change between Windows 10 and Windows 11 builds.
Platform-Specific Considerations
UI Automation vs. Wayland Protocols
On Linux, window management uses compositor-specific Wayland protocols (wlr-foreign-toplevel, COSMIC
toplevel). On Windows, UI Automation provides a single COM-based interface that works across all
window managers. The trade-off is COM initialization complexity and the need to handle apartment
threading models correctly (CoInitializeEx with COINIT_MULTITHREADED or
COINIT_APARTMENTTHREADED).
Credential Manager vs. Secret Service
Linux uses the freedesktop Secret Service API over D-Bus. Windows uses DPAPI
(CryptProtectData/CryptUnprotectData) for raw encryption tied to user credentials, and the
Credential Manager API (CredRead/CredWrite) for named credential storage. Both provide
user-scoped encrypted-at-rest storage, but the APIs are entirely different.
Task Scheduler vs. systemd
Windows uses the Task Scheduler for daemon autostart. Key differences from systemd:
- Readiness signaling: systemd supports
Type=notify. Task Scheduler has no equivalent; the task is considered running when the process starts. - Watchdog: systemd supports
WatchdogSec. Task Scheduler can restart failed tasks but does not support health-check pings. - Dependencies: systemd supports
After=,Requires=. Task Scheduler supports task dependencies but with a less expressive model. - Configuration: systemd uses INI-style unit files. Task Scheduler uses XML task definitions
registered via COM or
schtasks.exe.
Named Pipes vs. Unix Domain Sockets
The Noise IK IPC bus uses Unix domain sockets on Linux. On Windows, Named Pipes provide equivalent functionality with OS-level access control via security descriptors. Named Pipes support both byte-mode and message-mode communication; the IPC bus would use byte-mode to match the stream semantics of Unix domain sockets.
EDR Disclosure
Low-level keyboard hooks (WH_KEYBOARD_LL) and clipboard monitoring are flagged by Endpoint
Detection and Response (EDR) software common in enterprise environments. Deployment in managed
environments requires documentation of these behaviors and may require allowlist entries in the
organization’s security tooling.
Changelog
The changelog is auto-generated from conventional commit messages and
maintained in the repository root at
CHANGELOG.md.
Each GitHub Release includes the relevant changelog section along with
install instructions for the APT repository and direct .deb download
links. Release assets include SHA256 checksums and
SLSA Build Provenance attestations that can be verified
with:
gh attestation verify "open-sesame-linux-$(uname -m).deb" --owner ScopeCreep-zip
For the full version history, see the
Releases page or
the CHANGELOG.md file in the repository root.
License
Open Sesame is licensed under GPL-3.0-only (GNU General Public License, version 3, with no “or later” clause).
Why GPL-3.0
The cosmic-protocols crate, which provides Wayland protocol definitions for
the COSMIC desktop compositor, is licensed under GPL-3.0-only. Because
Open Sesame links against cosmic-protocols in the platform-linux and
daemon-wm crates, the entire combined work must be distributed under
GPL-3.0-only to satisfy the license terms.
License Text
The full license text is in the
LICENSE
file at the repository root. It is the standard GNU General Public License
version 3 as published by the Free Software Foundation on 29 June 2007.
SPDX Identifier
All crate manifests declare license = "GPL-3.0-only" in their
Cargo.toml workspace configuration, using the
SPDX license identifier.
Security Hardening Field Guide
A practical, encyclopedic reference for debugging and troubleshooting Linux security hardening across seccomp-bpf, Landlock, systemd sandboxing, and related tooling. Written for engineers hardening multi-daemon Linux applications.
1. Overview
Modern Linux application hardening is built on defense-in-depth: multiple independent security layers that each reduce the blast radius of a compromise. No single layer is sufficient. The three primary layers are:
| Layer | Scope | Enforced By |
|---|---|---|
| systemd sandboxing | Mount namespaces, resource limits, lifecycle | systemd (PID 1 / user manager) |
| Landlock | Filesystem access control | Kernel LSM, applied per-process |
| seccomp-bpf | Syscall filtering | Kernel, applied per-thread/process |
These layers compose because they operate at different abstraction levels:
- systemd mount namespaces control what the process can see on the
filesystem. A process inside
ProtectSystem=strictliterally cannot write to/usrbecause its mount namespace has a read-only bind mount. - Landlock controls what the process is allowed to access within the paths it can see. Even if systemd exposes a writable path, Landlock can restrict the process to specific subdirectories.
- seccomp-bpf controls what the process is allowed to do at the syscall
level. Even if a process can open a file, seccomp can block it from calling
execve,ptrace, ormount.
A compromised daemon that escapes one layer still faces the others. This guide covers how to implement each layer correctly, the non-obvious failure modes, and how to debug them when things go wrong.
2. seccomp-bpf
2.1 How seccomp works
seccomp-bpf attaches a BPF program to a process (or thread) that intercepts every syscall before the kernel executes it. The BPF program inspects the syscall number and arguments, then returns a verdict.
Activation:
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); // required first
seccomp(SECCOMP_SET_MODE_FILTER, flags, &prog);
The SECCOMP_FILTER_FLAG_TSYNC flag is critical for multi-threaded programs:
it synchronizes the filter to all threads in the thread group atomically. Without
it, each thread must install the filter individually, creating a race window.
Action modes:
| Action | Behavior | Use Case |
|---|---|---|
SECCOMP_RET_KILL_PROCESS | Kills the entire process with SIGSYS | Production: fail-closed, no zombie threads |
SECCOMP_RET_KILL_THREAD | Kills only the offending thread | Dangerous with async runtimes (see 2.2) |
SECCOMP_RET_ERRNO | Returns an errno to the caller | Graceful degradation, testable |
SECCOMP_RET_LOG | Allows but logs via audit | Development/audit mode |
Choosing an action mode:
- Use
SECCOMP_RET_KILL_PROCESSin production. It is the safest default. A process that violates its seccomp policy is compromised and should die. - Use
SECCOMP_RET_LOGduring development to discover which syscalls your code actually needs without killing it. - Use
SECCOMP_RET_ERRNO(EPERM)only when you have code that gracefully handles the error (e.g., optional features that degrade). - Avoid
SECCOMP_RET_KILL_THREADunless you fully understand the implications for your threading model. Read section 2.2.
2.2 KillThread + async runtimes (CRITICAL)
This is the single most dangerous failure mode in seccomp’d async applications.
When SECCOMP_RET_KILL_THREAD kills a thread in tokio’s (or async-std’s)
blocking thread pool, the JoinHandle returned by spawn_blocking never
resolves. The kernel destroys the thread. The channel that the runtime uses
to send the result back is dropped without sending. The JoinHandle future
polls forever.
The cascade:
- A
spawn_blockingtask calls a blocked syscall (e.g.,ftruncatefor SQLite WAL rollback). - seccomp kills that thread with SIGSYS.
- The
JoinHandlefuture never completes. - The
tokio::select!branch waiting on that handle blocks forever. - The event loop freezes. No other futures make progress.
- The watchdog timer (if it ticks inside the same event loop) stops ticking.
- systemd’s
WatchdogSecfires and kills the process.
This is silent. No logs. No crash. No panic. The process simply freezes and systemd eventually SIGKILLs it. Journalctl shows a watchdog timeout with no preceding error messages.
Design rule: Every spawn_blocking in a seccomp-filtered process MUST
have a timeout wrapper:
#![allow(unused)]
fn main() {
use tokio::time::{timeout, Duration};
let result = timeout(
Duration::from_secs(10),
tokio::task::spawn_blocking(move || {
// potentially blocked operation
database.execute("PRAGMA wal_checkpoint(TRUNCATE)")
}),
)
.await;
match result {
Ok(Ok(Ok(rows))) => { /* success */ }
Ok(Ok(Err(e))) => { /* database error */ }
Ok(Err(e)) => { /* JoinError: thread panicked */ }
Err(_) => {
// TIMEOUT: likely seccomp killed the thread
tracing::error!("spawn_blocking timed out -- possible seccomp kill");
// Initiate graceful shutdown or restart
}
}
}
This does not prevent the thread death, but it prevents the entire event loop from freezing and gives you a log line to debug.
2.3 Observing a seccomp kill
A SIGSYS handler cannot observe a KILL_THREAD or KILL_PROCESS verdict.
For both, the kernel forces the signal (force_sig_seccomp(nr, data, true),
which also requests a core dump) or exits the thread (do_exit(SIGSYS)); no
user handler runs (kernel/seccomp.c, __seccomp_filter). Only
SECCOMP_RET_TRAP delivers a catchable SIGSYS, and it lets the process
continue, so it is not a production verdict.
Observe kills from outside the process instead:
- Audit log. The kernel emits an audit record (
type=SECCOMP, withsyscall=andsig=31) for every kill action listed in/proc/sys/kernel/seccomp/actions_logged, which listskill_processandkill_threadby default.journalctl -k,ausearch -m SECCOMP, anddmesgshow it. - systemd. The unit fails with
status=31/SYS. - strace.
strace -fshows the call immediately before+++ killed by SIGSYS +++(5.1).
2.4 Building seccomp allowlists with strace
The only reliable way to build a seccomp allowlist is to trace your application under real workloads.
Step 1: Trace all threads
# Attach to a running process
strace -f -o /tmp/trace.log -p $(pidof my-daemon)
# Or launch under strace
strace -f -o /tmp/trace.log -- ./my-daemon
The -f flag follows child threads and processes.
Step 2: Exercise ALL code paths
This is where most allowlists fail. You must exercise:
- Startup and initialization
- Normal operation (happy path)
- Error paths (invalid input, network failure, disk full)
- Shutdown (graceful and SIGTERM)
- Database operations (open, read, write, WAL checkpoint, vacuum)
- Config reload (inotify, file re-read)
- IPC (socket creation, connection, message exchange)
Step 3: Extract unique syscalls
awk -F'(' '{print $1}' /tmp/trace.log \
| sed 's/^[0-9]* *//' \
| sort -u \
> /tmp/syscalls.txt
Step 4: Diff against your allowlist
Compare the trace output against your current allowlist. Add any missing syscalls.
Commonly missed syscalls:
| Syscall | Triggered By |
|---|---|
ftruncate | SQLite WAL rollback/checkpoint |
fsync | SQLite PRAGMA, checkpoint, journal |
fdatasync | SQLite WAL writes |
pwrite64 | SQLite WAL page writes |
fallocate | SQLite pre-allocating journal/WAL space |
readlink | Symlink resolution (common on NixOS) |
inotify_init1 | File watcher initialization |
inotify_add_watch | Watching config files for changes |
inotify_rm_watch | Cleaning up file watches |
statx | Modern stat replacement (glibc 2.28+) |
getrandom | Cryptographic RNG, SQLCipher |
clone3 | Modern thread creation (glibc 2.34+) |
2.5 Common pitfalls
fdatasync vs fsync:
SQLite uses both. fdatasync for WAL writes (it only needs data, not
metadata). fsync for PRAGMA operations and WAL checkpoints (it needs full
metadata sync). Missing either one causes intermittent seccomp kills that
only trigger under write load.
SQLite WAL mode syscall set:
A complete SQLite WAL allowlist includes: openat, ftruncate, pwrite64,
pread64, fallocate, rename, fsync, fdatasync, fcntl (for
F_SETLK/F_GETLK advisory locking), fstat, lseek, unlink.
D-Bus / zbus syscalls:
If your daemon communicates over D-Bus (e.g., for desktop integration):
socket, connect, sendmsg, recvmsg, geteuid (D-Bus auth), shutdown,
getsockopt, setsockopt.
inotify file watchers:
Any config hot-reload mechanism using inotify needs: inotify_init1,
inotify_add_watch, inotify_rm_watch, read (for reading events from the
inotify fd), epoll_ctl (if using epoll to watch the inotify fd).
SECCOMP_FILTER_FLAG_TSYNC timing:
TSYNC applies the filter to all existing threads. If a file watcher
thread was spawned before seccomp is applied, it gets the filter too. If that
thread’s syscalls are not in the allowlist, it dies. Either:
- Apply seccomp before spawning any background threads, or
- Ensure the allowlist covers all threads’ syscalls, or
- Have background threads install their own filters before doing work.
3. Landlock
3.1 How Landlock works
Landlock is a Linux Security Module (LSM) that provides unprivileged, process-level filesystem access control. Unlike seccomp (which filters syscalls), Landlock filters filesystem operations on specific paths.
#![allow(unused)]
fn main() {
// Pseudocode for Landlock setup
let ruleset = Ruleset::default()
.handle_access(AccessFs::from_all(abi_version))?
.create()?;
// Grant read-only access to config directory
ruleset.add_rule(PathBeneath::new(
File::open("/etc/myapp")?,
AccessFs::ReadFile | AccessFs::ReadDir,
))?;
// Grant read-write access to runtime directory
ruleset.add_rule(PathBeneath::new(
File::open("/run/user/1000/myapp")?,
AccessFs::from_all(abi_version),
))?;
// Enforce -- no more rules can be added after this
ruleset.restrict_self()?;
}
Key properties:
- Rules are additive: you start with no access and grant specific paths.
- Rules are inherited: child processes inherit the restriction.
- Rules are stackable: multiple Landlock rulesets compose (intersection).
- Landlock requires no privileges – any process can restrict itself.
ABI versions add access rights. Landlock covered only file system operations at first; later ABIs extend it to sockets and other processes:
| ABI | Linux | Adds |
|---|---|---|
| 1 | 5.13 | File system access rights |
| 2 | 5.19 | Refer (rename and link across directories) |
| 3 | 6.2 | Truncate |
| 4 | 6.7 | TCP bind and connect (AccessNet) |
| 5 | 6.10 | IoctlDev |
| 6 | 6.12 | Scopes: abstract Unix sockets, signals |
| 7 | 6.15 | Audit log control |
| 8 | 7.0 | Restricting every thread at once (TSYNC) |
| 9 | 7.1 | Pathname Unix socket connect (ResolveUnix) |
| 10 | 7.2 | UDP bind, connect, send |
Declare the ABI your ruleset is written against as a constant and handle
from_all(ABI) of it; never construct an ABI from the running kernel (the
landlock crate keeps that private by design, because a ruleset would then
differ between machines). Under the crate’s default CompatLevel::BestEffort
the kernel enforces the rights of its own ABI and drops the rest, which is
the compatibility model the kernel’s Landlock documentation prescribes: the
program runs on every kernel, under the strongest sandbox each one enforces,
and inherits what a newer kernel adds:
#![allow(unused)]
fn main() {
let status = Ruleset::default()
.set_compatibility(CompatLevel::BestEffort)
.handle_access(AccessFs::from_all(ABI::V10))?
.handle_access(AccessNet::from_all(ABI::V10))?
.scope(Scope::from_all(ABI::V10))?
.create()?
// rules...
.restrict_self()?;
// status.ruleset: FullyEnforced, PartiallyEnforced, or NotEnforced.
}
Best effort must not be silent. Report what the kernel does not enforce, at
startup and in diagnostics: a CompatLevel::HardRequirement ruleset of one
protection’s rights alone fails exactly when the kernel lacks it, and builds
nothing in the kernel. CompatLevel::HardRequirement on the whole ruleset is
for a program that must not run at all below a level (the crate’s “rare
circumstances”); it also keeps the program from running in CI on an older
kernel. Test each restriction on a kernel that enforces it and on one that
does not: expect a refusal where the kernel’s ABI includes the right and
access where it does not (rust-landlock runs its tests on a matrix of UML
kernels, one per ABI, with landlock-test-tools).
3.2 Symlink resolution
Landlock grants access to the resolved path, not the symlink itself. This is a critical distinction on distributions that use symlink farms.
NixOS and Guix store all packages in /nix/store/ (or /gnu/store/)
and symlink configuration files into place:
/etc/myapp/config.toml -> /nix/store/abc123-myapp-config/config.toml
If you grant Landlock access to /etc/myapp/, the process can open the
symlink. But the target is in /nix/store/, which is not in the ruleset.
The open fails with EACCES.
Solution: Canonicalize all config paths before building Landlock rules:
#![allow(unused)]
fn main() {
use std::fs;
use std::path::{Path, PathBuf};
use std::collections::HashSet;
fn resolve_landlock_paths(paths: &[&str]) -> HashSet<PathBuf> {
let mut resolved = HashSet::new();
for path in paths {
let p = Path::new(path);
if p.exists() {
// Add the original path
resolved.insert(p.to_path_buf());
// Add the canonical (resolved) path
if let Ok(canonical) = fs::canonicalize(p) {
resolved.insert(canonical.clone());
// Also add parent directories for traversal
if let Some(parent) = canonical.parent() {
resolved.insert(parent.to_path_buf());
}
}
}
}
resolved
}
}
Then add all resolved paths as read-only rules.
3.3 Common pitfalls
/dev/urandom blocked:
SQLCipher and OpenSSL read from /dev/urandom for random bytes. If Landlock
blocks /dev/urandom, they fall back to the getrandom() syscall, which
bypasses the filesystem entirely. This usually works, but you may see EACCES
errors in logs. Grant read access to /dev/urandom to silence them:
#![allow(unused)]
fn main() {
ruleset.add_rule(PathBeneath::new(
File::open("/dev/urandom")?,
AccessFs::ReadFile,
))?;
}
Pathname Unix sockets below ABI 9 are not mediated at all:
Before ResolveUnix (ABI 9, Linux 7.1), Landlock does not check connect(2)
to a pathname Unix socket: a sandboxed process reaches every socket it can
name, whatever its rules. On a desktop that includes the session D-Bus bus
($XDG_RUNTIME_DIR/bus), where the user’s service manager
(org.freedesktop.systemd1) starts transient units running any command, an
escape from any sandbox. Request ABI 9’s ResolveUnix (it is part of
AccessFs::from_all from ABI::V9), grant each socket a process connects to
(ResolveUnix, part of AccessFs::from_file, on the socket or on its
directory), and report a kernel below ABI 9 as one where this gap is open.
seccomp cannot close it: it cannot read the address connect points to. On
such a kernel, systemd’s InaccessiblePaths=-%t/bus removes the session bus
socket from the unit’s mount namespace.
NOTIFY_SOCKET path:
sd_notify() sends to the socket in $NOTIFY_SOCKET. A user service
manager’s is a pathname socket ($XDG_RUNTIME_DIR/systemd/notify); with
ResolveUnix handled (ABI 9), grant it like any socket, or notifications fail
on every kernel that enforces it. An abstract address
(@-prefixed) cannot be granted by a rule: under the abstract-socket scope
(below) it is unreachable.
Abstract sockets and the scope (ABI 6):
An abstract address (a leading null byte, @ in ss output) has no
file-system path, so no rule applies to it. Since ABI 6,
Scope::AbstractUnixSocket refuses connect to an abstract socket created
outside the process’s Landlock domain (Xwayland and some session buses listen
on abstract addresses). Without the scope, every abstract socket of the
network namespace is reachable.
4. systemd Sandboxing
4.1 Mount namespaces
systemd can create per-service mount namespaces that restrict the filesystem view. This is the outermost sandbox layer.
Key directives for [Service] sections:
[Service]
# Read-only root filesystem (bind mount overlays)
ProtectSystem=strict
# User home directory is read-only
ProtectHome=read-only
# Specific writable paths (bind-mounted into the namespace)
ReadWritePaths=/run/user/%U/myapp /home/%U/.local/share/myapp
# Restrict /proc, /sys, kernel tunables
ProtectProc=invisible
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
# Private /tmp
PrivateTmp=yes
# No new privileges (required for seccomp)
NoNewPrivileges=yes
# Restrict capabilities
CapabilityBoundingSet=
AmbientCapabilities=
Critical requirement: Every path listed in ReadWritePaths= must exist
on the host before the service starts. If the directory does not exist,
systemd cannot create the bind mount, and the service fails with
exit status 226/NAMESPACE.
This is the most common systemd sandbox failure mode.
4.2 tmpfiles.d for directory pre-creation
The chicken-and-egg problem: your daemon creates its directories on first run, but systemd’s mount namespace fails if those directories do not already exist.
Solution: Use systemd-tmpfiles to create directories at user session
login, before any service starts.
For NixOS (in your system or home-manager configuration):
systemd.user.tmpfiles.rules = [
"d %t/myapp 0700 - - -" # /run/user/UID/myapp
"d %h/.config/myapp 0700 - - -" # ~/.config/myapp
"d %h/.local/share/myapp 0700 - - -"
];
For other distributions, create ~/.config/systemd/user/tmpfiles.d/myapp.conf:
# Type Path Mode User Group Age
d %t/myapp 0700 - - -
d %h/.config/myapp 0700 - - -
d %h/.local/share/myapp 0700 - - -
Specifiers: %t = $XDG_RUNTIME_DIR, %h = $HOME, %U = numeric UID.
For wipe/reinitialize flows (e.g., factory reset, test harness):
# Recreate directories after wiping
rm -rf ~/.local/share/myapp
systemd-tmpfiles --user --create
systemctl --user restart myapp.service
Defense-in-depth: The application should also create its directories on
startup (a bootstrap_dirs() function) so it works on platforms without
systemd (containers, macOS, BSDs). tmpfiles.d is the systemd-specific layer;
application bootstrap is the portable layer.
4.3 Service type alignment
Type=notify:
The daemon signals readiness by calling sd_notify("READY=1"). systemd waits
for this signal before marking the service as active.
#![allow(unused)]
fn main() {
// Using the sd-notify crate or raw socket write
sd_notify::notify(false, &[sd_notify::NotifyState::Ready])?;
}
If you set Type=simple but your daemon calls sd_notify, systemd ignores
the notification silently. The service is marked active immediately on exec.
This is not an error – it just means your readiness signal does nothing.
WatchdogSec=:
The daemon must call sd_notify("WATCHDOG=1") at least every
WatchdogSec / 2 interval. If the event loop freezes (e.g., due to seccomp
killing a thread – see 2.2), the watchdog fires and systemd restarts the
service.
#![allow(unused)]
fn main() {
// Tick the watchdog inside the main event loop
loop {
tokio::select! {
msg = ipc_rx.recv() => { handle_message(msg).await; }
_ = watchdog_interval.tick() => {
sd_notify::notify(false, &[sd_notify::NotifyState::Watchdog])?;
}
}
}
}
Place the watchdog tick in the event loop, not in a separate thread. A separate thread will keep ticking even when the event loop is frozen, defeating the purpose.
TimeoutStopSec=:
How long systemd waits after sending SIGTERM before sending SIGKILL. Set this
to give your daemon time for graceful shutdown (flush databases, close
connections), but not so long that a hung daemon blocks restarts.
TimeoutStopSec=10s
4.4 Common pitfalls
RuntimeDirectory= with ProtectSystem=strict:
For user services, RuntimeDirectory=myapp creates /run/user/UID/myapp
inside the mount namespace. This directory is only visible to that specific
service instance. Other services in the same user session cannot see it.
If you need a shared runtime directory, use ReadWritePaths= with a
directory created by tmpfiles.d.
PrivateNetwork=yes and Unix sockets:
PrivateNetwork=yes creates a new network namespace with only a loopback
interface. TCP/UDP connections to external hosts are blocked. However, Unix
domain sockets on the filesystem are unaffected – they are filesystem
operations, not network operations. This means IPC over Unix sockets works
fine with PrivateNetwork=yes, which is usually what you want for a daemon
that only communicates via local IPC.
sd_notify silently succeeds when NOTIFY_SOCKET is unset:
When running outside systemd (e.g., in a terminal for debugging),
$NOTIFY_SOCKET is not set. The sd_notify() call returns success without
doing anything. Add diagnostic logging so you know whether notifications are
actually being delivered:
#![allow(unused)]
fn main() {
if std::env::var("NOTIFY_SOCKET").is_ok() {
tracing::info!("systemd notify socket available");
sd_notify::notify(false, &[sd_notify::NotifyState::Ready])?;
} else {
tracing::warn!("NOTIFY_SOCKET not set -- sd_notify disabled");
}
}
5. Debugging Toolkit
5.1 strace
strace is the single most valuable tool for debugging seccomp and Landlock issues.
Trace all threads of a running process:
strace -f -o /tmp/trace.log -p $(pidof my-daemon)
Filter out noisy syscalls:
strace -f -e trace='!read,write,close,epoll_wait,futex,nanosleep' \
-o /tmp/trace.log -p $(pidof my-daemon)
Find seccomp kills:
grep "killed by SIGSYS" /tmp/trace.log
The last syscall logged for that thread (immediately before the
+++ killed by SIGSYS +++ line) is the blocked syscall. Example:
[pid 12345] ftruncate(7, 0) = ?
[pid 12345] +++ killed by SIGSYS (core dumped) +++
This tells you ftruncate is missing from the allowlist.
Trace all daemons simultaneously for comprehensive coverage:
for pid in $(pgrep -f 'my-daemon'); do
strace -f -o /tmp/trace-${pid}.log -p $pid &
done
# Exercise all code paths, then kill strace processes
5.2 journalctl
View logs for a user service:
journalctl --user -u my-daemon.service --no-pager -o short-precise
Key exit status codes:
| Status | Meaning | Likely Cause |
|---|---|---|
| 226/NAMESPACE | Mount namespace setup failed | ReadWritePaths directory does not exist |
| 31/SYS | Killed by signal 31 (SIGSYS) | seccomp blocked a syscall |
| 6/ABRT | Aborted | Watchdog timeout, assertion failure, or panic |
| -1/WATCHDOG | Watchdog timeout | Event loop frozen (see 2.2) |
Watch in real time:
journalctl --user -u my-daemon.service -f -o short-precise
5.3 systemctl
Check service status:
systemctl --user status my-daemon.service
Look for: Active: (running/failed/inactive), Main PID:, exit code/status.
Clear failed state: After a service fails, systemd remembers the failure. You must reset it before restarting:
systemctl --user reset-failed my-daemon.service
systemctl --user start my-daemon.service
Recreate tmpfiles.d directories:
systemd-tmpfiles --user --create
This is idempotent – safe to run anytime.
5.4 Diagnostic patterns
“No such file or directory” + status=226:
The service’s ReadWritePaths or ReadOnlyPaths references a directory that
does not exist on the host filesystem. systemd cannot create the bind mount
into the namespace.
Fix: Ensure tmpfiles.d rules create all required directories. Run
systemd-tmpfiles --user --create and retry.
Watchdog timeout with no error logs:
The event loop is frozen. The most common cause is seccomp KILL_THREAD
silently destroying a thread that tokio::select! is waiting on (see 2.2).
Debug: Attach strace to the process, exercise the code path that triggers the
freeze, look for SIGSYS kills. Add timeout wrappers to spawn_blocking
calls to regain visibility.
“database is locked” after timeout:
A spawn_blocking thread was killed by seccomp while holding an fcntl
advisory lock on a SQLite file. The lock was not released because the thread
died without running destructors. The file descriptor may still be open (held
by the process, not the thread).
Fix: Add the missing syscall to the allowlist. If the database is stuck,
restart the process (the lock is released when the fd is closed on process
exit). For robustness, set PRAGMA busy_timeout so SQLite retries instead of
immediately returning SQLITE_BUSY.
Silent timeout from CLI (e.g., 5 seconds, no response): The daemon received the IPC message but froze during processing. The CLI’s request timeout fires. This is the user-visible symptom of the event loop freeze described above.
Debug: Check if the daemon process is still running (ps aux | grep daemon).
If it is running but not responding, it is frozen. Attach strace.
6. Defense-in-Depth Architecture
The two-tier model:
+----------------------------+
| systemd (outer) |
| Mount namespaces |
| Resource limits |
| (LimitNOFILE, MemoryMax) |
| Watchdog lifecycle |
| ProtectSystem, |
| ProtectHome |
+-------------+--------------+
|
+-------------v--------------+
| Application (inner) |
| Landlock filesystem ACL |
| seccomp-bpf syscall |
| filter |
| setrlimit |
| (NOFILE, MEMLOCK) |
| Directory bootstrap |
+----------------------------+
systemd owns:
- Process lifecycle (start, stop, restart, watchdog)
- Outer filesystem isolation (mount namespaces)
- Resource limits that survive application bugs (
MemoryMax,TasksMax) - Compliance posture (auditors can inspect unit files)
The application owns:
- Inner filesystem isolation (Landlock – more granular than mount namespaces)
- Syscall filtering (seccomp – systemd’s
SystemCallFilteris a convenience wrapper, but application-level gives more control) - Resource self-limits (
setrlimit– defense against fd leaks, memory leaks) - Directory bootstrapping (portable across platforms)
Both layers are required:
- systemd provides the compliance and lifecycle layer. Auditors and distribution packagers can review unit files without reading application code.
- Landlock and seccomp provide the defense-in-depth layer. They protect against vulnerabilities within the application itself.
- The application must work on non-systemd platforms (containers, macOS, embedded Linux). Landlock and seccomp are Linux-specific but do not require systemd. The application’s bootstrap code handles the portable case.
7. Checklist: Hardening a New Daemon
Use this checklist when adding security hardening to a new daemon. Each item addresses a specific failure mode described in this guide.
systemd unit file
-
Type=notifywithsd_notify("READY=1")in application code -
WatchdogSec=30s(adjust to your heartbeat interval) -
TimeoutStopSec=10s(enough for graceful shutdown) -
Restart=on-failure,RestartSec=2s -
ProtectSystem=strict -
ProtectHome=read-only -
ReadWritePaths=for every writable directory -
NoNewPrivileges=yes -
PrivateTmp=yes - tmpfiles.d rules for every directory in
ReadWritePaths
Application bootstrap
-
bootstrap_dirs()creates all required directories (portable fallback) -
setrlimit(RLIMIT_NOFILE, ...)to cap file descriptors -
setrlimit(RLIMIT_MEMLOCK, ...)if using mlock for secrets
Landlock
- Grant
ReadWriteto runtime directory ($XDG_RUNTIME_DIR/myapp) - Grant
ReadOnlyto config directory ($XDG_CONFIG_HOME/myapp) - Grant
ReadWriteto data directory ($XDG_DATA_HOME/myapp) - Canonicalize all paths to resolve symlinks (NixOS/Guix)
- Grant
ReadOnlyto/dev/urandomif using crypto - Request every right and scope of the newest ABI the crate knows, best-effort, so each kernel enforces all it supports
- Report the protections the kernel does not enforce, at startup and in
diagnostics (below ABI 9 pathname socket
connectis unmediated) - Grant each socket the process connects to,
$NOTIFY_SOCKETamong them, and nothing else: never the session D-Bus bus - Request every scope (abstract sockets, signals)
- Test each restriction where the kernel enforces it and where it does not
- Test on NixOS or with symlinked configs
seccomp allowlist
- Trace with
strace -funder ALL code paths - Include
fsyncANDfdatasync(SQLite uses both) - Include
inotify_init1,inotify_add_watch,inotify_rm_watchif using file watchers - Include
readlink,readlinkatif paths may be symlinks - Include
getrandomfor crypto operations - Include
clone3if targeting glibc >= 2.34 - Use
SECCOMP_RET_KILL_PROCESS(notKILL_THREAD) in production - Use
SECCOMP_FILTER_FLAG_TSYNCfor multi-threaded programs - Kill on a foreign architecture (
set_act_badarch):socketcalland 32-bit entry points bypass per-call rules - Admit
socket/socketpaironly for the families the program uses (argument 0), and leaveio_uringout
Defensive timeouts
- Every
spawn_blockingwrapped withtokio::time::timeout - Timeout duration is shorter than
WatchdogSec / 2 - Timeout fires a log message identifying the blocked operation
Observing kills
-
kill_processlisted in/proc/sys/kernel/seccomp/actions_logged(the default), so each kill is an audit record naming the call - No
SIGSYShandler relied on: kill verdicts never run it (2.3)
Watchdog
- Ticks inside the main event loop (
tokio::select!branch) - Does NOT tick in a separate thread
- Interval is
WatchdogSec / 2or less
Testing
- Wipe all state directories and recreate from scratch
- Start all daemons – verify no 226/NAMESPACE errors
- Exercise all features under normal operation
- Trigger error paths (bad input, network down, disk full)
- Verify watchdog ticks appear in journal
- Verify graceful shutdown completes within
TimeoutStopSec - Run full test cycle twice (catches state leaks from first run)