Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

secrets: specification

  • Status: draft 1, 2026-11-23. The implementation is in progress.
  • Audience: implementers of this repo, reviewers, and anyone who wants to write a compatible client or server.
  • Names: the project is secrets and the CLI is secrets-chad. The protocol uses secrets in the server binary (secrets-server), environment variables (SECRETS_*), the project file (.secrets.toml), the well-known path (/.well-known/secrets-server) and the domain-separation strings (secrets/v1/...).

Parts marked planned do not exist yet.

The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are used as described in RFC 2119 and RFC 8174.

Contents

  1. Goals and non-goals
  2. Concepts and terms
  3. Threat model
  4. Architecture
  5. Cryptography
  6. The project log
  7. Identity and authentication
  8. Authorization
  9. Key lifecycle: sharing, approval, removal, rotation
  10. HTTP API
  11. CLI
  12. Web app
  13. Instance admin
  14. Server operation
  15. Repository, build and release
  16. Conformance and testing
  17. Milestones

1. Goals and non-goals

Purpose

Programs get their secrets from a server that cannot read them. People share projects, machines get only the environments that an owner gave them, and the server can neither read a secret nor give access. A feature that needs the server to read a secret does not belong here.

Goals

  1. End-to-end encryption. Only clients (CLI, web app) see plaintext secret values. The server, its database, its backups, the host’s root user, and any reverse proxy or CDN in front of the server see ciphertext only.
  2. Server cannot grant access. Adding a member or a device to a project needs a signature from a project owner. A malicious server cannot add itself as a reader.
  3. Multi-user. People have accounts, own projects, share projects with other people, and approve devices for them.
  4. Separation of operator and owner. The instance admin manages accounts and the instance. The admin cannot read secrets, approve devices, or join projects unless an owner adds them like any other user.
  5. Standard auth flows. The CLI uses the OAuth 2.0 Device Authorization Grant (RFC 8628). Access tokens are sender-constrained with DPoP (RFC 9449). Machines get tokens with JWT bearer assertions (RFC 7523). People log in with passkeys (WebAuthn Level 3).
  6. Easy to use in deploys. One CLI call runs a command with secrets in its environment, or writes them to a .env or JSON file, or merges them into an existing file.
  7. Self-hostable. One server binary, an embedded SQLite database or a PostgreSQL server, a static web app. Any client can point at any compliant server.
  8. Open protocol. This spec is precise enough for an independent compatible implementation. The reference implementation (this repo) is the source of truth where the two disagree, until the spec is fixed.
  9. Small and fast. A small VM (1 vCPU, 1 GB RAM) serves hundreds of users. A bulk read of an environment answers in single-digit milliseconds on the server.

Non-goals (v1)

  • Credentials that the server makes or rotates (database users, cloud STS credentials). The server would need admin rights at the other system, and would see each credential. A client can make a value and store it, as any other value.
  • Secret values larger than 64 KiB, or binary files. (Encode them as base64 text if you must.)
  • Hiding project names, environment names, user handles, or the number and sizes of secrets from the server. (Secret names and values are encrypted; see §5.6.)
  • Protection against a client that is compromised while it holds keys.
  • Federation between servers. A user account belongs to one server.
  • Workload identity federation (for example CI OIDC tokens). CI uses an exported machine-device credential (§7.6).
  • Secret references (a value that points at another secret). Each value is plain text.
  • High availability. One server process per database. (PostgreSQL can be made highly available on its own, but the server does not coordinate several processes.)

2. Concepts and terms

TermMeaning
InstanceOne deployment of the server, with its own users.
UserA person with an account on an instance. Logs in with passkeys.
Instance adminA flag on a user account that allows invites and instance management through the admin panel. Not a project role.
ProjectA named container of environments, owned by one or more users.
EnvironmentA named set of secrets inside a project, for example dev or prod. Each environment has its own key.
SecretA named value (UTF-8 text) in an environment, with a version history.
MemberA user with a role on a project: owner, writer or reader.
DeviceA client keypair registered with the server. A user device acts as its user. A machine device has grants on specific environments only.
Browser sessionA short-lived, DPoP-bound session created by a passkey login in the web app.
GrantPermission for a machine device to read or read-write one environment.
Identity keyA user’s long-term key pair (signing + encryption).
Environment key (EK)The symmetric key that encrypts an environment’s secrets. Versioned by epoch.
Project logA hash-chained list of owner-signed entries that defines a project’s members, devices, grants, environments and key epochs. See §6.
FingerprintA short, human-comparable hash of a public key set.

3. Threat model

Assets

  1. Secret values (plaintext).
  2. Environment keys, identity private keys, device private keys.
  3. The integrity of who has access (membership, devices, grants).
  4. Secret value integrity (a client gets the value a legitimate writer wrote).

Adversaries and what the design guarantees

AdversaryCanCannot (guaranteed by design)
Stolen database or backup (database files or dump, backup replica in object storage, disk snapshot)Read metadata: user handles and display names, project and environment names, secret IDs and counts, version counts, ciphertext sizes, timestamps, public keys, audit log.Read any secret name or value, or any private key. Use any credential (tokens are stored hashed; device auth needs private keys the server never has).
Network or CDN (TLS-terminating proxy, tunnel provider)See the same metadata as above, in transit. Drop or delay requests.Read secret values. Replay requests (DPoP proofs are bound to method, URL, time, token, and a server nonce).
Malicious or compromised server (root on the host)Everything above. Refuse service. Withhold new versions from a client that has not seen them (freeze). Serve stale data to a client with no local state. Offer a wrong public key for a user being invited (mitigated by fingerprints, see below).Read secret values. Add a member, device or grant (needs an owner signature). Forge or alter a secret value (needs a writer signature). Roll back a client that has seen a newer state (detected by the client’s cached log head and versions).
Compromised web app hosting (whoever can change the JS/WASM served to browsers)Steal keys from users who log in, sign up or approve a device while the hosting is compromised.Read anything through a user who does not open the web app in that time. Every user opens it: to sign up, and for each new device. This is why the recommended deployment serves the web app from a host separate from the API server; see §4.3.
Removed member or revoked deviceKeep any plaintext and keys it already had.Read anything written after its removal (removal forces key rotation, see §9.4). Authenticate.
Other users of the instanceSee user display names and identity fingerprints of users they share projects with.See anything in projects they are not members of.
Instance adminDisable users and devices (denial of service), see instance-wide metadata, read the database (same as a stolen database).Read secret values. Grant access.
Phishing of device approval (an attacker starts a device flow and tricks an owner into approving it)Get approved if the owner ignores the warnings.Get approved silently. The approval page shows the device name, IP address, client and requested access, and the owner must type or confirm the user code. See §7.4.

Explicit limitations

  • Endpoints are trusted. A compromised laptop, CI runner or app host reveals what it can decrypt.
  • Public key substitution at first contact. When an owner shares a project with a user for the first time, the server supplies that user’s public keys. A malicious server could supply its own. Clients pin a user’s keys after first use (TOFU) and show the fingerprint; owners who care compare fingerprints out of band. Device approval is not affected: the user code ties the approval to the device that started the flow, and the device’s key fingerprint is shown on both sides.
  • Freeze for fresh clients. A client with no cached state cannot detect that the server hides the newest log entries or secret versions.
  • Some metadata is not secret. Project names, environment names, membership, devices, counts, sizes and times are visible to the server.

4. Architecture

4.1 Components

┌──────────────┐  HTTPS (DPoP)   ┌─────────────────────────┐
│ CLI          │────────────────▶│ secrets-server          │
│(secrets-chad)│                 │  public listener        │──▶ storage: SQLite or PostgreSQL ──▶ backups
└──────────────┘                 │  admin listener         │
┌──────────────┐  HTTPS (DPoP)   │                         │
│ Web app      │────────────────▶│                         │
│ (static WASM)│                 └─────────────────────────┘
└──────────────┘                        ▲ admin listener: private network only
       ▲ served by any static host      │
       │                         ┌─────────────────┐
     browser                     │ Admin panel     │ (server-rendered HTML, no crypto)
                                 └─────────────────┘
  • secrets-core (Rust library, compiles to native and wasm32-unknown-unknown): all cryptography, encodings, project log validation, request signing. The CLI, the web app and the server use the same crate.
  • secrets-server (Rust binary): HTTP API, WebAuthn verification, OAuth endpoints, storage, admin panel. The storage backend is SQLite or PostgreSQL, chosen at build time (cargo features) and at run time (database URL); see §14.2. It stores ciphertext, public keys and signed records, and validates signatures and rules. It never needs a private key of any user, device or environment, and it has no secret configuration of its own (see §14.5).
  • secrets-chad (Rust binary, the CLI): login, device enrollment, read/write, export, run, owner actions.
  • Web app (Leptos, client-side rendered, compiled to WASM): login, projects, sharing, approvals, rotation. A static bundle. It runs all cryptography locally through secrets-core.
  • Admin panel: served by the server on the admin listener only. Server-rendered HTML; it holds no keys.

4.2 Hostnames and discovery

A deployment has three origins:

OriginServesExample
Web originThe static web app, and the discovery documenthttps://secrets.example.com
API originThe public listenerhttps://secrets-api.example.com
Admin originThe admin listener, on a private networkhttps://secrets-admin.internal.example.com

The web origin and the API origin MAY be the same (the server can serve the web bundle itself, see §14.1). The admin origin MUST be different from both.

Discovery. A client given a host H fetches https://H/.well-known/secrets-server. The document is JSON:

{
  "issuer": "https://secrets-api.example.com",
  "api_base": "https://secrets-api.example.com/v1",
  "auth_path": "/v1/auth",
  "web_app": "https://secrets.example.com",
  "device_authorization_endpoint": "https://secrets-api.example.com/oauth/device_authorization",
  "token_endpoint": "https://secrets-api.example.com/oauth/token",
  "verification_uri": "https://secrets.example.com/device",
  "protocol_versions": ["1"],
  "dpop_signing_alg_values_supported": ["ES256", "EdDSA"],
  "server_version": "0.1.0"
}
  • Both the web origin and the API origin MUST serve this document with the same content.
  • A client MUST use HTTPS, except for localhost, 127.0.0.1 and ::1 with an explicit http:// host (development).
  • A client MUST reject a document that does not list a protocol version it supports.
  • A client stores the issuer with its login. Every token and every key is scoped to an issuer.
  • auth_path is where the account API is, below the issuer; a document without it means /v1/auth.
  • secrets-server runs under systemd as its own user on a small VM. The public listener binds 127.0.0.1; a reverse proxy or an outbound tunnel publishes it at the API origin.
  • The admin listener binds 127.0.0.1 on another port, and is published only on a private network (a VPN or an overlay network with HTTPS).
  • The web app is a release bundle from this repo, served by a static host or CDN at the web origin, with the deployment’s config.json and discovery document added (§12.3).
  • Storage is the embedded SQLite backend, and a SQLite replication tool (for example Litestream) copies the database to object storage. A deployment that already runs PostgreSQL can use it instead, with its own backups (§14.2).

