secrets
Summary: what secrets is, what it is for, what it is not for, and where to start.
Key terms: end-to-end encryption, project, environment, machine device, project log, secrets-chad.
Related: Concepts · Map · Recipes
secrets is a self-hosted secrets manager for projects and the people and machines that run them. Clients (the
secrets-chad CLI and the web app) encrypt and decrypt every secret name and value; the server stores ciphertext,
checks signatures and enforces the rules. Access to a project is defined by a hash-chained log that project owners sign,
so the server cannot add a reader on its own. People sign in with passkeys, and servers, CI jobs and coding agents use
device keys with access to the environments an owner granted.
The picture as text
flowchart LR
P[Person: browser or CLI] -->|ciphertext, signatures| S
M[Machine: server, CI, agent] -->|ciphertext, signatures| S
S[Server:<br/>stores, checks] --> D[(SQLite or PostgreSQL:<br/>no plaintext)]
W[Web app: static files<br/>on a separate host] -.->|loaded by| P
What it is for
| You want | secrets gives |
|---|---|
| Programs that get environment variables at start | secrets-chad run -- CMD sets them for one process; no file on disk |
A .env or JSON file for a deploy | secrets-chad export --out FILE, with an atomic write and an optional merge into an existing file |
| CI jobs with access to one environment | A machine device with a read grant, stored as one GitHub secret |
| A small team that shares projects | Owners, writers and readers per project; sharing by handle with fingerprint checks |
| Coding agents that use secrets without seeing them | run masks values in the output; get and export to the terminal are refused for agents |
| A host you do not fully trust | The server, its backups and any proxy or CDN see only ciphertext and metadata |
| A small deployment | One Rust binary, SQLite or PostgreSQL, and a static web app |
What it is not for
| Not for | Reason |
|---|---|
| Credentials that the server creates or rotates (database users, cloud tokens) | The server would need admin rights at the other system and would see each credential |
| Large files or binary data | Values are UTF-8 text of at most 64 KiB |
| A personal password vault | There are no browser autofill, TOTP or item types |
| Hiding project names, environment names, members or sizes from the server | The server needs this metadata to enforce the rules; see what the server sees |
| Different roles for one person in each environment | A member has one role in the whole project. Machines get grants per environment |
| High availability or federation | One server process per database; an account belongs to one server |
A feature that needs the server to read a secret does not belong in secrets.
Where to start
| You are | Read |
|---|---|
| New to the project | Concepts: the model and the vocabulary |
| Using the CLI or setting up CI | Recipes, starting with start |
| Running a server | Operation and the self-host recipe |
| Changing secrets | Map, Data, Flows, Interfaces, then the spec |
| A coding agent that uses secrets | The agent skill, or secrets-chad agent |
| A coding agent that changes this repository | INDEX.md, then AGENTS.md |
| Reviewing the security | Spec §3, threat model and Flows |
Getting started
secrets-chad login --host secrets.example.com # approve this device in the browser
secrets-chad project create shop/dev
secrets-chad -e shop/dev init # writes .secrets.toml; it holds IDs only
printf %s "$VALUE" | secrets-chad set DATABASE_URL
secrets-chad run -- ./server
- Status: before a first release. The server, the CLI and the web app work and are tested. No external security review has happened yet.
- Accounts: passkeys, sessions, devices and recovery come from
auth-chad, mounted at
/v1/auth. - Exact rules: the spec is the contract. Where this wiki and the spec differ, the spec is correct.
- Decisions and their reasons: decisions.
- MIT license.
Concepts
Summary: the model behind secrets in seven ideas, what the server can and cannot see, and the vocabulary of the code and the spec.
Key terms: project, environment, member, machine device, project log, environment key, epoch, wrap, record, fingerprint, rotation.
Related: Data · Flows · Spec §2
A project holds environments (for example dev and prod), and each environment holds named secrets.
Each environment has a symmetric environment key, and clients encrypt every secret name and value with keys derived
from it. The environment key reaches each reader as a wrap: a copy encrypted to that reader’s public key. Who may
read is defined by the project log, a hash chain of entries that owners sign with their identity keys. Clients
verify the whole log before they trust a key, a member or a secret.
The picture as text
flowchart TB
L[Project log: signed by owners] -->|defines| R[Members, machine grants, environments, epochs]
R -->|one wrap per reader| K[Environment key, per epoch]
K -->|derives| V[Value key, name key, name lookup key]
V -->|encrypt| S[Secret records: signed by the writer]
The seven ideas
1. Clients encrypt, the server stores
All cryptography is in secrets-core, which the CLI, the web app and the server share. The server never holds a
private key of a user, device or environment, and it has no secret configuration. It stores ciphertext and public keys,
checks signatures and log rules, and refuses what the rules forbid.
2. Owners sign access
Adding a member, granting a machine and rotating a key are log entries signed by an owner. The server validates every entry, and so does every client. A server that inserts an entry of its own cannot produce a valid signature, so clients reject the log with an integrity error (exit code 6).
3. One key per environment and epoch
An environment key is 32 random bytes. A rotation creates the next epoch with a new key, re-encrypts the latest
version of every secret, and wraps the new key to every remaining reader. Each rotate entry carries a
key commitment, so a client can check that a wrapped key is the one the owner signed.
4. Removal forces rotation
Removing a member, revoking a machine grant or revoking a user device removes a reader. The same request must rotate
every environment that reader could open. When no owner is present (a member leaves, a user revokes a device), the
server marks the environments rotation_required and refuses writes to them until an owner rotates. A rotation does
not change the values themselves: a removed reader may have copied them.
5. Writers sign records
Each version of a secret is a record signed by its writer, with the hash of the previous version and the log head the writer verified. A reader checks the signature, the writer’s role at that log head, the chain and the version before it decrypts. The server cannot forge or swap a value.
6. People have identity keys, devices have device keys
A person’s identity key signs log entries and opens wraps. The server stores it only in encrypted envelopes, one per passkey (opened with the passkey’s PRF output), one for the recovery key, and one per approved user device. A device key stays on its device: a user device acts as its user, and a machine device has grants on specific environments only.
7. Clients remember what they verified
A client caches the highest log head and secret versions it has verified. If the server later returns a shorter log, a different history or an older version, the client stops. A client with no cached state cannot detect a server that hides the newest entries.
What the server sees
A copy of the database shows the same as the server.
| Readable by the server | Not readable by the server |
|---|---|
| User handles and display names | Secret names |
| Project and environment names | Secret values |
| Members and their roles; machine devices and their grants | Environment keys |
| Device names, public keys, IP addresses, times | Identity keys, device keys, recovery keys |
| Number of secrets, their sizes and versions | Passkey private keys and PRF output |
| The audit log |
Whoever controls the web app’s files can steal keys from people who use the web app during that time. For this reason the web app should be served from a host other than the API server; see Operation.
Where the details are
- The threat model, adversary by adversary: spec §3.
- The formats and the cryptography: spec §5 and
docs/test-vectors/. - The log entries and their validation: spec §6,
crates/core/src/log.rs. - Accounts, passkeys and sessions: auth-chad’s concepts.
Fingerprints in code
A fingerprint is the first 20 bytes of a SHA-256 hash of a public key pair, shown as 8 groups of 4 characters. People compare fingerprints to detect a server that substitutes a key.
use secrets_core::fingerprint::Fingerprint;
fn same_person(sig_pub: &[u8; 32], enc_pub: &[u8; 32], shown_elsewhere: &str) -> bool {
Fingerprint::of(sig_pub, enc_pub).matches_text(shown_elsewhere) // "7KQ2-M9XA-…", case and dashes ignored
}
Glossary
| Term | Meaning | In the code |
|---|---|---|
| Instance | One deployment of the server, with its own users | secrets-server |
| User | A person with an account; logs in with passkeys | Id<User>, usr_… |
| Instance admin | A flag on a user account that allows invites. It gives no project rights | Profile::admin |
| Project | A named container of environments, owned by one or more users | Id<Project>, prj_… |
| Environment | A named set of secrets in a project, with its own key | Id<Env>, env_… |
| Secret | A named UTF-8 value in an environment, with a version history | Id<Secret>, sec_… |
| Member | A user with a role in a project: owner, writer or reader | Member, Role |
| User device | A CLI login that acts as its user and holds the user’s identity key | DeviceOwner::User |
| Machine device | A device with grants on specific environments only, for servers, CI and agents | DeviceOwner::Machine |
| Grant | Permission for a machine device to read or read-write one environment | device_grant, Access |
| Project log | The hash-chained, owner-signed entries that define a project’s access | SignedEntry, ProjectState |
| Log head | The sequence number and hash of the newest verified entry | Head |
| Identity key | A user’s long-term Ed25519 and X25519 key pair | PublicKeys |
| Envelope | The identity private key, encrypted for one passkey, the recovery key or one user device | auth-chad’s Envelope (passkey, recovery key); Sealed<64> (user device) |
| Device key | A device’s Ed25519 and X25519 key pair. It also signs DPoP proofs | KeyPair |
| Device credential | A device key and its server in one string, sdc1_…, for SECRETS_DEVICE | DeviceCredential |
| Environment key | The 32-byte key of one environment and epoch | EnvKey |
| Epoch | The version number of an environment key | epoch |
| Wrap | An environment key encrypted to one member or machine with HPKE | Wrap, Sealed<32> |
| Key commitment | A hash of the environment key in the signed rotate entry | key_commitment |
| Record | One signed version of one secret: encrypted name and value, chain hash, log head | Record |
| Name lookup hash | An HMAC of the secret name, so the server can find a name it cannot read | name_hmac |
| Rotation | A new epoch for an environment, with every latest record re-encrypted | rotate entry |
| Rotation required | A mark on an environment after a removal without an owner; writes stop until rotation | rotation_required |
| Fingerprint | A short hash of a public key pair, for comparison by people | Fingerprint |
| Pin | A fingerprint that a client stored at first use and compares later | Pins |
| Recovery key | A 32-byte key the person stores, which opens the recovery envelope | auth-chad’s e2ee recovery |
| Workspace | A verified project with the environment keys the caller can open | Workspace |
Map
Summary: how the repository and the Rust crates are laid out, which crate may depend on which, and where to make a change.
Key terms: crate, ports and adapters, use case, port, adapter, composition root, auth-chad, xtask.
Related: Interfaces · Data · AGENTS.md
The repository is one Rust workspace. secrets-core holds all cryptography, encodings and log validation, and the
CLI, the web app and the server all use it. The server follows a ports-and-adapters layout: secrets-server-app holds
the use cases and the traits they need, the store and HTTP crates implement those traits, and secrets-server wires
them together. Accounts come from auth-chad, a separate repository pinned by commit in Cargo.toml.
The picture as text
flowchart TB
subgraph clients [Clients]
cli[secrets-cli: secrets-chad]
web[secrets-web: Leptos, wasm]
client[secrets-client]
end
subgraph server [Server]
bin[secrets-server: wiring]
http[secrets-server-http: routes]
sqlite[secrets-store-sqlite]
pg[secrets-store-postgres]
app[secrets-server-app: use cases, ports]
end
api[secrets-api: wire types]
core[secrets-core: crypto, formats, log]
cli --> client
web --> client
client --> api
client --> core
bin --> http
bin --> sqlite
bin --> pg
http --> app
http --> api
sqlite --> app
pg --> app
app --> core
The repository
| Folder | Contents |
|---|---|
docs/spec.md | The exact rules. Change it in the same pull request as the behavior |
docs/wiki/ | This wiki |
docs/recipes/ | One page per task |
docs/decisions/ | Decisions and their reasons |
docs/test-vectors/ | JSON vectors for every format; a compatible implementation passes them |
skills/secrets-chad/ | The guide for coding agents that use the CLI |
crates/ | The Rust crates |
action/, action.yml | The GitHub Action that installs secrets-chad |
xtask/ | cargo xtask ci, the web bundle build, release helpers |
scripts/wiki.py | Builds and checks this wiki |
The crates
| Crate | Part | Job |
|---|---|---|
secrets-core | shared | All cryptography, encodings, IDs, records, the project log and its validation. no_std with alloc, no I/O |
secrets-api | shared | The JSON request and response types of the HTTP API |
secrets-client | client | Everything a client checks and plans: discovery, login, pins, log verification, keys, records, changes. Generic over Http, Clock and Draws; runs on auth-chad’s client |
secrets-cli | client | The secrets-chad binary: commands, export and run, files, GitHub, agent mode |
secrets-web | client | The web app (Leptos, client-side rendered, wasm) |
secrets-server-app | server | Use cases (App), policy functions, and the ports they need (Store, Random, AuditBuffer). No I/O |
secrets-server-http | server | The axum routes, auth-chad’s account API at /v1/auth with this application’s hooks (Rules), errors, limits, the request log |
secrets-store-sqlite | server | Store on SQLite (rusqlite, bundled) |
secrets-store-postgres | server | Store on PostgreSQL (tokio-postgres) |
secrets-store-tests | test | The Store conformance suite (conformance!), the in-memory MemStore, shared fixtures |
secrets-server | server | The composition root: configuration, backend choice, real clock and randomness, listeners, shutdown |
secrets-test-vectors | test | Generates and checks docs/test-vectors/ |
xtask | tool | CI checks for changed crates, the web bundle, release packaging |
Dependency rules
- Dependencies point inward:
secrets-server→secrets-server-httpandsecrets-store-*→secrets-server-app→secrets-core. - Only
secrets-corecalls a cryptographic primitive. secrets-coreisno_stdwithallocand does no I/O. Use cases insecrets-server-appdo no I/O; every effect is a port.- Adapters hold no rules. Use cases know no HTTP and no SQL.
- Account rules live in auth-chad. This repository adds projects, records and the hooks that join the two. A change to accounts goes to auth-chad.
Where to make a change
| Change | Place |
|---|---|
| A format, a signature or a log rule | crates/core/src, the vectors in crates/test-vectors, and spec §5–6 |
| A rule the server enforces | crates/server-app/src/policy.rs or app.rs |
| A table or column | Both stores (crates/store-sqlite/src/schema.sql, crates/store-postgres/src) and the conformance suite |
| A route | crates/server-http/src/routes.rs, the types in crates/api, and spec §10 |
| Signup, device approval or revocation rules | The hooks in crates/server-http/src/auth.rs |
| A CLI command | crates/cli/src/args.rs and commands.rs, and spec §11 |
| What a client verifies | crates/client/src |
| A web page | crates/web/src/pages |
Code rules
- Pure functions by default. Every side effect is a trait, injected by the caller, used through generics.
- Borrow before owning:
&str,&[u8], fixed-size arrays. - No logging. No secret, key, token or ciphertext in an error message,
Debugoutput or panic. - Key material lives in
zeroize-on-drop types. - No
unsafe,unwrap,expectorpanic!outside tests. - Every cryptographic format has test vectors.
Tests
| Test | Covers |
|---|---|
| Test vectors | Every format in secrets-core |
Property tests (proptest) | Parsers, encoders, the dotenv round trip, log validation |
Conformance suite (secrets_store_tests::conformance!) | Every store |
| HTTP tests with real DPoP proofs, in memory | Every route |
| Client tests against the real router, in memory | secrets-client |
| CLI tests against a local server | secrets-chad |
Browser tests (node crates/web/e2e/run.mjs) | The web app with a virtual passkey; not in CI yet |
| Compiled wiki snippets | Doctests of secrets-server-app |
cargo xtask ci runs formatting, clippy, tests and doctests for changed crates and their dependents, as CI does.
Data
Summary: the tables the server keeps, the signed objects that clients exchange, and the local files of the CLI.
Key terms: log entry, record, wrap, envelope, public keys, project access, rotation required, profile, audit, Batch, Commit.
Related: Flows · Interfaces · Spec §14.2
The server stores three kinds of data. Signed objects (log entries and secret records) are stored as JSON text, exactly
as the client sent them, so every reader can verify the signatures. Encrypted keys (wraps and device envelopes) are
opaque bytes that only their recipient can open. Index tables (project access, latest versions, rotation marks) let the
server answer and enforce rules without reading any secret. Account tables come from auth-chad, with the prefix auth_,
in the same database.
The picture as text
erDiagram
projects ||--o{ log_entries : "seq 1..head"
projects ||--o{ wraps : "env, epoch, recipient"
projects ||--o{ records : "env, secret, version"
projects ||--o{ secrets : "latest version per secret"
projects ||--o{ project_access : "who can see it"
projects ||--o{ rotation_required : "envs waiting"
profiles ||--o{ device_envelopes : "user devices"
public_keys ||--o{ log_entries : "pinned by fingerprint"
The tables
Projects
| Table | One row is | Notes |
|---|---|---|
projects | A project | The ID and the current log head (head), which serializes appends |
log_entries | One signed log entry | Primary key (project, seq); the entry JSON with its signature |
public_keys | A public key pair | Keyed by fingerprint, so a client can verify entries of past members |
wraps | An environment key sealed to one member or machine | (project, env, epoch, kind, recipient); 80 bytes of HPKE output |
records | One signed version of one secret | (project, env, secret, version); the record JSON |
secrets | The latest version of a secret | With name_hmac, unique per environment, deleted secrets included |
project_access | A user or machine that can see a project | Derived from the log; answers 404 for everyone else |
rotation_required | An environment that waits for a rotation | Writes to it are refused until an owner rotates |
People and devices
| Table | One row is | Notes |
|---|---|---|
profiles | What this application knows about a user | Display name, identity fingerprint, admin flag |
device_envelopes | A user’s identity key sealed to one user device | 112 bytes; deleted when the device is revoked |
audit | An audit event | Time, actor, device, IP address, action, project, environment, secret, number. No names or values |
auth_* | Accounts, passkeys, sessions, tokens, devices, invites, events | auth-chad’s tables; see auth-chad’s data page |
The SQLite schema is in crates/store-sqlite/src/schema.sql. PostgreSQL has the same tables in the secrets schema.
Signed objects
A log entry changes access. Its signature covers the JCS form of the entry, and its hash links to the previous entry.
{
"project_id": "prj_…", "seq": 12, "prev_hash": "…",
"type": "member_add",
"body": { "user_id": "usr_…", "identity_fpr": "…", "role": "writer" },
"author": "usr_…", "created_at": "2026-11-23T20:14:00Z", "sig": "…"
}
| Entry type | Changes | Author |
|---|---|---|
genesis | Creates the project and binds its ID to the creator | Any user |
member_add, member_role, member_remove | Members and roles | Owner; a member may remove itself |
member_rekey | A member’s identity key | The member, signed with the old key |
env_create, env_rename, env_delete | Environments | Owner |
device_grant, device_ungrant | Machine access to one environment | Owner |
rotate | A new epoch, with the key commitment | Owner |
project_rename | The project name | Owner |
A record is one version of one secret. The name and the value are encrypted separately, so a client can list names without downloading values.
| Field | Readable by the server | Purpose |
|---|---|---|
project_id, env_id, secret_id, version, epoch | Yes | Where the record belongs and which key opens it |
name_hmac | Yes, as a hash | Finds a secret by name without revealing the name |
name_nonce, name_ciphertext | No | The encrypted name |
nonce, ciphertext | No | The encrypted value; empty for a delete |
log_seq | Yes | The log head the writer verified; fixes the writer’s role |
prev_record_hash | Yes | Chains the versions of one secret |
writer, created_at, sig | Yes | Who wrote it, when, and the signature |
Types in the server
| Type | Holds | Created by |
|---|---|---|
Principal | A user or a device, as the actor or recipient of something | The HTTP layer, from auth-chad’s proof |
Caller | auth-chad’s Authenticated proof and the client address | secrets-server-http, per request |
Actor | The principal, its device and its address, for the audit log | App, from a Caller |
Commit | One project’s change: entries, wraps, records, access changes, rotations, audit rows | A use case in App |
Batch | One transaction: project commits, auth-chad writes, a profile, device envelopes, rotation marks | A use case, or an auth-chad hook |
Wrap | An environment key sealed to one principal | Clients; checked by policy |
Profile | Display name, fingerprint, admin flag | Signup |
AuditEvent | One audit row | App |
ProjectStore::commit stores a whole Batch, or nothing. A signup, a device approval or a rotation is therefore one
transaction across auth-chad’s tables and this application’s tables.
Local state of the CLI
| File | Contents |
|---|---|
$XDG_CONFIG_HOME/secrets-chad/config.toml | Default host; per host, the issuer and the device ID |
…/state/<issuer-hash>/pins.json | Pinned fingerprints, verified log heads, highest seen versions |
…/devices/<device-id>.key | The device key, mode 0600 in a 0700 folder |
.secrets.toml in a project | Host, project ID, environment ID, required names. No secret; commit it |
The CLI keeps no copy of secret values or environment keys on disk.
Where the details are
- Records, names and values: spec §5.6 and
crates/core/src/record.rs. - Log entries: spec §6 and
crates/core/src/log.rs. - Storage requirements and both backends: spec §14.2.
- The audit log: spec §10.3.
Flows
Summary: what each flow sends, who can read each item, and what the server checks: requests, signup, login, devices, machines in CI, projects, sharing, secrets, removal, revocation and recovery.
Key terms: DPoP, envelope, device grant, user code, wrap, record, rotation, rotation required, recovery hold, integrity error.
Related: Data · Concepts · Spec §7 · Spec §9
Every request carries an access token and a DPoP proof made with the client’s private key, and auth-chad checks both
before a route runs. Account flows (signup, login, device approval, recovery) are auth-chad’s routes at /v1/auth,
with this application’s rules in its hooks. Project flows send signed log entries, wraps and records that the client
built; the server validates them and stores them in one transaction. Clients verify everything they read before they
use it, and stop with an integrity error if a check fails.
Each flow below lists what travels. Readable items the server can read. Sealed items pass through the server, which cannot open them. Local items never leave the client.
Every request
The picture as text
sequenceDiagram
participant C as Client
participant A as auth-chad layer
participant R as Route
participant DB as Database
C->>A: access token + DPoP proof (method, URL, time, server nonce, token hash)
A->>DB: token hash, device not revoked, user not disabled, proof not reused
alt valid
A->>R: Caller (user or device, address)
R->>DB: role in the project (from the verified log)
R-->>C: answer, with a fresh DPoP-Nonce
else invalid
A-->>C: 401 with {"error": code}
end
- The access token is 32 random bytes, valid 15 minutes; the server stores its hash. It is useless without the private key that signs the proofs.
- There are no refresh tokens. A device signs a JWT assertion with its device key to get a new token (RFC 7523).
- A project the caller cannot see answers
404, so its existence does not leak.
Signup
An instance admin creates an invite; the server keeps only its hash and shows the link once. The new user creates every key in their own browser.
The picture as text
sequenceDiagram
participant B as Browser
participant S as Server
B->>S: signup/start (invite token, handle, display name)
S-->>B: challenge (5 minutes)
Note over B,S: browser creates passkey, identity key, recovery key
B->>S: signup/finish: public keys, recovery verifier, two envelopes
S->>S: commit_signup: one transaction
S-->>B: session
| Item | Readable | Sealed | Local |
|---|---|---|---|
| Invite token | As a hash | ||
| Handle, display name, public keys | Yes | ||
| Identity private key | In two envelopes | In the browser | |
| PRF output of the passkey, recovery key | Yes |
Login in the browser
One passkey prompt signs the challenge and returns the PRF output that opens the identity key.
The picture as text
sequenceDiagram
participant B as Browser
participant S as Server
S-->>B: challenge
Note over B,S: passkey signs, gives PRF output
B->>S: assertion + proof of the session key
S-->>B: access token bound to the session key, identity key sealed by this passkey
Note over B,S: browser opens the identity key
The browser keeps the identity key, the session key and the token in IndexedDB, encrypted with a non-extractable WebCrypto key, until logout: at most 1 hour idle and 12 hours in total.
Device login (user device)
secrets-chad login. The laptop can then do what its user can.
The picture as text
sequenceDiagram
participant D as CLI
participant S as Server
participant B as Person's browser
Note over D,S: CLI creates device keys (file, 0600)
D->>S: device_authorization (name, public keys, client info, DPoP proof)
S-->>D: user code, device code
D->>B: link + user code + device fingerprint
B->>S: approve after a fresh passkey prompt, with the identity key sealed to the device
D->>S: token (device code, DPoP proof)
S-->>D: access token, sealed identity key
Note over D,B: person types the identity fingerprint
- The approval page shows the device name, fingerprint, requested scope, IP address and client. The person compares the fingerprint with the terminal.
- The sealed identity key is not authenticated, so the CLI makes the person type the identity fingerprint from the browser before it stores anything. No flag skips this.
Machine device
secrets-chad machine create NAME. The machine can open the chosen environments and nothing else.
- The CLI creates device keys and requests approval, with environments (
env:<project>/<env>:read) or without (machine). - An owner opens the link, chooses the project, environments and access if the request names none, and approves after a fresh passkey prompt.
- The owner’s browser signs one
device_grantentry per environment and wraps each current environment key to the machine. The server stores the entries, the wraps, the device and the approval in one transaction. - The machine collects its token and wraps. It receives no identity key.
A machine in a GitHub Actions job
The picture as text
sequenceDiagram
participant L as Your laptop
participant G as GitHub
participant R as Runner
participant S as Server
L->>S: machine create deploy -e shop/prod --github
Note over L,S: you approve in the browser
L->>G: gh secret set SECRETS_DEVICE (credential on stdin, no file)
G->>R: SECRETS_DEVICE for the deploy step
R->>S: JWT assertion signed with the device key
S-->>R: token, shop/prod key sealed to the machine, encrypted records
Note over R,S: runner decrypts, starts deploy.sh
An owner ends it with secrets-chad machine revoke deploy or on the Machines page. The environment rotates, and the
next job fails.
Create a project
The creator’s client generates the genesis, env_create and rotate entries and environment key epoch 1, and wraps
the key to the creator. The project ID is a hash of the creator’s user ID, identity fingerprint and a random nonce, so
the server cannot invent a log for an ID that a client got from a trusted source.
Share a project
The picture as text
sequenceDiagram
participant A as Owner A
participant S as Server
participant B as User B
A->>S: GET /v1/users/{handle}
S-->>A: B's public keys and fingerprint
Note over A,B: A and B compare the fingerprint by another channel
A->>S: signed member_add (B, fingerprint, role) + every current key wrapped to B
B->>S: on the next visit: log, wraps, records
Note over S,B: B verifies the log and every record
The first fingerprint comparison is the only protection against a server that substitutes B’s key. Clients pin the fingerprint and warn when it changes. B can read versions from the current epoch on; history from before B joined stays unreadable to B.
Write and read a secret
- The writer’s client derives the subkeys of the current epoch, encrypts the name and the value, and signs the record with the log head it verified.
- The server checks the signature, the writer’s role, the version (latest + 1) and the name lookup hash, and writes an audit row.
- A reader’s client checks the signature, the writer’s role at
log_seq, the chain hash and the version, then decrypts and compares the name lookup hash.
use secrets_core::keys::PublicKeys;
use secrets_core::log::{replay, Head, SignedEntry};
fn verified_head(entries: &[SignedEntry], keys: &[PublicKeys], cached: Option<&Head>) -> Result<Head, secrets_core::Error> {
let state = replay(entries, keys)?; // every signature, role and rule from genesis
if let Some(head) = cached {
state.check_checkpoint(head)?; // the log still contains what this client saw before
}
Ok(state.head())
}
Remove a member
Owner A removes B. Everything is one request.
The picture as text
flowchart LR
A["A's client: new key per environment,<br/>re-encrypt every latest record"] --> M["A chooses machines to end<br/>(those B approved are preselected)"]
M --> E["Signed member_remove with rotations<br/>+ rotate entries + new wraps + records"]
E --> S[["Server: one transaction"]]
S --> G["B sees 404 for the project"]
The client lists the secrets B could read, so A can change them at their source (for example, roll an API key at the provider). Encryption cannot take back what B already read.
| After the removal | Result |
|---|---|
| B’s browser and CLI | The project answers 404. B’s identity key opens no new wrap |
| B’s other projects | No change |
| Secrets B wrote | Stay valid |
| Machines B approved as an owner | Preselected, so they end in the same request; A can keep some |
| Machines A approved that B operates | Keep working unless A ends them in the removal |
| Values B copied | B still has them; change them at the source |
| Old environment keys B kept | Open only old ciphertext, which B would also need to obtain |
| B leaves without an owner | Writes stop until an owner rotates; machines keep working, and the Machines page marks those B approved |
Revoke a device
| Case | What happens |
|---|---|
| A user revokes a user device | The server ends its tokens, deletes its identity envelope, and marks every environment of the user’s projects rotation_required. Reads continue; writes wait for an owner’s rotation |
| An owner revokes a machine | One request removes the grant and rotates that environment |
| A laptop is stolen | It held the identity key, so the user also replaces the identity key with a passkey. This re-keys every project log and ends all other passkeys, sessions and user devices |
Recover an account
When all passkeys are lost and the recovery key is not:
- The browser asks by handle. The server returns a challenge and the recovery envelope; for an unknown handle it returns a decoy of the same shape.
- The browser opens the envelope with the recovery key, signs the challenge with the recovery key’s signer, and registers a new passkey with its own envelope.
- The account is on hold for 72 hours: an older passkey can undo the recovery, and the identity key cannot be replaced.
Recovery by email or by an owner is refused, because it cannot restore the identity key.
Known gaps
None of these lets the server read a secret.
- The removal dialog in the web app asks “Remove and rotate?” and does not yet list the values to change at their source, which the spec requires.
- The invite token is in the query string (
?invite=), so the web host can see it in a request log. - An instance admin cannot yet disable a user or start a reset; both are in the spec.
Where the details are
- Authentication, DPoP and device approval: spec §7.
- Sharing, removal, rotation and account reset: spec §9.
- Every route and code: spec §10.
- auth-chad’s account flows: auth-chad’s flows page.
Interfaces
Summary: the traits where the parts of secrets meet: the server’s ports, the hooks into auth-chad, the client’s transport, and the CLI’s adapters.
Key terms: port, Ports, Store, ProjectStore, Random, AuditBuffer, Rules, Hooks, Http, KeyDirectory, Gh, Opener.
Related: Map · Data · AGENTS.md
Every side effect in secrets is a trait that the caller injects, used through generic parameters. On the server, the
use cases in App<P: Ports> name four ports: a store, a clock, a random source and an audit buffer. The stores and the
test fakes implement them. auth-chad’s account API calls back into this application through its Hooks trait, which
Rules implements. Clients reach the server through auth-chad’s Http trait, so the same client code runs in the CLI
and in the browser.
The picture as text
flowchart LR
subgraph http [secrets-server-http]
R[routes]
H[Rules: auth-chad Hooks]
end
subgraph app [secrets-server-app]
A["App, generic over Ports"]
end
S[(Store: SQLite, PostgreSQL, MemStore)]
C[Clock + Random]
B[AuditBuffer]
R --> A
H --> A
A --> S
A --> C
A --> B
Server ports
| Trait | Methods | Implemented by |
|---|---|---|
Ports | Names the four types: Store, Clock, Random, Audit | secrets-server’s wiring; MemPorts in tests |
Store | Health + KeyStore + ProjectStore + ProfileStore + AuditStore + auth-chad’s Reader | Blanket: any type with all six |
Health | ping | Both stores, MemStore |
KeyStore | keys by fingerprint, put_keys | Both stores, MemStore |
ProjectStore | Log entries, wraps, records, commit(Batch), projects_for, rotation_required | Both stores, MemStore |
ProfileStore | profile, device_envelope, prune_expired | Both stores, MemStore |
AuditStore | append_audit, audit (one page), prune_audit | Both stores, MemStore |
Random | fill(buf) | The OS random source; SeqRandom in tests |
AuditBuffer | push, take, restore: read events wait in memory and are stored once per second | MemoryAuditBuffer |
A new storage backend implements these traits and runs secrets_store_tests::conformance! in its tests.
use secrets_core::id::{Id, Project};
use secrets_server_app::{ProjectStore, StoreError};
async fn log_length<S: ProjectStore>(store: &S, project: &Id<Project>) -> Result<usize, StoreError> {
Ok(store.log_entries(project).await?.len())
}
A test assembles the ports from fakes:
use std::sync::atomic::{AtomicU8, Ordering};
use secrets_core::ports::FixedClock;
use secrets_server_app::{MemoryAuditBuffer, Ports, Random};
use secrets_store_tests::MemStore;
struct Counting(AtomicU8);
impl Random for Counting {
fn fill(&self, buf: &mut [u8]) {
buf.fill(self.0.fetch_add(1, Ordering::Relaxed)); // tests only
}
}
struct TestPorts;
impl Ports for TestPorts {
type Store = MemStore;
type Clock = FixedClock;
type Random = Counting;
type Audit = MemoryAuditBuffer;
}
secrets_store_tests::fixtures::mem_app() builds a whole App this way.
Hooks into auth-chad
Rules<P> in crates/server-http/src/auth.rs implements auth-chad’s Hooks. auth-chad decides the account step;
Rules adds this application’s checks and rows to the same transaction.
| Hook | What secrets does there |
|---|---|
commit_signup | Reads the identity public keys from the signup’s app field and stores the profile with auth-chad’s writes |
valid_names | Handle ^[a-z0-9_-]{3,32}$ and a display name |
invite_data, may_invite | Only users with the admin flag invite; an invite from the API never makes an admin |
may_request_device, device_kind | Checks the scope grammar and the device keys; the scope decides user or machine |
may_approve | A machine request for a project is visible only to its owners |
commit_approve | A user device: the sealed identity key. A machine: the signed device_grant entries and wraps. One transaction |
commit_revoke, commit_undo | Deletes envelopes and marks the user’s environments rotation_required |
The full contract of each hook is on auth-chad’s interfaces page.
Other server traits
| Trait | Purpose |
|---|---|
Fail | Turns an application failure into the {"error": code} answer of a route |
LogSink | Receives the optional request log, one line per request; NoLog discards it |
Shared traits in secrets-core
| Trait | Purpose |
|---|---|
Clock | The current time, injected so tests are exact; FixedClock for tests |
KeyDirectory | Public keys by fingerprint, so log validation can verify entries of past members; implemented for [PublicKeys] |
IdKind | The type prefix of an ID (usr_, prj_, env_, dev_, sec_, inv_) |
Client traits
secrets-client re-exports auth-chad’s client traits, so one transport serves the account API and this application’s
routes.
| Trait | You give | In the browser |
|---|---|---|
Http | send(request) -> response | auth-chad’s browser::Fetch |
Clock, Draws | Time and random bytes | The system |
The CLI’s adapters.rs implements them with ureq and the OS. Tests run the real router in memory through the same
traits.
CLI adapters
| Trait | Purpose | Real implementation |
|---|---|---|
Gh | Runs the GitHub CLI with input on stdin, for machine create --github | SystemGh |
Opener | Opens an address in the person’s browser | SystemBrowser |
Where the details are
- The ports and the
Batchtype:crates/server-app/src/ports.rs. - The hooks:
crates/server-http/src/auth.rs. - The client API:
crates/client/src/lib.rs, and auth-chad’s client recipe.
Operation
Summary: how to deploy and run a secrets server: the three origins, configuration, storage and backups, limits, logging, hardening, and the capacity of one process.
Key terms: web origin, API origin, admin origin, discovery, server.toml, SQLite, PostgreSQL, backup, request log, one process per database.
Related: Self-host recipe · Data · Spec §14
A secrets deployment is one secrets-server process, one database (SQLite or PostgreSQL), and a static web app. The
server holds no secret key material, so a deployment needs no key management service; the database holds only
ciphertext and metadata. The web app should come from a host other than the API server, because whoever controls the
web app’s files can steal keys from the people who use it. One process serves one database: secrets scales up on one
machine and does not run several server processes against one database.
The picture as text
flowchart LR
B[Browser] -->|static files| W[Web origin<br/>static host or CDN]
B -->|HTTPS, DPoP| P[Proxy or tunnel]
C[CLI, CI, agents] -->|HTTPS, DPoP| P
P --> S[secrets-server<br/>127.0.0.1:8470]
S --> D[(SQLite file<br/>or PostgreSQL)]
D --> K[Backups]
O[Operator on a private network] --> A[Admin listener<br/>127.0.0.1:8471]
A --- S
Why one process
| Part | Reason it stays in one process |
|---|---|
| Log appends | SQLite serializes them through one writer connection |
| Write rate limit | writes_per_minute is a token bucket in memory |
| Audit of reads | Read events wait in a memory buffer and are stored once per second |
| Capacity | A small VM (1 vCPU, 1 GB RAM) serves hundreds of users; a bulk read answers in milliseconds |
PostgreSQL can be made highly available on its own, but the server does not coordinate several processes. auth-chad’s account limits are already counted in the database.
Origins and discovery
| Origin | Serves | Example |
|---|---|---|
| Web origin | The static web app, config.json and the discovery document | https://secrets.example.com |
| API origin | The public listener | https://secrets-api.example.com |
| Admin origin | The admin listener, on a private network only | https://secrets-admin.internal.example.com |
A client given a host fetches https://HOST/.well-known/secrets-server. Both the web origin and the API origin serve the
same document. Prefer a single-level API name such as secrets-api.example.com: many CDN certificates cover one
subdomain level only.
Configuration
/etc/secrets/server.toml; every key can be overridden with SECRETS_SERVER_<KEY>.
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"
issuer = "https://secrets-api.example.com"
web_origins = ["https://secrets.example.com"]
auth_path = "/v1/auth"
client_ip_header = "X-Real-IP" # one address set by the proxy; omit to use the socket address
[rate_limits]
auth_per_minute = 20
writes_per_minute = 600
[audit]
days = 365
ip_days = 30 # 0 stores no IP addresses
The server refuses to start when admin_listen binds a public address, unless allow_public_admin = true.
Storage and backups
| Backend | URL | Backups |
|---|---|---|
| SQLite (default) | sqlite:///path/to/secrets.db | Any tool that copies a WAL database consistently, for example Litestream. The server runs no checkpoint or VACUUM of its own |
| PostgreSQL 15 or later | postgres://… (no password in the URL) | The operator’s: pg_dump or WAL archiving |
- Migrations are embedded and run at startup in a transaction.
- auth-chad’s account tables are in the same database, so a signup or a device approval is one transaction.
- A backup holds no plaintext secret and no usable credential. It shows the metadata listed in what the server sees.
- For PostgreSQL, prefer authentication without a password (a Unix socket with
peer). Otherwise put the password in the file named bydatabase_password_file.
Limits
| Limit | Default |
|---|---|
| Account calls without a login, per address and minute | 20 (auth_per_minute), counted in the database |
| Writes through project routes, per address and minute | 600 (writes_per_minute) |
| Request time, idle keep-alive | 10 s, 60 s |
| Request body | 128 KiB; 1 MiB for bulk writes; 8 MiB for identity key replacement |
| Projects per user, environments per project, secrets per environment | 25, 20, 1,000 |
| Value size | 64 KiB |
Logging and metrics
- The server writes nothing about request content to its logs.
- The optional request log (
[request_log], off by default) writes one line per request with fields from a fixed set: time, method, route template, status, duration, actor, client address, request ID, body sizes. - Tokens, proofs, envelopes, wraps, ciphertexts, IDs in paths and query strings are never logged.
GET /metricson the admin listener gives Prometheus text.
Process hardening
Run the server under systemd as its own user with a strict sandbox: NoNewPrivileges=yes, ProtectSystem=strict,
ReadWritePaths=/var/lib/secrets, PrivateTmp=yes, PrivateDevices=yes, IPAddressAllow=localhost,
IPAddressDeny=any, MemoryDenyWriteExecute=yes, SystemCallFilter=@system-service, LimitCORE=0,
MemoryMax=256M. The full list is in spec §14.6.
Releases
- Server and CLI share a version and are tagged
vX.Y.Z. - A release has the binaries for each platform and the web bundle as
.tar.gzwith its SHA-256 (spec §15.4). cargo xtask web --issuer URL --web URL [--auth-path PATH]writes a web bundle with itsconfig.json.
Where the details are
- Configuration, storage, limits and logging: spec §14.
- Hostnames and the recommended deployment: spec §4.2–4.3.
- The web app’s headers and CSP: spec §12.2.
Recipes
Summary: one short page per task, from a first login to CI, machines, coding agents and your own server.
Key terms: recipe, login, project, machine device, SECRETS_DEVICE, GitHub Action, agent, self-host.
Related: Flows · Operation · agent skill
Each recipe shows the commands for one task. Find the task in the table, copy the commands, and adapt the names. The flows explain what each command sends, and the spec has the exact rules.
The recipes
| You need | Recipe |
|---|---|
A first login, a project, secrets and run | start |
| A team: share, remove, rotate, audit | sharing |
| A server or another program that reads one environment | machines |
| A GitHub Actions workflow with secrets | github-actions |
| A coding agent that uses secrets without seeing them | agents |
| Your own server | self-host |
Common commands
| Task | Command |
|---|---|
| Check the setup | secrets-chad doctor |
| See who is logged in | secrets-chad whoami |
| List names and versions | secrets-chad ls (--json for scripts) |
| Run with secrets | secrets-chad run -- CMD |
| Write a file | secrets-chad export --format env|json|docker --out FILE [--merge] |
| Own account activity | secrets-chad activity |
| Own devices | secrets-chad device ls, device revoke ID |
| Read the docs offline | secrets-chad docs, secrets-chad docs <page>, secrets-chad docs --open |
Exit codes
| Code | Meaning |
|---|---|
| 1 | Other error, or check found missing names |
| 2 | Wrong arguments, or a person must act |
| 3 | Not logged in, or the device was revoked |
| 4 | Not allowed |
| 5 | Not found |
| 6 | Integrity error: a signature or a check failed, and the server may be lying. Stop |
| 7 | Network or server error |
| 8 | An owner must rotate keys first |
| 9 | Refused for a coding agent, because it would show a secret |
Start
Summary: log in, create a project, add secrets and run a program with them.
You need a server and an account on it; an instance admin sends you an invite link. Install secrets-chad from the
releases, or with the GitHub Action in CI.
secrets-chad login --host secrets.example.com # approve this device in the browser, then type the fingerprint
secrets-chad whoami
secrets-chad project create shop/dev # a project with its first environment
secrets-chad -p shop env create prod # more environments
secrets-chad -e shop/dev init # writes .secrets.toml with IDs; commit it
Add the names your program needs to .secrets.toml, so check can find missing ones:
required = ["DATABASE_URL", "SESSION_KEY"]
Fill and use them:
secrets-chad generate SESSION_KEY # a random value, never shown
printf %s "$VALUE" | secrets-chad set DATABASE_URL
secrets-chad import .env # every key of a file, in one request
secrets-chad check # exit 1 if a required name is missing
secrets-chad ls
secrets-chad run -- ./server # values in this one process's environment
secrets-chad export --format env --out .env --merge
set NAME=VALUE is refused: a value in a command line ends up in shell history and in ps.
Spec: §11 CLI.
Sharing and rotation
Summary: add a person to a project, remove them, and rotate keys.
secrets-chad -p shop share @alex --role writer # compare the fingerprint with alex by another channel
secrets-chad -p shop unshare @alex # removes alex and rotates every environment
secrets-chad -e shop/prod rotate # a new key for one environment
secrets-chad -p shop rotate --all # every environment, and every pending rotation
secrets-chad -p shop verify # check the whole log and every latest record
secrets-chad -p shop audit --limit 50 # owners: who read and wrote what
- Roles:
owner(everything),writer(read and write secrets),reader(read secrets). shareshows the new member’s fingerprint. The first comparison is the only protection against a server that substitutes a key; later the client warns when a pinned fingerprint changes.unshareshows the project’s machines with the owner who approved each, and asks which to revoke too. Without a terminal it refuses when the member approved machines, unless--revokeor--keep-machinesis given.- After a removal, change the values the person could read at their source. A rotation stops future reads only.
- Exit code 8 means an owner must rotate first: a member left or a device was revoked.
Wiki: Remove a member. Spec: §9.
Machines
Summary: give a server or another program read access to one environment, and end it.
A machine device has its own key and grants on specific environments. A person approves it once in the browser; it never receives anyone’s identity key.
secrets-chad machine create web1 -e shop/prod --out web1.key # read access to shop/prod
secrets-chad machine create worker -e shop/prod --access read-write --out worker.key
secrets-chad machine create box1 --out box1.key # the approver chooses the environments
Copy the key file to the machine (mode 0600), and point SECRETS_DEVICE at its content, or keep it as the device file.
Then, on the machine:
secrets-chad -e shop/prod run -- ./server
secrets-chad -e shop/prod export --format env --out /opt/apps/shop/.env --merge
End it:
secrets-chad -p shop machine ls
secrets-chad -e shop/prod machine revoke web1 # removes the grant and rotates shop/prod
- With IDs (from
.secrets.toml),machine createneeds no login on the computer that runs it. - A machine keeps its grants when the person who approved it leaves; see sharing.
Wiki: Machine device. Spec: §7.4.
GitHub Actions
Summary: let a workflow read one environment, with one repository secret.
On your computer, with the GitHub CLI gh logged in:
secrets-chad machine create deploy -e shop/prod --github # this repository
secrets-chad machine create deploy -e shop/prod --github=org/repo --github-env production
It checks that gh can store secrets there, asks, waits for your approval in the browser, and gives the credential to
gh secret set SECRETS_DEVICE on stdin. The credential is in no file, argument or output. It prints the workflow lines:
steps:
- uses: audiochad/secrets@v0.1.0-alpha.2
- run: secrets-chad -e shop/prod run -- ./deploy.sh
env:
SECRETS_DEVICE: ${{ secrets.SECRETS_DEVICE }}
- The Action installs
secrets-chadfrom the releases ofaudiochad/secrets. Itsversioninput picks another release. - Set
SECRETS_DEVICEfor the steps that need it only. - End access with
secrets-chad -e shop/prod machine revoke deploy; the next job fails.
Wiki: A machine in a GitHub Actions job.
Coding agents
Summary: let a coding agent set up and use secrets without a value in its context.
secrets-chad agent prints the guide for agents; the same text is in
skills/secrets-chad/SKILL.md. Install it as a skill, or point the agent at the
command.
When the CLI detects an agent (SECRETS_AGENT=1, or variables that known agents set):
| Command | Behavior |
|---|---|
get, export to the terminal, machine create without --out or --github | Refused with exit code 9 |
run | Replaces each value in the command’s output with [NAME], including its lines, JSON and base64 forms |
share | Refused: a person compares the fingerprint |
The agent can still fill secrets without seeing them:
secrets-chad generate SESSION_KEY
secrets-chad request DATABASE_URL STRIPE_KEY # prints a link; a person enters the values in the browser
secrets-chad run -- npm test
The masking prevents accidents; an agent that wants to can transform a value to get around it. The real boundary is access: give the agent’s machine a device with read access to one environment (machines).
Spec: §11.11.
Self-host
Summary: run your own server: build it, configure it, publish it, and create the first account.
-
Build the server and the web bundle (Rust version in
rust-toolchain.toml; the web bundle needswasm-bindgen-cliwith the version inCargo.lock):cargo build --release -p secrets-server cargo xtask web --issuer https://secrets-api.example.com --web https://secrets.example.com # writes target/web -
Install
target/release/secrets-serverand write/etc/secrets/server.toml(see Operation for the keys). Run it under systemd as its own user with the hardening of spec §14.6. It listens on127.0.0.1:8470. -
Publish the public listener at the API origin through a reverse proxy or an outbound tunnel. Set
client_ip_headerto the header your proxy sets. -
Serve
target/webfrom the web origin on a static host, with the headers of its_headersfile. Both origins must serve/.well-known/secrets-server. -
Create the first account:
sudo -u secrets secrets-server --config /etc/secrets/server.toml admin invite --adminOpen the printed link, register a passkey, and store the recovery key.
-
Back up the database: Litestream or another WAL-aware tool for SQLite,
pg_dumpor WAL archiving for PostgreSQL.
Check it from a client: secrets-chad login --host secrets.example.com, then secrets-chad doctor.
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
secretsand the CLI issecrets-chad. The protocol usessecretsin 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
- Goals and non-goals
- Concepts and terms
- Threat model
- Architecture
- Cryptography
- The project log
- Identity and authentication
- Authorization
- Key lifecycle: sharing, approval, removal, rotation
- HTTP API
- CLI
- Web app
- Instance admin
- Server operation
- Repository, build and release
- Conformance and testing
- 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
- 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.
- 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.
- Multi-user. People have accounts, own projects, share projects with other people, and approve devices for them.
- 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.
- 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).
- Easy to use in deploys. One CLI call runs a command with secrets in its environment, or writes them to a
.envor JSON file, or merges them into an existing file. - 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.
- 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.
- 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
| Term | Meaning |
|---|---|
| Instance | One deployment of the server, with its own users. |
| User | A person with an account on an instance. Logs in with passkeys. |
| Instance admin | A flag on a user account that allows invites and instance management through the admin panel. Not a project role. |
| Project | A named container of environments, owned by one or more users. |
| Environment | A named set of secrets inside a project, for example dev or prod. Each environment has its own key. |
| Secret | A named value (UTF-8 text) in an environment, with a version history. |
| Member | A user with a role on a project: owner, writer or reader. |
| Device | A client keypair registered with the server. A user device acts as its user. A machine device has grants on specific environments only. |
| Browser session | A short-lived, DPoP-bound session created by a passkey login in the web app. |
| Grant | Permission for a machine device to read or read-write one environment. |
| Identity key | A user’s long-term key pair (signing + encryption). |
| Environment key (EK) | The symmetric key that encrypts an environment’s secrets. Versioned by epoch. |
| Project log | A hash-chained list of owner-signed entries that defines a project’s members, devices, grants, environments and key epochs. See §6. |
| Fingerprint | A short, human-comparable hash of a public key set. |
3. Threat model
Assets
- Secret values (plaintext).
- Environment keys, identity private keys, device private keys.
- The integrity of who has access (membership, devices, grants).
- Secret value integrity (a client gets the value a legitimate writer wrote).
Adversaries and what the design guarantees
| Adversary | Can | Cannot (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 device | Keep 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 instance | See user display names and identity fingerprints of users they share projects with. | See anything in projects they are not members of. |
| Instance admin | Disable 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 andwasm32-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 (databaseURL); 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:
| Origin | Serves | Example |
|---|---|---|
| Web origin | The static web app, and the discovery document | https://secrets.example.com |
| API origin | The public listener | https://secrets-api.example.com |
| Admin origin | The admin listener, on a private network | https://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.1and::1with an explicithttp://host (development). - A client MUST reject a document that does not list a protocol version it supports.
- A client stores the
issuerwith its login. Every token and every key is scoped to an issuer. auth_pathis where the account API is, below the issuer; a document without it means/v1/auth.
4.3 Recommended deployment
secrets-serverruns under systemd as its own user on a small VM. The public listener binds127.0.0.1; a reverse proxy or an outbound tunnel publishes it at the API origin.- The admin listener binds
127.0.0.1on 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.jsonand 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:
- Root on the API host cannot change the code that runs in users’ browsers.
- 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
| Purpose | Primitive | Rust crate (planned) |
|---|---|---|
| Signatures | Ed25519 (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, ChaCha20Poly1305 | hpke |
| Symmetric encryption | XChaCha20-Poly1305, 24-byte random nonce | chacha20poly1305 |
| Key derivation | HKDF-SHA256 (RFC 5869) | hkdf, sha2 |
| Keyed hash (name lookup) | HMAC-SHA256 (RFC 2104) | hmac, sha2 |
| Hash | SHA-256 | sha2 |
| Constant-time comparison | — | subtle |
| Randomness | OS CSPRNG (getrandom; WebCrypto getRandomValues in WASM) | getrandom, rand_core |
| Memory hygiene | Zero secrets on drop | zeroize, 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 thesigfield. - 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
| Key | Material | Where the private part lives |
|---|---|---|
| Identity key (per user) | Ed25519 signing key + X25519 encryption key | Wrapped 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 key | On the device only: a 0600 file, a CI secret, or the OS keyring (planned). Never sent anywhere. |
| Browser DPoP key (per browser session) | Ed25519 | WASM 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 bytes | Shown 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:
- Passkey PRF.
unlock_secretis the output of the WebAuthnprfextension (hmac-secreton CTAP2 authenticators), evaluated with the fixed inputsecrets/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.
- The web app MUST NOT send PRF output to the server. (It appears in
- Recovery key.
unlock_secretis the 32-byte recovery key. One envelope. The recovery key also gives the key that proves a recovery (auth-chad’srecovery_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, readsOas0andI/Las1, 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). - 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 asenc (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
rotateentry therefore carrieskey_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_ciphertextandciphertextare the AEAD output with the 16-byte tag appended.name_hmac, the nonces, ciphertexts,prev_record_hashandsigare base64url.created_atis RFC 3339 UTC with whole seconds (2026-11-23T20:14:00Z).versionandlog_seqare integers below 2^53.- The record hash is
SHA-256(JCS(record)), over the whole record includingsig. - A delete is a record with
deleted: true, emptynonceandciphertext, 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:
- The signature is valid for the writer’s key.
- The writer had write access to the environment at the time of the record, according to the verified project log
(an
ownerorwritermember, or a machine device with aread-writegrant). The record’slog_seqfield (the log head the writer saw) fixes “at the time”. In the state after entrylog_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 itsrotateentry).
prev_record_hashmatches the previous version the client has, if it has one.- The version is not lower than a version the client cached before (rollback detection).
- Decryption of the name and the value with the AADs above succeeds.
name_hmacequalsHMAC-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
mlockon 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:
| Type | Body | Who may author |
|---|---|---|
genesis | project_name, creator user_id, creator identity_fpr, nonce (32 random bytes) | Any user (creates the project) |
member_add | user_id, identity_fpr, role | Owner |
member_role | user_id, role | Owner (an owner may not demote the last owner) |
member_remove | user_id, devices (absent if empty), rotations (see below) | Owner (another member); or the member itself (leave). Never the last owner. |
member_rekey | user_id, identity_fpr, rotations | The member itself, signed with the old identity key (§9.6) |
env_create | env_id, env_name | Owner |
env_rename | env_id, env_name | Owner |
env_delete | env_id | Owner |
device_grant | device_id, device_fpr, env_id, access (read / read-write) | Owner |
device_ungrant | device_id, env_id, rotations | Owner |
rotate | env_id, epoch, reason (create / manual / removal), key_commitment | Owner |
project_rename | project_name | Owner |
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:
rotationsis empty. The leaving member cannot rotate for the others, so every environment becomesrotation_requireduntil an owner appends amanualrotation 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:
seqstarts at 1 and increases by 1.prev_hashmatches.- The signature is valid for the author’s identity key, as pinned by
genesisor amember_add. - The author had the required role in the state after entry
seq - 1. - 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_deleteends every grant on that environment.
- 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_addpins the member’s identity fingerprint. It changes only with amember_rekeythat the old identity key signs, or with amember_removeand a newmember_add(see §9.6). A client that sees amember_rekeyof 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
| Client | How it gets an access token | Token binding |
|---|---|---|
| Web app | Passkey login → browser session | DPoP, browser Ed25519 key |
| User device (CLI on a laptop) | Device grant once; then JWT bearer assertions | DPoP, device Ed25519 key |
| Machine device (server, CI) | Device grant once; then JWT bearer assertions | DPoP, device Ed25519 key |
- Accounts, sessions, invites, devices and tokens are
auth-chad(its specification, profileAC1), with namespacesecrets/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’sauth_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-chadknows 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.jktsemantics, 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) andES256. 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, andathwhen an access token is present. A proof without an access token MUST NOT carryath. - The header has
typ=dpop+jwt,algand a publicjwk; ajwkwith a private member (d) is rejected.jtiis 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 gets401withuse_dpop_nonceand a fresh nonce; clients retry once. iatmust be within ±60 seconds of server time. The server rejects a reusedjtiwithin the nonce window.htuis 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 theHostheader), 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:
- The user opens the invite link in the web app and chooses a display name and a handle (unique,
^[a-z0-9_-]{3,32}$). - The web app creates a passkey with
residentKey: required,userVerification: required, and theprfextension. If the create response has no PRF output, it runs onegetto evaluate PRF, started by a new user gesture: some browsers refuse a second passkey prompt without one. - 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, fielde2ee). The public keys of the identity key are in the signup’sappfield:{"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 formatnoneis accepted. - 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).
- The user opens the invite link in the web app and chooses a display name and a handle (unique,
- Login:
- The web app creates a browser DPoP key, then asks for a discoverable-credential assertion with
userVerification: requiredand PRF evaluation (prf.eval) with the fixed input of §5.4. One prompt signs and gives the PRF output. - 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.
- The web app unwraps the identity key in memory.
- The web app creates a browser DPoP key, then asks for a discoverable-credential assertion with
- Credential algorithms and attestation: the server offers ES256 (
-7), EdDSA (-8) and RS256 (-257) inpubKeyCredParamsand accepts attestation formatnoneonly. It follows WebAuthn Level 3 §7.1 and §7.2 with this policy:- UP and UV are required. BS without BE is rejected.
crossOrigin: trueand anytopOriginare 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/finishMUST carry it (user_handle), and it MUST match the owner of the credential.
- Ceremonies are stateless:
…/startreturns an opaqueceremonytoken (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 useskid=recovery(§5.4). The user text in the envelope’s AAD is theusr_…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 inAuthorizationand 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 withPOST {auth}/step-up/startand/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/startwith 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}/recoveryreturnshas_keyandhold_until. Accounts from before the recovery verifier have a recovery envelope but no verifier (has_keyis 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):
| Parameter | Value |
|---|---|
scope | user 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_name | A label chosen by the user, for example alice-laptop or shop-prod-web (1–64 chars) |
data | JSON: {"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):
- The user logs in with a passkey (if not already logged in) and enters or confirms the user code.
- 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 (frompublic_keyandenc_key), requested scope (project and environment names, access level), the requester’s IP address,client_info, and the time of the request. - The page shows a warning: “Approve only if you started this on a device you control, just now.”
- 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 todevice_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 signeddevice_grantlog entry per environment, and seals the current EK of each environment todevice_enc_key. The server checks the approver’s role and the log entries.
- User device (
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 gets403.POST {auth}/device/{user_code}/approvewith{"app": {"kind":"user","envelope":…}}or{"app": {"kind":"machine","entries":[…],"wraps":[…]}}. The scope decides the kind of the device. The machine entries MUST be exactly onedevice_grantper requested environment, in scope order, with the request’sdevice_id, fingerprint and access. For an unassigned request they MUST be 1 to 20device_grantentries of one project, with the request’sdevice_idand 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 exampleintegrity_errororwraps_mismatch.POST {auth}/device/{user_code}/deny.- A request that is no longer pending returns
404(or409 conflictif 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>
issandsubare the device ID as base64url of its 16 bytes. The JWT is signed with the device’s Ed25519 key. Header:alg=EdDSA,typ=JWTor absent, nojwk. Claims:issandsub=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 + 60andnow < 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
jtiwas used before. - Response as in step 3, without
device_codesemantics.
7.6 Device credential storage
| Client | Storage |
|---|---|
| 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. |
| CI | A 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
| Action | Owner | Writer | Reader | Machine device read-write | Machine device read |
|---|---|---|---|---|---|
| Read secrets | all envs | all envs | all envs | granted envs | granted envs |
| Write and delete secrets | ✓ | ✓ | — | granted envs | — |
| See secret history | ✓ | ✓ | ✓ | granted envs, from grant epoch | granted 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)
| Item | Default |
|---|---|
| Projects owned per user | 25 |
| Environments per project | 20 |
| Secrets per environment | 1,000 |
| Versions kept per secret | 100 (older versions are pruned; the record chain restarts with prev_record_hash of the oldest kept record allowed to dangle) |
| Value size | 64 KiB |
| Members per project | 50 |
| Devices per user | 50 |
| Request body | 1 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
- 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).
- The client appends
member_addand seals the current EK of every environment to the new member. - 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:
- The owner’s client generates a new EK epoch for each affected environment.
- It re-encrypts the latest record of every secret in those environments under the new epoch, as new versions signed by the owner.
- It seals the new EKs to every remaining recipient.
- It appends the removal entry (with
rotations) and therotateentries. - 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:
| Removal | Rotated |
|---|---|
| Member removed or left | All environments of the project |
| Machine device grant revoked | That environment |
| Machine device deleted | Every environment it had a grant on (across projects, one request per project) |
| User device revoked | All 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_removethey author, with emptyrotations).
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):
- 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.
- 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. - For every project of the user, the client builds one change:
- a
member_rekeyentry with the new fingerprint, signed with the old identity key; - if the user is an owner: a
rotateentry with reasonremovalfor every live environment, signed with the new key, with the new wraps and the re-encrypted records.rotationslists them, as formember_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.
- a
- The request carries the passkey assertion (
ceremony,credential), the new public keys, a signature with the new key over{"challenge": <base64url challenge>, "user_id": …}(purposeidentity-proof), the two new envelopes, the new recovery verifier, and the changes. - 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 acceptsmember_rekeyin 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:
- The admin starts a reset. The user signs up again through a reset invite with the same handle.
- Each owner of each affected project compares the new fingerprint and re-adds the user (
member_removewith rotation, thenmember_addwith 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 useapplication/x-www-form-urlencodedrequests as RFC 6749 requires. -
Auth:
Authorization: DPoP <access_token>and aDPoPproof 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 returns412with the current head (headfield); the client refetches and retries. A missingIf-Matchreturns428. -
Error codes:
Status codeMeaning 400 invalid_requestMalformed JSON, query or header, or a refused request of the account API 400 integrity_errorA signature, log rule or record check failed 400 wraps_mismatchKey wraps missing for a recipient, or given for someone who is not one 400 records_mismatchA rotation did not re-encrypt exactly the latest record of every secret 401 unauthenticated,invalid_dpop_proof,use_dpop_nonce,step_up_requiredWith a WWW-Authenticate: DPoP …challenge403 forbiddenAuthenticated, but the role or grant does not allow it 404 not_foundAlso returned for projects the caller cannot see, so existence does not leak 409 log_changedThe log changed during the request; retry 409 version_conflictversionis not latest + 1409 rotation_requiredAn owner must rotate the environment before it can be written 409 projects_changedThe request does not cover exactly the user’s projects (§9.6) 409 conflictThe state changed during the request, for example a device request that was decided 409 name_existsA secret with this name_hmacexists (secret_idfield)412 log_head_mismatchIf-Matchdoes not match the log head (headfield)413 payload_too_largeBody over the limit 428 precondition_requiredIf-Matchmissing on a log write429 rate_limitedToo many requests; see Retry-After503 backendStorage is unavailable The account API has more codes, with the statuses of
auth-chad(for example403 on_hold,409 last_passkey,400 passkey_refused). -
Every response carries a fresh
DPoP-Nonce. A request without a valid nonce getsuse_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-TypeandIf-Matchrequest headers and theDPoP-Nonceresponse header exposed.
10.2 Endpoints
Discovery, health and OAuth:
| Method and path | Purpose |
|---|---|
GET /.well-known/secrets-server | Discovery (§4.2) |
GET /healthz | 200 when the database answers |
POST /oauth/device_authorization | RFC 8628 step 1 |
POST /oauth/token | RFC 8628 device code grant, RFC 7523 JWT bearer grant |
POST /oauth/revoke | Revoke 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 path | Purpose |
|---|---|
POST {auth}/signup/start, /signup/finish | Invite-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/finish | Passkey login; the answer has the passkey’s envelope |
GET/POST/DELETE {auth}/session | The session; renewal; logout |
POST {auth}/step-up/start, /step-up/finish | A 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/undo | Recovery 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 …/deny | Device 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 path | Purpose |
|---|---|
GET /v1/me | Profile and admin flag |
GET /v1/me/keys | For a device: its envelope (user device) or nothing (machine device) |
POST /v1/me/identity/start, POST /v1/me/identity | Replace the identity key (§9.6); browser session and passkey only |
GET /v1/users/{handle} | Public keys and display name, for sharing |
Projects:
| Method and path | Purpose |
|---|---|
GET /v1/projects | Projects the caller can see |
POST /v1/projects | Create (genesis + first environment + EK wrap) |
GET /v1/projects/{p}/log?after_seq= | Project log |
POST /v1/projects/{p}/log | Append 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}/keys | Every public key set the log pins (members, past members, devices), to verify the log |
GET /v1/projects/{p}/people | User 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}/devices | Machine devices with grants: ID, name, fingerprint (owners) |
GET /v1/projects/{p}/audit?cursor= | Audit log (owners) |
GET /v1/projects/{p}/pending | Environments that wait for a rotation (members) |
Secrets:
| Method and path | Purpose |
|---|---|
GET /v1/projects/{p}/envs/{e}/secrets | Latest record of every secret (with ciphertext): the bulk read for run and export |
GET /v1/projects/{p}/envs/{e}/secrets?values=0 | Latest 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}/versions | History (records) |
GET /v1/projects/{p}/envs/{e}/secrets/{s}/records/{version} | One version |
PUT /v1/projects/{p}/envs/{e}/secrets | Write 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_writerow 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_readrow per request that returns records.secret_idis 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 with503: 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’sidentity_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 thedevice_grantrow 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 = 0stores no IP addresses. GET /v1/projects/{p}/auditreturns up to 100 rows, newest first, to owners:{"events": […], "next": <cursor>}.nextis null on the last page. Clients show environment and secret names by decrypting them.GET {auth}/eventsreturns 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):
--host <host>flag.SECRETS_HOSTenvironment variable.hostin the nearest.secrets.toml(searched from the current directory up to the filesystem root).- The default host in the user config (
$XDG_CONFIG_HOME/secrets-chad/config.toml), set by the firstlogin.
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
| Command | Does |
|---|---|
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 whoami | Host, 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
| Command | Does |
|---|---|
secrets-chad init | Write .secrets.toml for the project and environment of -p and -e (an interactive choice is planned). |
secrets-chad ls | Names, versions, last writer, time. |
secrets-chad get NAME | Print the value to stdout (no trailing newline added when stdout is not a TTY). |
secrets-chad set NAME | Read 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 NAME | Delete (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 mode0600, callsfsync, and renames it overFILE(atomic replace). It keepsFILE’s owner and group when it can, and sets the mode to0600unless--modesays otherwise (planned). --onlylimits the export to the listed names.--prefixadds 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,
--mergebehaves 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
--mergeandimportaccepts 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(execvpon 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-overridekeeps existing variables.
11.7 Machine and device commands
| Command | Does |
|---|---|
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 ID | Own user devices; revoke one, with the rotation it requires. |
secrets-chad machine ls / revoke NAME|ID | Owner: 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):
- Before it asks the server for anything, it checks that
ghcan store secrets in the repository and, with--github-env, in that GitHub environment. It names the repository, says ifSECRETS_DEVICEexists there, and asks. - After the approval, it gives the credential to
gh secret set SECRETS_DEVICEon standard input. The credential is in no argument, file or output. Ifghfails, the key is gone, and the CLI says how to revoke the machine. - 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
| Command | Does |
|---|---|
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|reader | Add 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_CODE | Prints 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 agent | Prints 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 verify | Fetch and verify the whole project log and every latest record; print the result. |
11.9 Output and exit codes
- Human output by default;
--jsongives machine-readable output forls,check,project lsandenv ls(other commands: planned). - Exit codes:
0success,1generic error,2usage error,3not logged in or device revoked,4permission denied,5not found,6integrity error (verification failed, possible rollback or fork),7network or server error,8rotation required (writes refused). - Every command is non-interactive when stdin is not a TTY or
--yesis given; it fails instead of prompting. - The CLI never prints a secret value unless the command’s purpose is to print it (
get,exportto 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, mode0600.
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,exportto stdout andmachine createwithout--outor--githubare refused with exit code 9.runreplaces 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.--maskdoes the same for a person. The exit code is the command’s.shareis 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
- Invite / signup with recovery key display and confirmation.
- Login with passkey; recovery with the recovery key.
- 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.
- Device approval at
/device(§7.4). - 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-Policydenying everything not used, andCache-Control: public, no-cache, no-transform, so that a CDN does not change the page. Static hosts set these from the_headersfile 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 to127.0.0.1and 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 withSecure,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
| Action | Notes |
|---|---|
| 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 user | Disable revokes tokens and devices at once and marks affected environments rotation_required (§9.4). |
| Delete a user | Only 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 status | Replication 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:
- 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.
- Serialized appends per project. Two concurrent appends to one project’s log cannot both commit the same
seq. The losing request gets409and retries on the new head. - 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 to409(or to a new random value, for server-generated codes). - Durability of a commit before the server answers.
- Read-your-writes for a client that reads after its own write.
Every backend passes the same conformance test suite.
Backends in this repo:
| Backend | Cargo feature | database URL | Notes |
|---|---|---|---|
| SQLite (default) | sqlite | sqlite:///path/to/secrets.db | Bundled through rusqlite; one file. |
| PostgreSQL | postgres | postgres://… (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)orVACUUMon 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 atREAD COMMITTED; the uniqueness constraints are the final guard. - TLS: for a host that is not a Unix socket or loopback, the default (
sslmode=prefer) becomesrequire, with the certificate checked against the bundled Mozilla roots. It never falls back to plaintext.sslmode=disableturns TLS off explicitly. Private certificate authorities are not supported yet. - The server needs a database it owns (it creates its tables in the
secretsschema). - Backups are the operator’s job (for example
pg_dump, or WAL archiving).
Both:
- Account tables are those of
auth-chad, with the prefixauth_, 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 runsauth-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_versionfor SQLite, aschema_versiontable 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_limitedwithRetry-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.formatisjson(one object per line) orlogfmt. -
request_log.fieldsselects the fields and their order, from this fixed set only:Field Value 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_headeror the socket)request_idA random ID per request, also sent as the X-Request-Idresponse headerbytes_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 /metricson 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.
14.6 Process hardening (recommended systemd settings)
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.tomlandCargo.toml(rust-version). #![forbid(unsafe_code)]incore,cliandweb;serverallowsunsafeonly 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-denychecks 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/aarch64Linux (musl, static),x86_64/aarch64macOS,x86_64Windows (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, andenvformat 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-corebefore 1.0.
17. Milestones
| Milestone | Content | Done when |
|---|---|---|
| M0 Spec | This document, reviewed. | The maintainers approve it. |
| M1 Core | secrets-core with all formats, log validation, DPoP; test vectors. | Test vectors pass on native and WASM. |
| M2 Server | Storage (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 CLI | login, 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 app | Signup, login, recovery, projects, sharing, approvals, rotation, account. | Headless end-to-end test passes; CSP has no violations. |
| M5 Admin | Admin panel, bootstrap, invites, disable/reset, quotas, metrics. | Manual test on a staging instance. |
| M6 Release | Release 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. |
Decisions
Summary: what we decided, and why, one short page each. The wiki explains how things work; these pages keep the reasons.
Key terms: decision, reason, refused, not now.
Related: wiki · spec
Each page has the date, what was decided, why, and what it rules out. A new decision gets the next number. A decision that changes gets a new page that names the old one.
| No. | Decision | Date |
|---|---|---|
| 001 | Accounts, passkeys, sessions and devices come from auth-chad | 2026-11-26 |
| 002 | The web app is served from a host other than the API server | 2026-11-23 |
| 003 | One server process per database; no high availability in the server | 2026-11-23 |
001 Accounts on auth-chad
Summary: why secrets uses auth-chad’s account API for passkeys, sessions, devices and recovery, and what stays in secrets.
Key terms: auth-chad, account API, hook, e2ee mode, recovery verifier, auth_path.
Related: Interfaces · Flows
Date: 2026-11-26. State: in force. Deployed on the test service with server 2a36178 and auth-chad bf07bcd.
Decided
- The account API is auth-chad’s, mounted at
/v1/auth(the server’sauth_path, configurable). secrets’ own account routes are gone. - auth-chad’s formats. IDs in the account API are base64url, and errors on every route are
{"error": code}. The web app and the CLI changed in one release (v0.1.0-alpha.2). - auth-chad’s end-to-end encryption mode (
Auth::with_e2ee): envelopes at signup, login, passkey add and remove, and recovery, with a recovery verifier. Recovery for an unknown handle returns a decoy, so handles do not leak. - Rules through hooks.
Rulesimplements auth-chad’sHooks: profile at signup, handle rules, invite rules, device scopes and kinds, machine grants at approval, rotation marks at revocation and at undo. - Admin invites from the host only. The
invite_datahook refuses an admin flag from the API; the server’sadmin invite --admincommand makes admins. - Rate limits. auth-chad’s shared limits count account calls (
auth_per_minute, default 20). secrets keeps its own write limit for project routes (writes_per_minute, 600). - Extra functions used: the session list (end one, end all), recovery status with the hold, and recovery undo. The device approval page shows the requesting address.
What stays in secrets
Projects, environments and their logs; the profile, user lookup and people routes; identity key replacement; machine grants and the choice of machines at a member’s removal; discovery, the request log and body limits.
Refused
| Refused | Reason |
|---|---|
| Recovery by email or by an owner | It gives a login without the identity key, which nobody else can restore |
| View as a user | It conflicts with end-to-end encryption |
| API keys | Every client is key-bound; a device key does the same without a copyable secret |
| Mail recovery, external login, tenants, places | No use in secrets |
Not now
| Not now | What can change it |
|---|---|
| Connected apps (OAuth for other companies’ apps) | Read access for AI apps; the routes exist, with no app registered and dynamic registration off |
| Encrypted data sync (auth-chad spec 16) | The open questions at the end of that draft |
Consequences
People logged in once more after the switch. The two accounts from before it had to set a new recovery key, because
the recovery verifier is new. CLIs before v0.1.0-alpha.2 stopped working.
002 The web app on its own host
Summary: why the recommended deployment serves the web app from a static host other than the API server.
Key terms: web origin, API origin, discovery, CSP, web bundle.
Related: Operation · Concepts
Date: 2026-11-23. State: in force (spec §4.3).
Decided
- The web app is a generic static bundle. A deployment adds
config.json, the discovery document and the CSPconnect-srcvalue, and serves it from the web origin. - The API server publishes the public listener at a separate API origin. The server can also serve the bundle itself
(
serve_web_bundle), as a self-hosting option. - The bundle has no inline scripts and no third-party code, and every release publishes it with its SHA-256.
Why
Every person opens the web app: to sign up, and to approve each new device. Whoever can change its files can steal the keys of people who use it during that time. With a separate host:
- Root on the API host cannot change the code that runs in browsers.
- The API host stays a store with no influence over key handling.
Refused
| Refused | Reason |
|---|---|
| Server-side rendering of the web app | The server would produce the code that handles keys |
| Third-party scripts, fonts or analytics | Each is code that runs with the keys in reach |
003 One process per database
Summary: why secrets runs one server process per database and leaves high availability to the database and the operator.
Key terms: SQLite, PostgreSQL, writer connection, rate limit, audit buffer, high availability.
Related: Operation · Spec §1
Date: 2026-11-23. State: in force.
Decided
- One
secrets-serverprocess serves one database. The target is a small VM (1 vCPU, 1 GB RAM) for hundreds of users. - SQLite is the default, with one writer connection that serializes log appends. PostgreSQL is supported for deployments that already run it.
- The write rate limit and the buffer of read audit events live in the process’s memory.
Why
- A secrets server has little traffic: a deploy or a CI job reads one environment in one request.
- One process keeps the server small and its failure modes few. Backups of one SQLite file are simple.
- Clients detect a server that lies or rolls back; availability is the only property that a second process would add.
Refused
| Refused | Reason |
|---|---|
| Several server processes on one database | The in-memory limits and audit buffer would need shared state |
| Federation between servers | Out of scope for v1: an account and its devices belong to one server |
Not now
| Not now | What can change it |
|---|---|
| High availability in the server | A deployment that cannot accept a restart; PostgreSQL can already be made highly available on its own |
secrets wiki index
For coding agents and search. One line for each page: what it answers, and its key terms. Read the page you need, not
all of them. Exact rules are in docs/spec.md; task commands are in docs/recipes/.
- index.md: what secrets is, what it is for and not for, where to start. Terms: end-to-end encryption, project, environment, machine device, status.
- concepts.md: the model in seven ideas, what the server sees, the glossary. Terms: project log, environment key, epoch, wrap, record, rotation, fingerprint, pin, envelope.
- map.md: repository and crate layout, dependency rules, where to change things, code rules, tests. Terms: ports and adapters, use case, composition root, auth-chad.
- data.md: every table, log entries and records field by field, server types, CLI local files. Terms: Batch, Commit, Principal, Caller, Actor, project_access, rotation_required.
- flows.md: requests, signup, login, device and machine approval, GitHub Actions, sharing, secrets, removal, revocation, recovery, known gaps. Terms: DPoP, user code, device grant, integrity error, hold.
- interfaces.md: traits: Ports, Store, Health, KeyStore, ProjectStore, ProfileStore, AuditStore, Random, AuditBuffer, Fail, LogSink, Clock, KeyDirectory, IdKind, Http, Draws, Gh, Opener; auth-chad hooks in Rules.
- operation.md: deployment, origins, configuration, storage and backups, limits, logging, hardening, why one process. Terms: web origin, API origin, admin listener, server.toml.
- recipes.md: the task index, common commands, exit codes.
- ../decisions/README.md: decisions and their reasons.
- ../spec.md: the normative spec.
Build the site: scripts/wiki.py build (output in target/wiki). Check it: scripts/wiki.py check.
From the CLI: secrets-chad docs, secrets-chad docs <page>, secrets-chad docs --open.