Run programs with secrets
Instead of putting a secret in a file, put a vault:// reference there and
let vaultfold fill it in for one process.
Prerequisites
Section titled “Prerequisites”- A vault with at least one entry (see store and read).
- An existing env file or template to hold the references.
linkedits files in place; it does not create them.
Run a command with an env file
Section titled “Run a command with an env file”Write a reference into an env file, then run the command. Every variable whose whole value is a reference is replaced in the child's environment only. Env files are read, never written.
touch .envvaultfold link .env DB_PASS vault://app/db#passwordvaultfold run --env-file .env -- npm startEverything after -- is the command and its arguments. All references are
resolved before the command starts; if one cannot be resolved, nothing runs.
When output goes to a terminal, resolved values of 8 bytes or more are
replaced by ***. Use --mask-min to change the threshold.
Keep a value out of the environment
Section titled “Keep a value out of the environment”Environment variables are visible to the child and, through the process table, to other processes with the same privileges. For the most sensitive values, deliver the value on a file descriptor instead (not on Windows).
vaultfold run --fd 4=vault://app/db#password -- sh -c 'cat <&4'Render a template
Section titled “Render a template”inject replaces references in a template and writes the result to standard
output, resolving everything before anything is written.
printf 'host=db.internal\npass=vault://app/db#password\n' > app.conf.tmplvaultfold inject -i app.conf.tmplTo give a program a real file, render to a temporary file that is zeroed and
removed when the command exits. This asks you to type write on a terminal
and never overwrites an existing file.
vaultfold inject -i app.conf.tmpl --to-file app.conf --ephemeral -- ./start-serverIf a run is interrupted, vaultfold inject --wipe removes any leftover files.
Current limitations
Section titled “Current limitations”- Vault commands start the agent daemon and unlock once;
runandinjecthave the daemon resolve references so no key reaches them. SetVAULTFOLD_NO_AGENT=1to skip the daemon and unlock in-process for that command only. - Encoded forms of a value (base64, URL encoding) are not masked, and a masked child sees pipes rather than a terminal.
- A script that runs many vault commands back to back can hit the daemon's
rate limit (60 requests a minute, burst of 20); batch references into one
run. --to-fileneeds a terminal to confirm, and on Windowsrun --fdis refused.