Two reasons to host the web app separately from the API server:

  1. Root on the API host cannot change the code that runs in users’ browsers.
  2. The API host stays a dumb store with no influence over key handling.

Prefer a single-level API hostname such as secrets-api.example.com over api.secrets.example.com: many CDNs’ default wildcard certificates cover one subdomain level only.


5. Cryptography

All cryptography lives in secrets-core. No other crate may call a cryptographic primitive directly.

5.1 Primitives

PurposePrimitiveRust crate (planned)
SignaturesEd25519 (RFC 8032), strict verification (reject non-canonical and small-order keys)ed25519-dalek
Public-key encryption (“wrapping”)HPKE (RFC 9180), mode base, DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, ChaCha20Poly1305hpke
Symmetric encryptionXChaCha20-Poly1305, 24-byte random noncechacha20poly1305
Key derivationHKDF-SHA256 (RFC 5869)hkdf, sha2
Keyed hash (name lookup)HMAC-SHA256 (RFC 2104)hmac, sha2
HashSHA-256sha2
Constant-time comparison—subtle
RandomnessOS CSPRNG (getrandom; WebCrypto getRandomValues in WASM)getrandom, rand_core
Memory hygieneZero secrets on dropzeroize, secrecy

No other algorithms are allowed in protocol version 1. A new algorithm needs a new protocol version.

5.2 Encodings

  • Binary in JSON: base64url without padding (RFC 4648 §5).
  • Signed JSON: the JSON Canonicalization Scheme (JCS, RFC 8785). A signature covers "secrets/v1/sig/" || <purpose> || 0x00 || JCS(object), where the object excludes the sig field.
  • Associated data (AAD) and HPKE info: a domain string followed by length-prefixed fields: domain || for each field: u32_be(len(field)) || field. Fields are UTF-8 strings or raw bytes as listed.
  • IDs: 128-bit random values, encoded big-endian as 26 lower-case Crockford base32 characters (the first is 0–7), with a type prefix: usr_, prj_, env_, dev_, sec_, inv_. Example: prj_01jd8k3x9w7q2m5n4p6r8t0v2y.

5.3 Key types

KeyMaterialWhere the private part lives
Identity key (per user)Ed25519 signing key + X25519 encryption keyWrapped on the server (see §5.4); unwrapped in the web app memory and in user devices.
Device key (per device)Ed25519 signing key (also the DPoP key) + X25519 encryption keyOn the device only: a 0600 file, a CI secret, or the OS keyring (planned). Never sent anywhere.
Browser DPoP key (per browser session)Ed25519WASM memory, and encrypted in IndexedDB (§7.3), deleted at logout or expiry.
Environment key (EK)32 random bytes, one per (environment, epoch)Wrapped to each recipient with HPKE.
Recovery key (per user)32 random bytesShown once to the user (to store in a password manager or on paper).

Fingerprint of a public key set: SHA-256("secrets/v1/fpr" || ed25519_pub || x25519_pub), first 20 bytes, shown as 8 groups of 4 upper-case Crockford base32 characters (7KQ2-M9XA-…), most significant bits first. Clients MUST show fingerprints in exactly this form so people can compare them across clients.

5.4 Identity key protection

The server stores the identity private keys (ed25519_priv || x25519_priv, 64 bytes) once per unlock method, in a key envelope:

envelope = { kid, method, salt (32 B), nonce (24 B), ciphertext (64 B), tag (16 B) }
wrapping_key = HKDF-SHA256(ikm = unlock_secret, salt = salt, info = AAD("secrets/v1/identity-wrap", user_id))
ciphertext = XChaCha20-Poly1305(wrapping_key, nonce, identity_priv, aad = AAD("secrets/v1/identity", user_id, kid, method))

Unlock methods:

  1. Passkey PRF. unlock_secret is the output of the WebAuthn prf extension (hmac-secret on CTAP2 authenticators), evaluated with the fixed input secrets/v1/passkey-prf (22 ASCII bytes). Each credential has its own PRF secret, so the output is different for each passkey, and the random envelope salt makes each wrapping key different. A fixed input lets any browser get the PRF output in the login assertion. One envelope per registered passkey.
    • The web app MUST NOT send PRF output to the server. (It appears in clientExtensionResults, which the client controls; the web app strips it before it sends the assertion.)
    • Registration requires an authenticator that supports PRF. If the authenticator does not return PRF output, the web app refuses the registration and explains why.
  2. Recovery key. unlock_secret is the 32-byte recovery key. One envelope. The recovery key also gives the key that proves a recovery (auth-chad’s recovery_signer): the server keeps its public key, the recovery verifier, and replaces it with the envelope. The recovery key is shown to the user once, at signup, as 56 upper-case Crockford base32 characters in 14 groups of 4, joined by -: 52 characters for the key, then 4 for a checksum (the first 2 bytes of SHA-256 of the key). Each part is encoded most significant bit first and padded with zero bits. A client that reads a recovery key ignores case, - and white space, reads O as 0 and I/L as 1, and rejects a wrong length, non-zero padding bits or a wrong checksum. The user can replace it later from the web app (new envelope, old one deleted).
  3. User device. When a user device is approved, the approving browser seals the identity private key to the device’s X25519 public key with HPKE (info = AAD("secrets/v1/identity-to-device", user_id, device_id)). One envelope per user device.

If a user loses all passkeys, the recovery key and all user devices, the identity key is lost. See §9.6.

5.5 Environment keys

  • An owner’s client creates EK epoch 1 when it creates an environment, and a new epoch on every rotation.
  • The EK is sealed with HPKE to every recipient:
    • each project member (to the member’s identity X25519 key), and
    • each machine device with a grant on that environment (to the device’s X25519 key).
  • info = AAD("secrets/v1/ek-wrap", project_id, env_id, u32_be(epoch), recipient_id).
  • Every HPKE wrap in this spec uses single-shot base mode with empty AAD (the context is in info) and is encoded as enc (32 B) || ciphertext || tag (16 B), the RFC 9180 single-shot output. An EK wrap is 80 bytes; an identity key sealed to a device is 112 bytes.
  • Key commitment. HPKE base mode does not authenticate the sender, so a wrap alone proves nothing about who made the key: the server could seal a key of its own to a member. Every rotate entry therefore carries key_commitment = HKDF-SHA256(ikm = EK, salt = none, info = AAD("secrets/v1/ek-commit", project_id, env_id, u32_be(epoch))), 32 bytes in base64url, signed by the owner with the entry. A client MUST check every EK it unwraps against the commitment in the verified log before it uses the key to read or write.
  • A recipient gets wraps for the epochs from its join epoch onward. History before a recipient joined stays unreadable to it, by design.
  • User devices do not get their own EK wraps: they hold the user’s identity key and use the member wraps.

5.6 Secret names and values

Secret names and values are both encrypted. The server sees a stable random secret_id and a keyed hash of the name, never the name itself.

Subkeys. For each environment epoch, clients derive three subkeys from the EK:

subkey(purpose) = HKDF-SHA256(ikm = EK[epoch], salt = empty,
                              info = AAD("secrets/v1/ek-subkey", purpose, env_id, u32_be(epoch)))
value_key = subkey("value")      name_key = subkey("name")      name_mac_key = subkey("name-mac")

Name lookup hash. name_hmac = HMAC-SHA256(name_mac_key, utf8_name) (32 bytes). The server keeps a unique index on (env_id, name_hmac) over all secrets, deleted ones included. Writing a name whose name_hmac matches a deleted secret adds a new version to that secret (same secret_id). The hash depends on the epoch, so a rotation recomputes it for every secret (see §9.4).

Encryption.

name_nonce = 24 random bytes
name_ciphertext = XChaCha20-Poly1305(name_key, name_nonce, utf8_name,
                    aad = AAD("secrets/v1/name", project_id, env_id, secret_id, u64_be(version), u32_be(epoch)))
nonce = 24 random bytes
ciphertext = XChaCha20-Poly1305(value_key, nonce, utf8_value,
                    aad = AAD("secrets/v1/value", project_id, env_id, secret_id, u64_be(version), u32_be(epoch)))

Names and values are encrypted separately, so a client can list names without downloading values.

Each stored version is a secret record, signed by its writer:

{
  "project_id": "prj_…", "env_id": "env_…", "secret_id": "sec_…",
  "version": 7, "epoch": 2,
  "name_hmac": "…", "name_nonce": "…", "name_ciphertext": "…",
  "nonce": "…", "ciphertext": "…",
  "deleted": false,
  "log_seq": 12,                     // the project log head the writer verified
  "prev_record_hash": "…",          // SHA-256 of JCS of version 6's record, or null for version 1
  "created_at": "2026-11-23T20:14:00Z",
  "writer": { "kind": "user", "id": "usr_…" },   // or { "kind": "device", "id": "dev_…" }
  "sig": "…"                         // Ed25519 by the writer's identity key or device key, purpose "record"
}
  • name_ciphertext and ciphertext are the AEAD output with the 16-byte tag appended. name_hmac, the nonces, ciphertexts, prev_record_hash and sig are base64url. created_at is RFC 3339 UTC with whole seconds (2026-11-23T20:14:00Z). version and log_seq are integers below 2^53.
  • The record hash is SHA-256(JCS(record)), over the whole record including sig.
  • A delete is a record with deleted: true, empty nonce and ciphertext, and the name still encrypted (so owners can see and restore deleted names).
  • On rotation (see §9.5), the rotating owner re-encrypts the latest record of every secret, deleted ones included, under the new epoch, as a new version with a new name_hmac. Old versions keep their old epoch.
  • Values are UTF-8 text, at most 65,536 bytes.
  • Names match ^[A-Za-z_][A-Za-z0-9_]{0,127}$ (portable environment variable names).

