safekeys/secret-creation [built]
Creating a secret is the one flow that touches plaintext, and it deliberately bypasses the model. A human CLI or agent SDK sends plaintext to the sidecar over a local authenticated channel; the sidecar encrypts locally and asks the control plane to allocate an object id and wrapping policy; only a capability token is returned to the agent.
Status: built
Why this exists
If creation flowed through model context — "here is the API key, please store it" — the value would already be compromised at step one, whatever happened afterwards. Routing plaintext caller→sidecar and returning only a token means even the creation moment keeps the model off the path.
Design decisions
local-channel-for-create [accepted]
Decision: Send plaintext from caller to sidecar over the local authenticated Unix socket, never over the network.
Rationale: Keeps the value off the wire entirely during creation and makes the trust boundary a filesystem permission the OS already enforces.
stdin-not-argv [accepted]
Decision: Accept values via stdin or file only; never as a command-line argument.
Rationale: argv is visible in process listings, shell history, and audit logs — a trivially avoidable leak.
create-not-a-web-console-flow [accepted]
Decision: Do not build a web console for creation in the MVP.
Rationale: A browser form would reintroduce a network path for plaintext without changing the security story; the CLI and SDK cover the two real callers.
How it works
Create a secret from the CLI (create-from-cli)
A human supplies a value out-of-band and receives a token.
- Receive — Operator pipes the value to
safekeys createvia stdin or a file — not as an argument. - Send — CLI sends the plaintext to the local sidecar over the Unix socket.
- Receive — Sidecar asks the control plane to allocate an object id and wrapping policy.
- Encrypt — Sidecar generates a DEK, encrypts the plaintext locally, and writes the ciphertext object.
- Transmit — Sidecar sends the DEK for wrapping under the KEK in the key store.
- Receive — A capability token is returned to the caller; the plaintext is discarded.
Create a secret from an agent SDK (create-from-agent)
An agent creates a secret and receives only a token — it never supplies a value it read from context.
- Receive — Agent SDK calls create_secret with metadata and a value source that is not model context (a file path or an out-of-band reference).
- Send — SDK forwards the value to the sidecar over the local channel without it entering the agent's transcript.
- Receive — SDK returns a capability token and folder path to the agent.
- Observe — The agent transcript contains no plaintext.
Guarantees
plaintext-not-through-model
Creation must never require the plaintext to pass through model context, logs, or tool arguments.
Acceptance criteria:
- [ ] The caller hands the value to the sidecar directly over a local channel
- [ ] Values are supplied via stdin or file, not as command arguments
- [ ] Only a token is returned to the agent
encrypt-before-persist
Plaintext is encrypted before anything durable is written.
Acceptance criteria:
- [ ] A fresh DEK is generated per object
- [ ] Only ciphertext is written to the folder
- [ ] The plaintext buffer is zeroised after encryption
token-returned-not-value
The creation response contains a handle, never the secret.
Acceptance criteria:
- [ ] Response carries a capability token and/or folder path
- [ ] No value is echoed back
- [ ] The token contains no secret material
Test specifications
creation-returns-token-only
Given:
- secret_value: "value-from-stdin"
When: create-from-cli
Then:
- assertion: the response contains a capability token
- assertion: the response does not contain the secret value
- assertion: the stored object is ciphertext
Contracts verified: token-returned-not-value, encrypt-before-persist
argv-never-contains-plaintext
Given:
- supplied_via: "file"
When: create-from-cli
Then:
- assertion: the process arguments contain no plaintext
- assertion: the value arrives over stdin or a file descriptor
Contracts verified: plaintext-not-through-model
agent-transcript-clean
Given:
- agent: "langgraph-agent"
- secret_source: "file"
When: create-from-agent
Then:
- assertion: the agent transcript contains no plaintext
- assertion: the agent holds only a token afterwards
Contracts verified: plaintext-not-through-model
Implementation
- Primary: apps/cli/internal/commands/commands.go
- Test code status: none
See Also
- safekeys/envelope-encryption
- safekeys/encrypted-folder
- safekeys/python-sdk