Secrets Architecture
A workspace often needs credentials: an API token for the model provider, a registry password, a deploy key. jailoc keeps them out of the image, out of config.toml and out of the shared directories. The configuration names where each secret comes from on the host, and jailoc delivers the value into the running VM's memory.
Two kinds of secret
Secrets are declared under [defaults.secrets] or [workspaces.<name>.secrets]:
| Kind | Result in the guest |
|---|---|
secrets.env.NAME |
The environment variable NAME in every session, loaded from an in-memory environment file in the guest |
secrets.file.NAME |
The file /run/secrets/NAME |
Each secret has exactly one source:
| Source | Value comes from |
|---|---|
from_env |
A variable in the environment of the jailoc process |
from_file |
A file on the host |
from_command |
The standard output of a command jailoc runs on the host |
The configuration holds the reference, never the value. from_command lets a password manager or keychain hold the secret, so it never sits in a plain file or the shell environment.
Delivery
On the host
jailoc reads every secret on the host before it boots the VM or applies a reload. A from_command runs with /bin/sh -c and JAILOC_WORKSPACE set to the workspace name, with the terminal attached, so a password manager can prompt for an unlock.
When a from_command secret sets ttl, jailoc caches its output in the host's system keychain (the macOS login keychain or the Linux kernel user keyring) for that duration per workspace. That avoids repeated interactive prompts across restarts and reloads while keeping secret values out of plain files on host disk.
A source that can't be read, or a command that fails or prints nothing, stops the operation before anything changes.
Into the guest
Once the guest's SSH server is ready, jailoc sends the values, together with the workspace's env entries, as a single payload over the SSH connection that the broker forwards into the VM.
Inside the guest, jailoc-guest stores them in memory:
| Secret | Stored as |
|---|---|
| File secret | /run/secrets/NAME, mode 0400, owned by agent. /run/secrets is a tmpfs owned by agent, so the values exist only in guest memory and disappear when the VM stops. |
| Env secret, and other environment entries | An in-memory environment file that every new session loads. An env secret value loses its trailing line break and must fit on one line; multi-line values belong in file secrets. |
What never reaches host disk
jailoc never writes secret values to host disk. They aren't part of the image, the VM state directory, a share or a snapshot.
Two logs in the VM state directory receive guest text: the process log (jailoc strace), which records command lines, and the VM console log (jailoc logs). Both replace configured secret values of eight or more characters and common credential patterns with [redacted] before writing to disk. These aren't covered:
- shorter values that don't match a credential pattern,
- values transformed by a program,
- anything the agent writes to shared directories.
Restarts and interrupted starts
A guest that stops for any reason takes the whole VM down, and every start delivers the secrets again. jailoc also records each delivery in the VM state directory: when a session attaches to a running VM that never received its secrets, for example because jailoc up was interrupted right after the boot, jailoc delivers them first.
Reload and rotation
jailoc reload is how secrets rotate: it reads every source again and pushes the full set.
| Command | Cached from_command output |
|---|---|
jailoc reload |
Reuses unexpired ttl entries |
jailoc reload --purge-cache |
Evicts the entries from the system keychain and runs every command again |
What changes in the guest:
- Changed values replace the old files, and files for secrets that are no longer configured are removed from
/run/secrets. - New sessions get the new environment.
- Sessions that are already running keep the environment they started with, so a process that read a variable at start doesn't see the change until a new session starts.
- Processes that read
/run/secrets/NAMEsee the new value immediately.
What this protects against
The design keeps secrets out of places that outlive the VM or reach other parties: image layers, build caches, Git history, and files shared with the host.
It doesn't hide them from the agent. The agent runs as agent, can read every env secret in its environment and every file in /run/secrets, and, unless protect_git turns it off, can use sudo to become root in the guest. Every secret configured for a workspace is visible to the agent, and network egress to public addresses is open, so the agent can send a secret anywhere it can reach.
Configure only the secrets the workspace really needs, and prefer short-lived, narrowly scoped tokens. See Threat Model.
See Manage secrets for configuration steps.