5.7 Verification rules for clients

A client that reads a secret record MUST check, before it uses the value:

  1. The signature is valid for the writer’s key.
  2. The writer had write access to the environment at the time of the record, according to the verified project log (an owner or writer member, or a machine device with a read-write grant). The record’s log_seq field (the log head the writer saw) fixes “at the time”. In the state after entry log_seq:
    • the writer’s pinned fingerprint matches the key that signed the record,
    • the environment exists, its current epoch equals the record’s epoch, and no rotation is pending or required for it (a removal entry or a leave makes an environment read-only until its rotate entry).
  3. prev_record_hash matches the previous version the client has, if it has one.
  4. The version is not lower than a version the client cached before (rollback detection).
  5. Decryption of the name and the value with the AADs above succeeds.
  6. name_hmac equals HMAC-SHA256(name_mac_key, decrypted name), and no two secrets in the environment decrypt to the same name.

If any check fails, the client MUST stop and report an integrity error. It MUST NOT fall back to an unverified value.

5.8 Memory hygiene

  • Private keys, EKs and plaintext values live in zeroize-on-drop types.
  • The CLI SHOULD call mlock on key buffers where the OS allows it, and disable core dumps for its own process (prctl(PR_SET_DUMPABLE, 0) on Linux).
  • No client or server writes a secret value, private key or token to a log.

6. The project log

The project log is how clients know, without trusting the server, who has access to a project.

6.1 Entries

Each entry:

{
  "project_id": "prj_…",
  "seq": 12,
  "prev_hash": "…",                 // SHA-256 of JCS of entry 11 (including its sig); null for seq 1
  "type": "member_add",
  "body": { … },
  "author": "usr_…",
  "created_at": "2026-11-23T20:14:00Z",
  "sig": "…"                         // Ed25519 by the author's identity key, purpose "log"
}

Entry types and bodies:

TypeBodyWho may author
genesisproject_name, creator user_id, creator identity_fpr, nonce (32 random bytes)Any user (creates the project)
member_adduser_id, identity_fpr, roleOwner
member_roleuser_id, roleOwner (an owner may not demote the last owner)
member_removeuser_id, devices (absent if empty), rotations (see below)Owner (another member); or the member itself (leave). Never the last owner.
member_rekeyuser_id, identity_fpr, rotationsThe member itself, signed with the old identity key (§9.6)
env_createenv_id, env_nameOwner
env_renameenv_id, env_nameOwner
env_deleteenv_idOwner
device_grantdevice_id, device_fpr, env_id, access (read / read-write)Owner
device_ungrantdevice_id, env_id, rotationsOwner
rotateenv_id, epoch, reason (create / manual / removal), key_commitmentOwner
project_renameproject_nameOwner

Field encodings: fingerprints (identity_fpr, device_fpr) are the 20 fingerprint bytes in base64url; prev_hash is base64url; project_name and env_name match ^[a-z0-9][a-z0-9_-]{0,63}$; created_at is whole-second UTC (YYYY-MM-DDTHH:MM:SSZ). The entry hash is SHA-256(JCS(entry including sig)).

The project ID is bound to its first owner: project_id is the first 16 bytes of SHA-256(AAD("secrets/v1/project-id", user_id, identity_fpr, nonce)) over the genesis fields (identity_fpr and nonce as raw bytes). The server and every client MUST check it. A server can therefore not invent a log for a project ID that a client got from a source it trusts (a project file, a flag, a device scope). It can still list an invented project under a familiar name, so clients MUST store and use IDs after the first lookup.

rotations lists {env_id, epoch} for each environment the removed party could read, in the order the environments were created, each with the epoch after the current one:

  • An owner removes another member: every environment that is not deleted.
  • device_ungrant: that environment.
  • A member leaves: rotations is empty. The leaving member cannot rotate for the others, so every environment becomes rotation_required until an owner appends a manual rotation for it (see §9.4).

devices lists the machine devices that lose every grant in this project together with the member, each once, each with a grant. A member who leaves lists none. An empty list is absent from the signed JSON.

A removal entry with non-empty rotations must be followed directly, in the same request, by one rotate entry per listed rotation, in the same order, with reason: "removal", by the same author. An env_create must be followed directly by its rotate entry with epoch: 1 and reason: "create". No other entry may come between them.

6.2 Validation

The server and every client validate the log from genesis:

  1. seq starts at 1 and increases by 1. prev_hash matches.
  2. The signature is valid for the author’s identity key, as pinned by genesis or a member_add.
  3. The author had the required role in the state after entry seq - 1.
  4. The body is consistent with that state (no duplicate member, no grant on a deleted environment, epochs increase by 1, a project always has at least one owner).
    • Environment IDs are never reused, and names are unique among environments that are not deleted.
    • A device’s grants in one project all pin the same device_fpr.
    • A rename or role change must change something. env_delete ends every grant on that environment.
  5. The rotation rules in §6.1 hold. A log (or a batch of new entries) that ends while rotations are still due is invalid.

A removed member’s old entries stay valid: the client verifies each entry with the key whose fingerprint was pinned at the time, which it fetches with GET /v1/projects/{p}/keys and checks against the fingerprint.

The server rejects an invalid entry. A client that sees an invalid log stops with an integrity error.

6.3 Client state and rollback detection

  • A client caches, per project, the highest (seq, entry_hash) it has verified.
  • When the server returns a log, the client checks that it contains the cached entry with the same hash, and that it is not shorter. Otherwise the client reports a fork or rollback and stops.
  • The log is small (tens to hundreds of entries), so clients fetch it whole and incrementally (?after_seq=).

6.4 Identity key pinning

  • member_add pins the member’s identity fingerprint. It changes only with a member_rekey that the old identity key signs, or with a member_remove and a new member_add (see §9.6). A client that sees a member_rekey of another member after its cached log head MUST warn the user and show the new fingerprint.
  • When an owner adds a user, the owner’s client fetches the user’s public keys from the server, shows the fingerprint, and pins it in the entry. If the client has seen this user before (in another project, or cached), it MUST warn loudly when the fingerprint differs.

7. Identity and authentication

7.1 Overview

