Skip to content

safekeys/dev-key-custody [built] ​

Development-stack key custody: no key material the coding agent's OS user can read as a plaintext file — the dev KEK in the macOS Keychain or a containerised OpenBao dev instance on Linux, and the token signing seed under the same ladder. A plaintext file survives only behind SAFEKEYS_ALLOW_INSECURE_KEYSTORE=1 with a loud startup warning and a permission check; dev-up refuses to start on stale plaintext key files; and a documented separate-user mode runs the sidecar as a dedicated user with peer-credential checks on the socket. The Keychain is a storage improvement, not an access boundary (measured); the separate-user mode is the boundary.

Status: built

Why this exists ​

The dev stack currently stores the KEK in a 0600 file owned by the same OS user as any coding agent, so an agent with file access can read it and the deployment's separate-user promise does not exist locally. The default dev flow must keep the KEK out of an agent-readable file — Keychain on macOS, the containerised dev OpenBao on Linux — with a plaintext file available only behind an explicit, loudly-warned opt-in, and a documented separate-user mode for hosts where the stronger boundary matters.

Design decisions ​

keep-insecure-keystore-name [accepted] ​

Decision: Keep SAFEKEYS_ALLOW_INSECURE_KEYSTORE as the file-mode opt-in rather than renaming to SAFEKEYS_DEV_INSECURE_KEYFILE.

Rationale: The variable already exists, is documented, and is asserted by the production refuse test. Renaming it would churn every reference for no security gain; the semantics being added (permission check, loud warning) do not require a new name.

Date: 2026-09-28

keychain-is-a-speed-bump-not-a-boundary [accepted] ​

Decision: Document the macOS Keychain as a storage improvement, not an access boundary, and name the separate-user mode as the strong local boundary.

Rationale: Measured on this machine (2026-09-28, macOS login keychain): a generic-password item created with security add-generic-password -T <binary> is readable WITHOUT any prompt by an arbitrary same-user process — both via the security CLI and via the Security framework (SecKeychainFindGenericPassword returns success silently). The -T ACL governs GUI-level partition lists and does not bind the trusted security tool or framework reads the way the design assumed. The red-team script caught this: the original test expected a denied silent read and measured success.

Consequences: The honest guarantee is: no plaintext key FILE exists in the repo or home directory by default, and key material lives outside the working tree. The red-team key-access section asserts the disk property and records the keychain finding as a measured note. Operators who need a same-host access boundary use scripts/separate-user-mode.sh, which mirrors the deployment's OS-user separation and is the control this feature names for that threat.

Date: 2026-09-28

openbao-dev-is-the-linux-default [accepted] ​

Decision: Make the containerised dev OpenBao the default Linux dev keystore instead of the local file.

Rationale: The dev Compose stack already runs OpenBao under its own container user; pointing the sidecar at Vault transit costs no new infrastructure and removes the plaintext file from the default path entirely.

Date: 2026-09-28

How it works ​

Dev KEK lives in the macOS Keychain (dev-kek-in-keychain) ​

  1. Setup — scripts/dev-up.sh creates or reuses a Keychain item whose ACL grants only the sidecar binary.
  2. Receive — The sidecar reads the KEK from the Keychain at startup; no plaintext KEK file exists on disk.
  3. Observe — A same-user process other than the sidecar reading the item triggers a user-visible ACL prompt or denial.
  4. Observe — .dev/ contains no KEK file and the sidecar resolves normally.

Dev KEK lives in the dev OpenBao instance (dev-kek-in-openbao) ​

  1. Setup — The dev Compose stack runs OpenBao in a container under its own user, as it already does.
  2. Receive — The sidecar uses Vault transit by default on Linux; the KEK never exists as a file the agent user can read.
  3. Observe — No KEK file appears in .dev/ or the home directory.

Plaintext key file is an explicit, loud opt-in (insecure-file-opt-in) ​

  1. Receive — SAFEKEYS_ALLOW_INSECURE_KEYSTORE=1 is the only way the local file keystore activates.
  2. Validate — The sidecar refuses to start when the key file is group- or world-readable.
  3. Observe — Startup prints a loud warning that the mode is not for real secrets.
  4. Observe — Documentation marks the mode as not for real secrets.

Separate-user local mode with peer-credential checks (separate-user-local-mode) ​

  1. Setup — A documented script creates a dedicated sidecar user and an agent group; the sidecar runs as the dedicated user.
  2. Validate — The sidecar checks the peer credential (uid/gid) of every socket connection, not only filesystem permissions.
  3. Observe — An agent in the group resolves; a process outside the group is denied even if socket permissions change.