Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 serverNot readable by the server
User handles and display namesSecret names
Project and environment namesSecret values
Members and their roles; machine devices and their grantsEnvironment keys
Device names, public keys, IP addresses, timesIdentity keys, device keys, recovery keys
Number of secrets, their sizes and versionsPasskey 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

TermMeaningIn the code
InstanceOne deployment of the server, with its own userssecrets-server
UserA person with an account; logs in with passkeysId<User>, usr_…
Instance adminA flag on a user account that allows invites. It gives no project rightsProfile::admin
ProjectA named container of environments, owned by one or more usersId<Project>, prj_…
EnvironmentA named set of secrets in a project, with its own keyId<Env>, env_…
SecretA named UTF-8 value in an environment, with a version historyId<Secret>, sec_…
MemberA user with a role in a project: owner, writer or readerMember, Role
User deviceA CLI login that acts as its user and holds the user’s identity keyDeviceOwner::User
Machine deviceA device with grants on specific environments only, for servers, CI and agentsDeviceOwner::Machine
GrantPermission for a machine device to read or read-write one environmentdevice_grant, Access
Project logThe hash-chained, owner-signed entries that define a project’s accessSignedEntry, ProjectState
Log headThe sequence number and hash of the newest verified entryHead
Identity keyA user’s long-term Ed25519 and X25519 key pairPublicKeys
EnvelopeThe identity private key, encrypted for one passkey, the recovery key or one user deviceauth-chad’s Envelope (passkey, recovery key); Sealed<64> (user device)
Device keyA device’s Ed25519 and X25519 key pair. It also signs DPoP proofsKeyPair
Device credentialA device key and its server in one string, sdc1_…, for SECRETS_DEVICEDeviceCredential
Environment keyThe 32-byte key of one environment and epochEnvKey
EpochThe version number of an environment keyepoch
WrapAn environment key encrypted to one member or machine with HPKEWrap, Sealed<32>
Key commitmentA hash of the environment key in the signed rotate entrykey_commitment
RecordOne signed version of one secret: encrypted name and value, chain hash, log headRecord
Name lookup hashAn HMAC of the secret name, so the server can find a name it cannot readname_hmac
RotationA new epoch for an environment, with every latest record re-encryptedrotate entry
Rotation requiredA mark on an environment after a removal without an owner; writes stop until rotationrotation_required
FingerprintA short hash of a public key pair, for comparison by peopleFingerprint
PinA fingerprint that a client stored at first use and compares laterPins
Recovery keyA 32-byte key the person stores, which opens the recovery envelopeauth-chad’s e2ee recovery
WorkspaceA verified project with the environment keys the caller can openWorkspace