ClientHow it gets an access tokenToken binding
Web appPasskey login → browser sessionDPoP, browser Ed25519 key
User device (CLI on a laptop)Device grant once; then JWT bearer assertionsDPoP, device Ed25519 key
Machine device (server, CI)Device grant once; then JWT bearer assertionsDPoP, device Ed25519 key
  • Accounts, sessions, invites, devices and tokens are auth-chad (its specification, profile AC1), with namespace secrets/v1, invite-only signup, key-bound sessions only, end-to-end encryption (its spec 12), and the limits of this section. Its account API is mounted below /v1/auth (the server’s auth_path, written {auth} here) and its OAuth endpoints at /oauth/*. This document has what is different or added: the rules of this application are its hooks. auth-chad knows nothing of projects or secrets.
  • IDs in the account API are base64url of their 16 bytes. This application’s own routes and its signed log use the usr_…/dev_… text of the same bytes. Clients map between the two.
  • Access tokens are opaque, 32 random bytes, valid 15 minutes. The server stores only their SHA-256 hash. Every access token is DPoP-bound (cnf.jkt semantics, RFC 9449); a request with a token and no valid proof is rejected.
  • There are no refresh tokens. A device proves possession of its device key to get a new access token (RFC 7523, §7.5). Revoking a device ends all its access within 15 minutes, or at once for new token requests. A CI job needs one secret (the device key), not a rotating token.

7.2 DPoP

The server implements RFC 9449 with these choices:

  • Algorithms EdDSA (Ed25519) and ES256. The key fixes the algorithm. The JWK thumbprint (RFC 7638) identifies it. A device’s key is Ed25519, because it also signs records.
  • Proofs MUST include jti, htm, htu, iat, and ath when an access token is present. A proof without an access token MUST NOT carry ath.
  • The header has typ = dpop+jwt, alg and a public jwk; a jwk with a private member (d) is rejected. jti is 1–64 characters (clients use 16 random bytes in base64url). A proof is at most 4096 bytes.
  • The server requires a server nonce (DPoP-Nonce). Nonces rotate every 5 minutes; the server accepts the current and previous nonce. A request with a missing or old nonce gets 401 with use_dpop_nonce and a fresh nonce; clients retry once.
  • iat must be within ±60 seconds of server time. The server rejects a reused jti within the nonce window.
  • htu is compared exactly, without query and fragment (RFC 9449 §4.3), to the public URL the server is configured with plus the request path (not to the Host header), because the server sits behind a proxy.

7.3 People: passkeys (WebAuthn)

  • Relying party ID: the web origin’s host (for example secrets.example.com). The server verifies the origin against its configured web origin(s).
  • Signup is by invite only (see §13). Flow:
    1. The user opens the invite link in the web app and chooses a display name and a handle (unique, ^[a-z0-9_-]{3,32}$).
    2. The web app creates a passkey with residentKey: required, userVerification: required, and the prf extension. If the create response has no PRF output, it runs one get to evaluate PRF, started by a new user gesture: some browsers refuse a second passkey prompt without one.
    3. The web app generates the identity key and the recovery key, builds two envelopes (passkey PRF, recovery key), and sends them with the recovery verifier and the attestation (POST {auth}/signup/finish, field e2ee). The public keys of the identity key are in the signup’s app field: {"identity": {"sig_pub", "enc_pub"}}. The server stores the profile (handle, display name, fingerprint, and the admin flag of a host’s admin invite) in the same commit. Attestation format none is accepted.
    4. The web app shows the recovery key once and asks the user to confirm that they saved it (by typing 4 random groups of it).
  • Login:
    1. The web app creates a browser DPoP key, then asks for a discoverable-credential assertion with userVerification: required and PRF evaluation (prf.eval) with the fixed input of §5.4. One prompt signs and gives the PRF output.
    2. The server verifies the assertion and returns a browser session: an access token bound to the browser DPoP key, the user’s envelope for that credential, and the user’s public data.
    3. The web app unwraps the identity key in memory.
  • Credential algorithms and attestation: the server offers ES256 (-7), EdDSA (-8) and RS256 (-257) in pubKeyCredParams and accepts attestation format none only. It follows WebAuthn Level 3 §7.1 and §7.2 with this policy:
    • UP and UV are required. BS without BE is rejected.
    • crossOrigin: true and any topOrigin are rejected. The origin must match exactly.
    • The credential public key has exactly the required COSE parameters. Duplicate or optional parameters are rejected.
    • The signature counter starts at the registered value. It must increase when either side is non-zero.
    • Authenticator data has no trailing bytes. Extension data, if present, is one CBOR map. An assertion carries no attested credential data.
    • Client data that is not valid UTF-8 is rejected (stricter than WebAuthn, which replaces invalid sequences).
    • The WebAuthn user handle is the 16 raw bytes of the user ID. login/finish MUST carry it (user_handle), and it MUST match the owner of the credential.
  • Ceremonies are stateless: …/start returns an opaque ceremony token (a MAC over the challenge, its kind and expiry, valid 5 minutes) that the client sends back to …/finish. Each challenge is accepted once.
  • Envelope key IDs: a passkey envelope uses kid = base64url of the credential ID; the recovery envelope uses kid = recovery (§5.4). The user text in the envelope’s AAD is the usr_… form of the user ID.
  • Login response (POST {auth}/login/finish): the user, the session, the access token, and the envelope of the passkey that signed.
  • Browser session lifetime: access token 15 minutes, renewable with POST {auth}/session (the current token in Authorization and a DPoP proof over it; the token may already be expired) for up to 1 hour idle and 12 hours absolute. After that, the user logs in again with a passkey.
  • Keeping the identity key across page reloads: the web app stores the identity private key, the browser DPoP key and the session token in IndexedDB, encrypted with a non-extractable WebCrypto AES-GCM key, for the life of the browser session. It MUST delete them at logout, and when it finds that the session ended. The encryption protects a copy of the browser profile that does not include the non-extractable key. It does not protect against a script that runs on the web origin: such a script can read the stored keys and use them until the session ends (the token and the DPoP key), and later (the identity key). A non-extractable WebCrypto DPoP key would not change this, because the same script can read the identity key, which is worth more. The defence against such a script is the CSP and the absence of third-party code (§12.2). After a suspected compromise, the user replaces the identity key (§9.6).
  • Fresh login: adding or removing a passkey, setting the recovery key and approving a device need a passkey assertion that is at most 15 minutes old. Otherwise the answer is 401 step_up_required, and the client asks for the passkey with POST {auth}/step-up/start and /finish, for a named action. A device can never do these things.
  • More passkeys: a logged-in user can add passkeys (each with its own PRF envelope) and remove them, as long as one passkey remains.
  • Recovery (auth-chad’s recovery with the key, end-to-end): POST {auth}/recovery/key/start with the handle returns the options of a new passkey and the recovery envelope (for an unknown handle, a decoy of the same shape, the same each time). The web app opens the envelope with the recovery key, signs the challenge with the recovery key’s signer, and finishes (/recovery/key/finish) with the new passkey and its envelope. The account is then on hold (72 hours): an older passkey can undo the recovery, and the recovery key cannot change. Recovery by email or by an owner is refused: it cannot restore the identity key.
  • Recovery status: GET {auth}/recovery returns has_key and hold_until. Accounts from before the recovery verifier have a recovery envelope but no verifier (has_key is false): the web app and the CLI tell such a user to make a new recovery key. The web app shows a hold on every page.

7.4 CLI and machines: Device Authorization Grant (RFC 8628)

All device enrollment uses RFC 8628, with extension parameters for the device’s keys. One flow serves user devices and machine devices.

Step 1: device authorization request (POST /oauth/device_authorization, application/x-www-form-urlencoded):

ParameterValue
scopeuser for a user device. env:<project_id>/<env_id>:read / :read-write (space-separated, all in one project, at most 20) for a machine device. machine for a machine device whose approver chooses the project, the environments and the access
device_nameA label chosen by the user, for example alice-laptop or shop-prod-web (1–64 chars)
dataJSON: {"enc_key": <X25519 public key, base64url>, "client_info": <CLI name, version, OS and architecture, at most 128 characters, for example "secrets-chad/0.1.0 linux-aarch64">}

The request MUST carry a DPoP proof made with the device’s Ed25519 signing key: that key is the device key. A request with another scope or data is refused with invalid_scope. An approval of a device whose key is not Ed25519 is refused.

Step 1 response (RFC 8628 §3.2):

{
  "device_code": "…",                       // 32 random bytes, base64url; stored hashed
  "user_code": "WDJB-MJHT",                 // 8 chars, RFC 8628 §6.1 alphabet BCDFGHJKLMNPQRSTVWXZ
  "verification_uri": "https://secrets.example.com/device",
  "verification_uri_complete": "https://secrets.example.com/device?user_code=WDJB-MJHT",
  "expires_in": 600,
  "interval": 5,
  "device_id": "…"                          // base64url
}

The server assigns the device_id at this step; the approving owner signs it into device_grant entries. The DPoP nonce rules of §7.2 apply to both OAuth endpoints; a missing or stale nonce returns 400 {"error": "use_dpop_nonce"} with a fresh DPoP-Nonce header (RFC 9449 §8).

The CLI prints the URI, the user code, and the device fingerprint. It MUST NOT treat verification_uri_complete as a substitute for showing the code (RFC 8628 §3.3.1). If a person looks at the terminal, it also shows verification_uri_complete as a QR code, and opens it in the browser unless --no-browser is given, the session is remote (SSH) or there is no desktop. It does both only if that link is <web_app>/device?user_code=<user_code>, with the web_app of the discovery document: a server must not make the CLI open another address.

Step 2: user interaction (in the web app at verification_uri):

  1. The user logs in with a passkey (if not already logged in) and enters or confirms the user code.
  2. The web app fetches the pending request (GET {auth}/device/{user_code}: device, name, public_key, scope, data, ip, created) and shows: device name, device fingerprint (from public_key and enc_key), requested scope (project and environment names, access level), the requester’s IP address, client_info, and the time of the request.
  3. The page shows a warning: “Approve only if you started this on a device you control, just now.”
  4. The user clicks Approve or Deny.
    • User device (scope=user): any logged-in user may approve, for their own account. The web app seals the identity private key to device_enc_key (see §5.4) and uploads the envelope with the approval.
    • Machine device (scope=machine): the approver first chooses one project that they own, at least one of its environments, and the access. Anyone who is logged in and has the user code can see or deny the request, as for a user device. The rest is the same as below.
    • Machine device (scope=env:…): the approver MUST be an owner of the project. The web app appends one signed device_grant log entry per environment, and seals the current EK of each environment to device_enc_key. The server checks the approver’s role and the log entries.

Step 3: device access token request (POST /oauth/token, polled every interval seconds):

grant_type=urn:ietf:params:oauth:grant-type:device_code
device_code=…

with a DPoP proof made with the device key. Responses follow RFC 8628 §3.5: authorization_pending, slow_down (the client adds 5 seconds to its interval), access_denied, expired_token. On success:

{
  "access_token": "…",
  "token_type": "DPoP",
  "expires_in": 900,
  "scope": "user",                 // the requested scope
  "device_id": "…"                 // base64url
}

The device then fetches its key material (GET /v1/me/keys) and verifies it. The envelope that holds the identity key is not authenticated: the server could seal an identity of its own. A client MUST therefore make the user enter the identity fingerprint that the approving browser shows, and compare it, before it stores anything. No flag skips this. The response has device_id, device_name, user_id (user devices) and envelope (the identity key sealed to the device, user devices only). A machine device lists its projects with GET /v1/projects and fetches its EK wraps per project.

The approval API used by the web app is auth-chad’s, with this application’s rules in its hooks:

  • GET {auth}/device/{user_code}, as above. For a machine scope with a project, only an owner of the project sees it; anyone else gets 403.
  • POST {auth}/device/{user_code}/approve with {"app": {"kind":"user","envelope":…}} or {"app": {"kind":"machine","entries":[…],"wraps":[…]}}. The scope decides the kind of the device. The machine entries MUST be exactly one device_grant per requested environment, in scope order, with the request’s device_id, fingerprint and access. For an unassigned request they MUST be 1 to 20 device_grant entries of one project, with the request’s device_id and fingerprint. The server commits them, the wraps, the device and the approval in one transaction. A refusal of the entries or wraps has the codes of the project routes, for example integrity_error or wraps_mismatch.
  • POST {auth}/device/{user_code}/deny.
  • A request that is no longer pending returns 404 (or 409 conflict if it changed during the call).

Abuse limits (RFC 8628 §5):

  • User code entry: at most 5 failed attempts per browser session per 10 minutes, and 50 per IP per hour.
  • A device code is single use and expires after 10 minutes.
  • Device authorization requests: at most 10 per IP per hour.

7.5 Token renewal: JWT bearer assertions (RFC 7523)

A registered device gets a new access token with:

POST /oauth/token
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
assertion=<JWT>
  • iss and sub are the device ID as base64url of its 16 bytes. The JWT is signed with the device’s Ed25519 key. Header: alg = EdDSA, typ = JWT or absent, no jwk. Claims: iss and sub = device_id, aud = the token endpoint URL (a string, or an array that contains it), iat, exp, jti (1–64 characters).
  • The server accepts it when iat < exp <= iat + 300, iat <= now + 60 and now < exp.
  • The request carries a DPoP proof with the same key. The issued token is bound to it.
  • The server rejects the request if the device is revoked, its user is disabled, or the jti was used before.
  • Response as in step 3, without device_code semantics.

7.6 Device credential storage

ClientStorage
CLI on a desktop OS (planned; today: as on a server)OS keyring (macOS Keychain, Windows Credential Manager, Secret Service on Linux) through the keyring crate. Keyed by issuer + device_id.
CLI on a server (no keyring)A file, default $XDG_CONFIG_HOME/secrets-chad/devices/<device-id>.key, mode 0600, owner-only directory 0700. The CLI refuses a file with looser permissions.
CIA single environment variable SECRETS_DEVICE holding an exported device credential (see §11.7).

A device credential export is sdc1_ followed by base64url of the JCS JSON {issuer, device_id, sig_priv, enc_priv}. It is a secret; the CLI warns before printing it.


8. Authorization

8.1 Project roles

ActionOwnerWriterReaderMachine device read-writeMachine device read
Read secretsall envsall envsall envsgranted envsgranted envs
Write and delete secrets✓✓—granted envs—
See secret history✓✓✓granted envs, from grant epochgranted envs, from grant epoch
Create, rename, delete environments✓————
Add or remove members, change roles✓————
Approve and revoke machine devices✓————
Rotate keys✓————
See the project audit log✓————
Leave the project✓ (not the last owner)✓✓——
  • A user device has exactly its user’s rights. A browser session also.
  • Sharing a project with a user requires that the user exists on the instance. Owners find users by exact handle; there is no user directory.

8.2 Instance admin

The admin flag is a property of a normal user account. It gives access to the admin panel and to invites (see §13). It gives no project rights. The admin panel has no API to read key material, envelopes or secret records, and the public API uses the admin flag for invites only.

8.3 Quotas (defaults, configurable per instance and per user by the admin)

ItemDefault
Projects owned per user25
Environments per project20
Secrets per environment1,000
Versions kept per secret100 (older versions are pruned; the record chain restarts with prev_record_hash of the oldest kept record allowed to dangle)
Value size64 KiB
Members per project50
Devices per user50
Request body1 MiB (bulk writes), 8 MiB (identity key replacement), 128 KiB otherwise

9. Key lifecycle

9.1 Create a project

The creator’s client generates project_id, writes genesis, env_create for the first environment (default name default), and a rotate entry with epoch 1, and seals EK epoch 1 to the creator. The server stores all of it in one transaction.

9.2 Share a project with a user

  1. The owner enters the user’s handle. The client fetches the user’s public keys and shows the fingerprint (with a TOFU warning if it differs from a cached one).
  2. The client appends member_add and seals the current EK of every environment to the new member.
  3. The server stores the entry and the wraps in one transaction.

9.3 Approve a device

See §7.4. An owner can also add a grant to an existing machine device (device_grant + EK wrap), for another environment or another project they own (planned in the web app and the CLI). A device can have grants in several projects; an owner of each project approves its own grants.

9.4 Removal and mandatory rotation

Removing a member, revoking a grant, revoking a user device, or deleting a machine device removes a reader. Every such change MUST rotate the keys it affects, in the same request:

  1. The owner’s client generates a new EK epoch for each affected environment.
  2. It re-encrypts the latest record of every secret in those environments under the new epoch, as new versions signed by the owner.
  3. It seals the new EKs to every remaining recipient.
  4. It appends the removal entry (with rotations) and the rotate entries.
  5. The server commits all of it in one transaction, or nothing.

A machine device does not follow the person who approved it: it keeps its grants until an owner ends them. A removed owner can therefore still hold the key of a machine. So when an owner removes a member, the client MUST show the machine devices of the project with the owner who signed each grant (the author of the device_grant entry), and let the owner choose which to end in the same member_remove (devices). It preselects those that the removed member approved. Device names come from the server and are not signed; the client shows the fingerprint too. The machine list of a project marks a grant whose author is no longer an owner.

Affected environments:

RemovalRotated
Member removed or leftAll environments of the project
Machine device grant revokedThat environment
Machine device deletedEvery environment it had a grant on (across projects, one request per project)
User device revokedAll environments of all projects the user is a member of. The device held the user’s identity key, so clients tell the user to replace it (see §9.6).

The server enforces this: it rejects a removal entry without the matching rotation.

Removals the owner cannot do at once. Three cases have no owner client at hand:

  • The instance admin disables a user or deletes a machine device.
  • A user revokes one of their own devices, but they are not the owner of every project the user is a member of.
  • A member leaves a project (a member_remove they author, with empty rotations).

DELETE {auth}/devices/{id} revokes one of the caller’s user devices (a machine is refused: it ends through its projects). In one transaction the server marks the device revoked, deletes its tokens and its identity envelope, and marks every environment of every project of that user rotation_required. Clients read them with GET /v1/projects/{p}/pending. A commit that rotates an environment clears its mark. Every request checks that its device is not revoked and that its user is not disabled.

In those cases the server cuts access at once: it revokes tokens and refuses new ones. It then marks every affected environment rotation_required, and the web app and CLI show this to the owners until an owner completes the rotation. While it is pending, the server refuses new writes to those environments (reads continue), so no new secret is encrypted under a key that a removed party holds.

The client also tells the user that rotating keys does not change the secret values. A removed party may have copied values. The UI lists the secrets the removed party could read, so owners can change them at the source (for example, roll an API key at the provider).

9.5 Rotation

An owner can rotate an environment at any time (secrets-chad rotate, or the web app). This is the same procedure as in §9.4 with reason: "manual".

9.6 Account reset

Replacing the identity key (a user device was compromised, and the user still has a passkey):

  1. The user logs in with a passkey in the browser. The client generates a new identity key and a new recovery key, and the user saves the recovery key.
  2. The client asks for a challenge (POST /v1/me/identity/start, which answers WebAuthn request options) and signs it with the passkey, with the PRF extension.
  3. For every project of the user, the client builds one change:
    • a member_rekey entry with the new fingerprint, signed with the old identity key;
    • if the user is an owner: a rotate entry with reason removal for every live environment, signed with the new key, with the new wraps and the re-encrypted records. rotations lists them, as for member_remove;
    • if the user is not an owner: no rotations. The entry makes every live environment rotation_required;
    • a new wrap, sealed to the new key, for every EK wrap that the user holds, old epochs included.
  4. The request carries the passkey assertion (ceremony, credential), the new public keys, a signature with the new key over {"challenge": <base64url challenge>, "user_id": …} (purpose identity-proof), the two new envelopes, the new recovery verifier, and the changes.
  5. In one transaction the server checks and appends every change, replaces the user’s wraps and fingerprint, stores the envelopes and the recovery verifier, deletes the user’s other passkeys and other sessions, and revokes all user devices. If the changes do not cover exactly the user’s projects, it refuses with projects_changed. It accepts member_rekey in no other request.

After the member_rekey, the old key can sign nothing in that project, and the old key opens no EK of a later epoch. Records that the old key wrote before stay valid. The old key signs the change itself, so until then a thief with the old key and control of the server can replace the key first, as they can sign any other entry.

A user who lost every passkey and the recovery key has no old key to sign with:

  1. The admin starts a reset. The user signs up again through a reset invite with the same handle.
  2. Each owner of each affected project compares the new fingerprint and re-adds the user (member_remove with rotation, then member_add with the new fingerprint). If the user is the only owner of a project, that project is lost. The UI says so before the reset starts.

10. HTTP API

10.1 Conventions

  • Base path /v1. JSON request and response bodies (application/json), except OAuth endpoints, which use application/x-www-form-urlencoded requests as RFC 6749 requires.

  • Auth: Authorization: DPoP <access_token> and a DPoP proof header on every request except discovery, health, the WebAuthn ceremony starts, and the device authorization request (which carries a proof but no token). The account API authenticates every route, this application’s own routes included.

  • Errors: one shape on every route, the account API’s: a status and application/json {"error": "<code>"}, with a field for some codes (head, secret_id). OAuth endpoints use the RFC 6749 error format, which has the same field.

  • Writes that change the project log carry the client’s expected log head: If-Match: "log:<seq>". A mismatch returns 412 with the current head (head field); the client refetches and retries. A missing If-Match returns 428.

  • Error codes:

    StatuscodeMeaning
    400invalid_requestMalformed JSON, query or header, or a refused request of the account API
    400integrity_errorA signature, log rule or record check failed
    400wraps_mismatchKey wraps missing for a recipient, or given for someone who is not one
    400records_mismatchA rotation did not re-encrypt exactly the latest record of every secret
    401unauthenticated, invalid_dpop_proof, use_dpop_nonce, step_up_requiredWith a WWW-Authenticate: DPoP … challenge
    403forbiddenAuthenticated, but the role or grant does not allow it
    404not_foundAlso returned for projects the caller cannot see, so existence does not leak
    409log_changedThe log changed during the request; retry
    409version_conflictversion is not latest + 1
    409rotation_requiredAn owner must rotate the environment before it can be written
    409projects_changedThe request does not cover exactly the user’s projects (§9.6)
    409conflictThe state changed during the request, for example a device request that was decided
    409name_existsA secret with this name_hmac exists (secret_id field)
    412log_head_mismatchIf-Match does not match the log head (head field)
    413payload_too_largeBody over the limit
    428precondition_requiredIf-Match missing on a log write
    429rate_limitedToo many requests; see Retry-After
    503backendStorage is unavailable

    The account API has more codes, with the statuses of auth-chad (for example 403 on_hold, 409 last_passkey, 400 passkey_refused).

  • Every response carries a fresh DPoP-Nonce. A request without a valid nonce gets use_dpop_nonce, and the client retries once.

  • Lists are paginated with ?limit= (max 500) and an opaque ?cursor=.

  • Every response has Cache-Control: no-store.

  • CORS: the API allows the configured web origin(s) only, without credentials (there are no cookies), with the Authorization, DPoP, Content-Type and If-Match request headers and the DPoP-Nonce response header exposed.

10.2 Endpoints

Discovery, health and OAuth:

Method and pathPurpose
GET /.well-known/secrets-serverDiscovery (§4.2)
GET /healthz200 when the database answers
POST /oauth/device_authorizationRFC 8628 step 1
POST /oauth/tokenRFC 8628 device code grant, RFC 7523 JWT bearer grant
POST /oauth/revokeRevoke the current access token (RFC 7009)

auth-chad’s OAuth router also serves its metadata (/.well-known/oauth-authorization-server, /.well-known/oauth-protected-resource, /.well-known/openid-configuration, /oauth/jwks) and the routes for connected apps (/oauth/authorize, /oauth/par, /oauth/register, and {auth}/consent, {auth}/apps). This application registers no connected app and has dynamic registration off, so these routes give no access. Its own routes accept first-party callers only.

The account API (auth-chad, below {auth}, by default /v1/auth). Bodies and answers are those of auth-chad; what this application adds:

Method and pathPurpose
POST {auth}/signup/start, /signup/finishInvite-only signup. Needs a valid handle and display name. finish carries the envelopes, the recovery verifier and, in app, the identity public keys
POST {auth}/login/start, /login/finishPasskey login; the answer has the passkey’s envelope
GET/POST/DELETE {auth}/sessionThe session; renewal; logout
POST {auth}/step-up/start, /step-up/finishA new passkey assertion in a session, for a named action
GET/DELETE {auth}/sessions, DELETE {auth}/sessions/{id}List the sessions (with the passkey that opened each), end all, end one
GET/POST {auth}/passkeys, POST {auth}/passkeys/start, DELETE {auth}/passkeys/{id}Passkeys and their envelopes
GET {auth}/recovery, PUT {auth}/recovery/key, POST {auth}/recovery/key/start, /finish, POST {auth}/recovery/undoRecovery status, a new recovery key, recovery with it, undo (§7.3)
GET/POST {auth}/invites, GET/DELETE {auth}/invites/{id}Invites, for users with the admin flag. GET with a token checks it. An invite from the API never makes an admin
GET {auth}/events?before=Own account activity (§10.3)
GET {auth}/device/{user_code}, POST …/approve, POST …/denyDevice approval (§7.4)
GET {auth}/devices?kind=user, DELETE {auth}/devices/{id}Own devices; revoking a user device triggers §9.4

This application’s account routes:

Method and pathPurpose
GET /v1/meProfile and admin flag
GET /v1/me/keysFor a device: its envelope (user device) or nothing (machine device)
POST /v1/me/identity/start, POST /v1/me/identityReplace the identity key (§9.6); browser session and passkey only
GET /v1/users/{handle}Public keys and display name, for sharing

Projects:

Method and pathPurpose
GET /v1/projectsProjects the caller can see
POST /v1/projectsCreate (genesis + first environment + EK wrap)
GET /v1/projects/{p}/log?after_seq=Project log
POST /v1/projects/{p}/logAppend entries, with the EK wraps and re-encrypted records they need, in one transaction (member add/remove/role, env create/rename/delete, device grant/ungrant, rotate)
GET /v1/projects/{p}/keysEvery public key set the log pins (members, past members, devices), to verify the log
GET /v1/projects/{p}/peopleUser ID, handle and display name of members and past members (users only). Names only: the log pins the keys
GET /v1/projects/{p}/wraps?env=EK wraps for the caller
GET /v1/projects/{p}/devicesMachine devices with grants: ID, name, fingerprint (owners)
GET /v1/projects/{p}/audit?cursor=Audit log (owners)
GET /v1/projects/{p}/pendingEnvironments that wait for a rotation (members)

Secrets:

Method and pathPurpose
GET /v1/projects/{p}/envs/{e}/secretsLatest record of every secret (with ciphertext): the bulk read for run and export
GET /v1/projects/{p}/envs/{e}/secrets?values=0Latest records without nonce and ciphertext: encrypted names, versions, writers, times
GET /v1/projects/{p}/envs/{e}/secrets?name_hmac=…Latest record of the secret with that name hash (404 if none)
GET /v1/projects/{p}/envs/{e}/secrets/{s}Latest record
GET /v1/projects/{p}/envs/{e}/secrets/{s}/versionsHistory (records)
GET /v1/projects/{p}/envs/{e}/secrets/{s}/records/{version}One version
PUT /v1/projects/{p}/envs/{e}/secretsWrite one or more records atomically (import, multi-set). A new secret has version 1 and a client-generated secret_id; otherwise version must be latest+1, else 409. A new secret whose name_hmac already exists also gets 409, with the existing secret_id.

Path parameters {p}, {e} and {s} are IDs. Clients resolve project and environment names to IDs from the verified log, and secret names to IDs through name_hmac or a full listing.

10.3 Audit log

The server records, without names or values: time, actor (user or machine device), device (none for a browser session), IP address, action, project, environment, secret_id, and a number (the log seq of an entry, or the version of a written secret). It does not record the user agent: a client can send any text there.

  • Changes: one row per log entry (the action is the entry type) and one secret_write row per written record, in the same transaction as the change. Re-encrypted records of a rotation get no row of their own.
  • Reads: one secret_read row per request that returns records. secret_id is set when the request names one secret. The server keeps these rows in memory and stores them at least once per second and at shutdown. A crash can lose the last second of reads, but never a change. When the rows cannot be stored and the memory buffer (16,384 rows) is full, the server answers reads with 503: it does not serve what it cannot record.
  • Account: auth-chad’s events, one row per account action, in the same transaction as the action: signup, login (passkey), logout, step_up, recovered, recovery_key_set, passkey_add, passkey_remove, session_end, device_approve, device_deny, device_login (the approved device collects its first token), device_revoke, invite_create, invite_cancel, and this application’s identity_replace. Approve, deny and revoke rows name the target device (target, base64url). These rows belong to no project. A machine device’s approval is also the device_grant row of its project, with the approver’s IP address.
  • Retention: rows 365 days, IP addresses 30 days, by default ([audit] in the server config). ip_days = 0 stores no IP addresses.
  • GET /v1/projects/{p}/audit returns up to 100 rows, newest first, to owners: {"events": […], "next": <cursor>}. next is null on the last page. Clients show environment and secret names by decrypting them.
  • GET {auth}/events returns the caller’s own account rows, up to 100, newest first: id, time, action, target, ip, device. ?before=<id> gives the next page. Machine devices cannot read it.
  • The audit log is the server’s statement: it is not signed, and a malicious server can change it. The project log (§6) is the signed record of changes.

The admin sees instance-level entries (logins, invites, disables) and per-project counts in the admin panel.


11. CLI

Binary name: secrets-chad. Rust, single static binary per platform.

11.1 Host resolution

The CLI resolves the server in this order (first match wins):

  1. --host <host> flag.
  2. SECRETS_HOST environment variable.
  3. host in the nearest .secrets.toml (searched from the current directory up to the filesystem root).
  4. The default host in the user config ($XDG_CONFIG_HOME/secrets-chad/config.toml), set by the first login.

There is no built-in default host. With no host, the CLI fails with a message that names the four options. The CLI can hold logins to several hosts at once.

11.2 Project file

secrets-chad init writes .secrets.toml in the current directory. It contains no secret and is safe to commit:

host = "secrets.example.com"
project = "prj_01jd8k3x9w7q2m5n4p6r8t0v2y"   # IDs, not names, so renames do not break it
env = "env_01jd8k4b2c3d4e5f6g7h8j9k0m"       # default environment

--project and --env flags (names or IDs) override the file. --env shop/prod gives both: names have no /. SECRETS_ENV can have both too. A project from --env or SECRETS_ENV and one from an option of the same or a higher rank is an error. A project name resolves among the projects the caller can see; if two match, the CLI fails and asks for the ID (@owner-handle/name is planned). Environment names are unique within a project. The environment variables SECRETS_PROJECT and SECRETS_ENV sit between the flags and the file.

11.3 Account and device commands

CommandDoes
secrets-chad login [--host H] [--name N] [--no-browser]Device grant with scope=user (§7.4). Stores the device key in a 0600 file (in the keyring: planned).
secrets-chad logout [--host H]Revokes this user device (with the rotation it requires, see §9.4) and deletes local keys. --local deletes local keys only.
secrets-chad whoamiHost, user, device, fingerprints.
secrets-chad fingerprint [@handle] (planned)Show own or another user’s identity fingerprint, and whether it is pinned.

11.4 Secret commands

CommandDoes
secrets-chad initWrite .secrets.toml for the project and environment of -p and -e (an interactive choice is planned).
secrets-chad lsNames, versions, last writer, time.
secrets-chad get NAMEPrint the value to stdout (no trailing newline added when stdout is not a TTY).
secrets-chad set NAMERead the value from a hidden prompt, or from stdin when stdin is not a TTY. secrets-chad set NAME=VALUE is refused (values in argv leak to shell history and ps), unless --allow-argv (planned).
secrets-chad rm NAMEDelete (tombstone).
secrets-chad history NAME (planned)Versions, writers, times. --show decrypts.
secrets-chad import FILE [--format env|json] [--overwrite]Write all keys from a file in one atomic request. Without --overwrite, existing names are skipped and listed.
secrets-chad export ...See §11.5.
secrets-chad run [--] CMD ARGS...See §11.6.

11.5 Export

secrets-chad export [--project P] [--env E] --format env|json|docker [--out FILE] [--merge] [--only NAME,...] [--prefix PFX]
  • Without --out, export writes to stdout.
  • With --out, the CLI writes to a temporary file in the same directory with mode 0600, calls fsync, and renames it over FILE (atomic replace). It keeps FILE’s owner and group when it can, and sets the mode to 0600 unless --mode says otherwise (planned).
  • --only limits the export to the listed names. --prefix adds a prefix to every key in the output.
  • --merge (requires --out) reads the existing file and:
    • replaces the value of every key that is also in the export, in place (same line position);
    • keeps every other key, comment and blank line as it is;
    • appends exported keys that are not in the file at the end, after a comment line # added by secrets-chad <ISO-8601 time>;
    • for JSON, the file must contain one object; keys keep their order, new keys are appended, other values are kept.
    • If the file does not exist, --merge behaves like a plain write.
  • Exit status is non-zero, and the file is untouched, if any record fails verification (§5.7).

env format (works with common dotenv libraries, Docker Compose env_file, and systemd EnvironmentFile=):

  • One KEY="value" per line, keys sorted by name.
  • Inside the double quotes, these characters are escaped: \ as \\, " as \", newline as \n, carriage return as \r, $ as \$ (so no consumer expands variables).
  • The parser for --merge and import accepts unquoted values, single-quoted values (literal), double-quoted values with the escapes above, export KEY=… prefixes, and # comments. It rejects lines it cannot parse, with the line number.

json format: one JSON object {"KEY": "value", …}, keys sorted, two-space indent, trailing newline.

docker format (for docker run --env-file, which does not support quotes): KEY=value with the raw value. The export fails if a value contains a newline.

Example deploy step:

SECRETS_DEVICE="$DEPLOY_DEVICE" secrets-chad export --host secrets.example.com \
  --project shop --env prod --format env --out /opt/apps/shop/.env --merge

11.6 Run

secrets-chad run [--project P] [--env E] [--only …] [--prefix …] [--no-override] -- CMD ARGS...

  • Fetches and verifies the environment, sets the variables, and replaces itself with CMD (execvp on Unix; spawn and forward exit code and signals on Windows). No plaintext touches the disk.
  • By default secret values override variables already in the environment. --no-override keeps existing variables.

11.7 Machine and device commands

CommandDoes
secrets-chad machine create NAME [--env P/E[,E2]] [--access read|read-write] [--no-browser] [--github[=OWNER/REPO] [--github-env NAME] | --out FILE]Machine device grant. With names, the CLI looks them up, and needs a login. With IDs (also from .secrets.toml), it needs none. With neither, the approver chooses. Prints the user code and fingerprint, waits for an owner to approve, then prints what the machine can use. Stores the credential in --out, gives it to GitHub, or prints it (in the keyring: planned).
secrets-chad device export (planned)Print the current machine device credential as sdc1_… for a CI secret. Asks for confirmation; refuses when stdout is a TTY unless --yes.
secrets-chad device ls / revoke IDOwn user devices; revoke one, with the rotation it requires.
secrets-chad machine ls / revoke NAME|IDOwner: machine devices of the project; revoke one in the environment of --env, or in the whole project, with rotation.
secrets-chad machine grant ID --env E [--access …] (planned)Owner: add a grant to an existing machine device.

When SECRETS_DEVICE is set, the CLI uses that credential and ignores the device files.

machine create --github uses the GitHub CLI gh (installed and logged in by the person):

  1. Before it asks the server for anything, it checks that gh can store secrets in the repository and, with --github-env, in that GitHub environment. It names the repository, says if SECRETS_DEVICE exists there, and asks.
  2. After the approval, it gives the credential to gh secret set SECRETS_DEVICE on standard input. The credential is in no argument, file or output. If gh fails, the key is gone, and the CLI says how to revoke the machine.
  3. It prints the lines for the workflow.

secrets-chad doctor checks the server, the login, the chosen project with its log, and gh. Exit code 1 if one of the first three fails. A missing gh is a note, because only --github needs it.

11.8 Owner commands

CommandDoes
secrets-chad project create NAME[/ENV] / ls / rename (planned)Projects.
secrets-chad env create NAME / ls / rename, rm (planned)Environments.
secrets-chad share @handle --role owner|writer|readerAdd a member (§9.2).
secrets-chad unshare @handle [--revoke MACHINE[,M2] | --keep-machines]Remove a member, with rotation. At a terminal, it shows the machines and asks which to revoke too. Otherwise it refuses if the member approved machines and neither option is given.
secrets-chad approve USER_CODEPrints where to approve: a device has no passkey, so it cannot approve another one.
secrets-chad generate NAME [--kind alnum|hex|base64url] [--length N] [--overwrite]Creates a random value and stores it without showing it.
secrets-chad request NAME… [--no-wait] [--timeout S]Prints a web app link where a person enters the values, and waits for them.
secrets-chad check [NAME…] [--json]Which names are missing: these, or required in .secrets.toml. Exit code 1 if any is.
secrets-chad agentPrints the guide for coding agents (§11.11).
secrets-chad rotate [--env E | --all]Rotate keys, and complete pending required rotations.
secrets-chad activity [--limit N]Own account activity, newest first, one tab-separated line per row: time, acting device, IP address, action, target device.
secrets-chad audit [--limit N]Project audit log, newest first, one tab-separated line per row: time, actor, device, IP address, action, environment, secret, number. Showing secret names fetches them, which is itself a recorded read.
secrets-chad verifyFetch and verify the whole project log and every latest record; print the result.

11.9 Output and exit codes

  • Human output by default; --json gives machine-readable output for ls, check, project ls and env ls (other commands: planned).
  • Exit codes: 0 success, 1 generic error, 2 usage error, 3 not logged in or device revoked, 4 permission denied, 5 not found, 6 integrity error (verification failed, possible rollback or fork), 7 network or server error, 8 rotation required (writes refused).
  • Every command is non-interactive when stdin is not a TTY or --yes is given; it fails instead of prompting.
  • The CLI never prints a secret value unless the command’s purpose is to print it (get, export to stdout).

11.10 Local state

$XDG_CONFIG_HOME/secrets-chad/ (on macOS ~/Library/Application Support/secrets-chad/, on Windows %APPDATA%\secrets-chad\):

  • config.toml: default host, per-host issuer and device ID.
  • state/<issuer-hash>/pins.json: pinned user fingerprints, verified log heads, highest seen secret versions.
  • devices/<device-id>.key: device key files, mode 0600.

No local cache of secret values or EKs.

11.11 Coding agents

A coding agent runs commands and reads their output, so a value that a command prints is in the agent’s context, and often at a third party. The CLI detects an agent by SECRETS_AGENT (1 or 0), or by variables that known agents set. Then:

  • get, export to stdout and machine create without --out or --github are refused with exit code 9.
  • run replaces each value in the output of the command with [NAME]: the value, each of its lines, and its JSON and base64 forms, from 6 characters on, also across write boundaries. --mask does the same for a person. The exit code is the command’s.
  • share is refused: a person compares the fingerprint.

An agent that wants to can defeat this: it can run a program that transforms a value. It prevents accidents. The boundary is access: give an agent’s machine a device with read access to one environment.

skills/secrets-chad/SKILL.md is the guide for agents.


12. Web app

Leptos, client-side rendered, built with Trunk to a static bundle (HTML, WASM, JS glue, CSS). No server-side rendering, no third-party scripts, fonts or analytics.

12.1 Screens

  1. Invite / signup with recovery key display and confirmation.
  2. Login with passkey; recovery with the recovery key.
  3. Projects: list, create; per project: environments, secrets (names, versions, reveal and copy on demand, edit, history), members (share by handle, change role, remove), machine devices (grants, revoke), audit log, pending rotations, project log viewer with fingerprints.
  4. Device approval at /device (§7.4).
  5. Account: passkeys (the one of this session marked), recovery key (status, a missing key, a hold after a recovery, replace), sessions (end one), own devices, own fingerprint, activity, account reset. For a user with the admin flag: invites. A user without a recovery key, or on hold, sees it on every page.

12.2 Security requirements

  • Content Security Policy: default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; font-src 'self'; img-src 'self' data:; connect-src <api origin>; manifest-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'. The build MUST NOT use inline scripts (Trunk’s loader is emitted as a file, not inline).
  • Headers: Strict-Transport-Security, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, Cross-Origin-Opener-Policy: same-origin, Permissions-Policy denying everything not used, and Cache-Control: public, no-cache, no-transform, so that a CDN does not change the page. Static hosts set these from the _headers file shipped in the bundle.
  • Subresource Integrity on every script and stylesheet the HTML references.
  • Revealed values are hidden again after 30 seconds and on tab blur. Copy-to-clipboard clears the clipboard after 30 seconds where the browser allows it.
  • The identity key and EKs exist only in WASM memory (and the encrypted IndexedDB copy of §7.3).

12.3 Runtime configuration

The bundle is generic. At startup it loads /config.json from its own origin:

{ "api_base": "https://secrets-api.example.com/v1", "auth_path": "/v1/auth", "issuer": "https://secrets-api.example.com" }

cargo xtask web --issuer URL --web URL [--auth-path PATH] writes it.

A deployment adds config.json, /.well-known/secrets-server, and the CSP connect-src value to the bundle before it uploads it. Each release publishes the bundle as a .tar.gz with its SHA-256, so a deployment can prove which code it serves.


13. Instance admin

13.1 Admin listener and panel

  • The server serves the admin panel on a separate listener (admin_listen), which MUST NOT be exposed to the internet. The recommended deployment binds it to 127.0.0.1 and publishes it on a private network with HTTPS.
  • The admin panel uses its own WebAuthn relying party (the admin origin’s host), so admin passkeys are separate from user passkeys. Admin passkeys need no PRF: the admin panel holds no keys.
  • Server-rendered HTML with htmx-style forms (no client-side crypto). Sessions use a __Host- cookie with Secure, HttpOnly, SameSite=Strict, 1 hour idle, 8 hours absolute; every form has a CSRF token.

13.2 Bootstrap

secrets-server admin bootstrap (run on the host) prints a one-time link (valid 1 hour) on the admin origin to register the first admin passkey and link it to a user handle. It also prints a user invite link for that person. secrets-server admin add-admin <handle> does the same for another admin.

Until the admin panel exists, secrets-server [--config PATH] admin invite [--admin] creates an invite (valid 7 days, single use) and prints the signup link <web origin>/signup?invite=<token>. With --admin, the account it creates has the admin flag. Only this command creates such invites.

13.3 Admin actions

ActionNotes
Create, list and cancel invite links (single use, 7 days)Also in the web app, for a logged-in user with the admin flag ({auth}/invites). The server stores a hash of the token, so it shows a link once. An invite from the API never gives the admin flag. A signup that started stops when its invite is cancelled.
List users (handle, display name, created, last seen, project and device counts)No project names.
Disable / enable a userDisable revokes tokens and devices at once and marks affected environments rotation_required (§9.4).
Delete a userOnly when the user is in no project, or after a 30-day disable.
Start a reset invite for a user who lost all passkeys§9.6.
Set quotas (instance defaults, per user)
View instance audit log, server version, storage backend, database size, replication statusReplication status from Litestream’s metrics, if configured (SQLite only).

The admin panel cannot approve devices, add members, read secret names, or see envelopes, wraps or records.


14. Server operation

14.1 Configuration

TOML file (default /etc/secrets/server.toml), every key overridable with SECRETS_SERVER_<KEY> environment variables:

public_listen = "127.0.0.1:8470"
admin_listen  = "127.0.0.1:8471"
database      = "sqlite:///var/lib/secrets/secrets.db"   # or "postgres:///secrets?host=/run/postgresql"
database_password_file = ""             # PostgreSQL password auth only; see §14.5

issuer        = "https://secrets-api.example.com"   # public URL of the API; used for htu and aud checks
web_origins   = ["https://secrets.example.com"]     # CORS and WebAuthn origins
rp_id         = "secrets.example.com"   # default: host of the first web origin; must cover every web origin
auth_path     = "/v1/auth"              # where the account API is; not a path of the other routes
admin_origin  = "https://secrets-admin.internal.example.com"
admin_rp_id   = "secrets-admin.internal.example.com"

client_ip_header = "X-Real-IP"          # one address, set by the proxy (not a list); omit to use the socket address
serve_web_bundle = ""                   # path to a web bundle to serve from the public listener (self-hosting option)

[rate_limits]                           # see §14.3
auth_per_minute   = 20
writes_per_minute = 600

[audit]                                 # see §10.3
days    = 365
ip_days = 30                            # 0: store no IP addresses

[request_log]                           # see §14.4
enabled = false
format  = "json"                        # "json" or "logfmt"
fields  = ["time", "method", "route", "status", "duration_ms", "actor"]

The server refuses to start if admin_listen binds a non-loopback, non-private address, unless allow_public_admin = true.

14.2 Storage

The protocol does not depend on a database engine. A storage backend MUST provide:

  1. Atomic transactions over many rows. A log append commits its entries, EK wraps, re-encrypted records and audit rows together, or nothing (§9.4). A batch secret write is atomic.
  2. Serialized appends per project. Two concurrent appends to one project’s log cannot both commit the same seq. The losing request gets 409 and retries on the new head.
  3. Uniqueness: (project_id, seq) for log entries, (env_id, secret_id, version) for records, (env_id, name_hmac) for the latest record of each live secret, the user handle, and every token, device-code and user-code hash. A violated constraint maps to 409 (or to a new random value, for server-generated codes).
  4. Durability of a commit before the server answers.
  5. Read-your-writes for a client that reads after its own write.

Every backend passes the same conformance test suite.

Backends in this repo:

BackendCargo featuredatabase URLNotes
SQLite (default)sqlitesqlite:///path/to/secrets.dbBundled through rusqlite; one file.
PostgreSQLpostgrespostgres://… (libpq-style URL, no password in it)Through tokio-postgres, TLS through rustls. PostgreSQL 15 or later.

A release binary includes both. The server refuses to start if the URL scheme names a backend it was built without.

SQLite:

  • Pragmas: journal_mode=WAL, synchronous=FULL, foreign_keys=ON, busy_timeout=5000.
  • The server does not run wal_checkpoint(TRUNCATE) or VACUUM on its own, so a replication tool can manage checkpoints.
  • One writer connection behind a single task, which serializes appends; a pool of read connections (default 4). All SQLite calls run on blocking threads.
  • Backups: any tool that copies a SQLite WAL database consistently. Litestream is one such tool.

PostgreSQL:

  • A connection pool (default 8). Log appends lock the project row (SELECT … FOR UPDATE) and run at READ COMMITTED; the uniqueness constraints are the final guard.
  • TLS: for a host that is not a Unix socket or loopback, the default (sslmode=prefer) becomes require, with the certificate checked against the bundled Mozilla roots. It never falls back to plaintext. sslmode=disable turns TLS off explicitly. Private certificate authorities are not supported yet.
  • The server needs a database it owns (it creates its tables in the secrets schema).
  • Backups are the operator’s job (for example pg_dump, or WAL archiving).

Both:

  • Account tables are those of auth-chad, with the prefix auth_, in the same database. A change that needs both, such as a signup, a device approval or a new identity key, is one transaction. The server runs auth-chad’s background work every 5 seconds: it removes expired tokens, challenges, invites, marks and limits.
  • Migrations are embedded per backend and run at startup in a transaction. The schema version is stored in the database (PRAGMA user_version for SQLite, a schema_version table for PostgreSQL).
  • Backups and dumps contain no plaintext secrets and no credentials (see §3).

14.3 Limits and abuse controls

  • Request body limits as in §8.3.
  • rate_limits.auth_per_minute (default 20): calls of the account API without a login (login, signup, recovery, invite checks, device authorization and token requests), per client address and minute, counted in the database for every server process. The lookup of user codes has the same limit per user. Over the limit: 429 rate_limited.
  • rate_limits.writes_per_minute (default 600): changes through this application’s own routes, per address (token bucket, in memory). Over the limit: 429 rate_limited with Retry-After.
  • Timeouts: 10 s per request, 60 s idle keep-alive.

14.4 Logging and metrics

  • The server writes nothing to its logs about request content. The only log output is the optional request log: one structured line per request, written to stdout.

  • The request log is off by default (request_log.enabled = false).

  • request_log.format is json (one object per line) or logfmt.

  • request_log.fields selects the fields and their order, from this fixed set only:

    FieldValue
    timeRFC 3339 UTC time the request started
    methodHTTP method
    routeRoute template, for example /v1/projects/{p}/envs/{e}/secrets (never the concrete path)
    statusHTTP status code
    duration_msTime to the response, in milliseconds
    actorActor ID (usr_…, dev_…) or -
    client_ipClient IP address (from client_ip_header or the socket)
    request_idA random ID per request, also sent as the X-Request-Id response header
    bytes_in, bytes_outBody sizes
  • No configuration can add other fields. Tokens, DPoP proofs, envelopes, wraps, ciphertexts, secret IDs, project or environment IDs, query strings and WebAuthn payloads are never logged.

  • GET /metrics on the admin listener only (Prometheus text format).

14.5 Server secrets

The server needs no secret key material: tokens and device codes are stored as SHA-256 hashes, and WebAuthn and DPoP verification use public keys. The only sensitive files are the database (metadata) and the bootstrap links it prints. A deployment needs no KMS or secret store for the server.

The one exception is a PostgreSQL password. Prefer authentication without one (a Unix socket with peer authentication, or a client certificate). With password authentication, put the password in a file named by database_password_file (mode 0600), never in the database URL or the environment.

User= a dedicated user, NoNewPrivileges=yes, ProtectSystem=strict, ReadWritePaths=/var/lib/secrets, ProtectHome=yes, PrivateTmp=yes, PrivateDevices=yes, ProtectKernelTunables=yes, ProtectKernelModules=yes, ProtectControlGroups=yes, RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX, IPAddressAllow=localhost, IPAddressDeny=any, MemoryDenyWriteExecute=yes, LockPersonality=yes, SystemCallFilter=@system-service, LimitCORE=0, MemoryMax=256M. A sample unit ships in deploy/.


15. Repository, build and release

15.1 Layout

Cargo.toml                 # workspace
crates/
  core/                    # secrets-core: crypto, encodings, log validation, DPoP (no I/O)
  api/                     # secrets-api: HTTP request and response types shared by server, CLI and web (no I/O)
  server-app/              # application layer: use cases and the ports they need (Store, Clock, Rng, …); no I/O
  store-tests/             # conformance test suite that every Store adapter runs
  store-sqlite/            # Store adapter: SQLite
  store-postgres/          # Store adapter: PostgreSQL
  server-http/             # HTTP adapter: routes, extractors, DPoP and auth middleware, error mapping
  server/                  # secrets-server: composition root (config, wiring, listeners, binary)
  cli/                     # secrets (CLI)
  web/                     # Leptos web app (wasm32)
  test-vectors/            # generator and checker for docs/test-vectors/
docs/
  spec.md                  # this document
  test-vectors/            # JSON test vectors for every format in §5 and §6
deploy/                    # sample systemd unit, sample config, sample Litestream config
xtask/                     # build helpers (web bundle, release packaging)

The server follows a ports-and-adapters (hexagonal) layout. Dependencies point inward only: server → server-http, store-* → server-app → core. The application layer defines the ports as traits, and the adapters implement them. Use cases are generic over the ports (static dispatch), so tests run them against in-memory fakes without HTTP or a database.

15.2 Toolchain and dependencies

  • Stable Rust, MSRV pinned in rust-toolchain.toml and Cargo.toml (rust-version).
  • #![forbid(unsafe_code)] in core, cli and web; server allows unsafe only through dependencies.
  • Planned dependencies: axum, tokio, tower, tower-http, rusqlite (bundled), tokio-postgres, rustls, auth-chad (accounts, passkeys, sessions, devices), serde, serde_json, tracing, clap, reqwest (rustls only), keyring, leptos, crypto crates from §5.1. Any new dependency needs a reason in the PR.
  • cargo-deny checks licenses (permissive only: MIT, Apache-2.0, BSD, ISC, Zlib, Unicode, CC0, BSL-1.0, CDLA-Permissive-2.0), advisories and duplicate versions.

15.3 CI (GitHub Actions)

On every PR: cargo fmt --check, cargo clippy -D warnings, tests on Linux and macOS, the WASM build, cargo deny, test vector check, and an end-to-end test (server + CLI + headless browser for the web app).

15.4 Releases

  • Tagged vX.Y.Z (SemVer). Server and CLI share a version.
  • Release artifacts: CLI and server binaries for x86_64/aarch64 Linux (musl, static), x86_64/aarch64 macOS, x86_64 Windows (CLI only); the web bundle .tar.gz; SHA256SUMS; signatures with GitHub artifact attestations (SLSA provenance).
  • An install script and a Homebrew tap for the CLI.
  • The protocol version (1) changes only for breaking protocol changes. A server supports the current and previous protocol version.

16. Conformance and testing

  • Test vectors in docs/test-vectors/ for: fingerprints, AAD encoding, identity envelopes, EK subkeys, name hashes and name encryption, EK wraps (with fixed HPKE ephemeral keys), secret records, log entries and chains (valid and each kind of invalid), DPoP proofs, JWT assertions, and env format escaping and merge cases. A compatible implementation passes all of them.
  • Property tests (proptest) for the dotenv parser and writer (round trip) and for log validation.
  • Adversarial server tests: a test harness that plays a malicious server (swaps keys, reorders or drops log entries, rolls back versions, swaps ciphertexts between names) and checks the CLI stops with exit code 6.
  • Fuzzing (cargo-fuzz) of every parser that reads untrusted input: dotenv, JSON bodies, log entries, DPoP proofs, WebAuthn payloads.
  • External review of secrets-core before 1.0.

17. Milestones

MilestoneContentDone when
M0 SpecThis document, reviewed.The maintainers approve it.
M1 Coresecrets-core with all formats, log validation, DPoP; test vectors.Test vectors pass on native and WASM.
M2 ServerStorage (SQLite and PostgreSQL), OAuth device grant, JWT bearer, DPoP, projects, log, secrets, audit. WebAuthn signup and login.API integration tests pass; both storage backends pass the conformance suite.
M3 CLIlogin, init, ls/get/set/rm/history, import, export (all formats, merge), run, device enroll/export, approve, share, rotate.End-to-end test: two users, one machine device, removal with rotation.
M4 Web appSignup, login, recovery, projects, sharing, approvals, rotation, account.Headless end-to-end test passes; CSP has no violations.
M5 AdminAdmin panel, bootstrap, invites, disable/reset, quotas, metrics.Manual test on a staging instance.
M6 ReleaseRelease pipeline, install script, Homebrew tap, self-hosting guide with a sample deployment.v0.1.0 tagged; a staging instance runs from release artifacts with backups and a tested restore.