Safeguard Docs
Credentials Vault

Local vault and keychain storage

Keep credentials on one machine with no network or account (local://), and keep PAM provider secrets in the operating system keychain (keychain://).

Local vault and keychain storage

Two features keep secrets on the machine that uses them. Both are in the Safeguard CLI.

  • Keychain references (keychain://<service>/<account>) put a PAM provider's own connection secret, such as an API key, in the operating system's credential store instead of an environment variable or a file.
  • The local vault (local://<name>) is an offline store of credentials on this machine. It needs no network and no Safeguard account.

Neither one sends a value to Safeguard.

Keychain references for provider secrets

A setting in the provider file that holds a secret (api_key, token, secret_id, client_secret, jwt) can be written as a keychain reference next to env:// and file://:

providers:
  - name: pam-prod
    type: arcon
    url: https://pam.example.internal
    api_user: svc-safeguard
    api_key: keychain://safeguard-pam-prod/api-key

Store the value once. The command reads it from the terminal without echoing it, or from standard input when piped (all of it, so a multi-line PEM key is kept whole, minus one trailing newline), and never takes it as an argument, so it does not reach a process list or the shell history:

safeguard vault keychain set safeguard-pam-prod/api-key
safeguard vault keychain test safeguard-pam-prod/api-key   # says whether it exists, never shows it
safeguard vault keychain rm safeguard-pam-prod/api-key

<service> and <account> use letters, digits and . _ @ : + - only.

SystemStore used
macOSThe macOS Keychain
WindowsWindows Credential Manager
LinuxThe Secret Service (GNOME Keyring, or KWallet where it provides the Secret Service API), through secret-tool

Windows Credential Manager holds up to 2560 bytes per entry. A machine without a usable store, such as a headless server, cannot use keychain://. Use env:// or file:// there. On Linux, secret-tool installed without a running D-Bus session reports an entry as not found rather than as an unavailable keychain. A missing or unreadable entry fails the read with a message that names the setting and never the value.

The local vault

The local vault holds named credentials in one encrypted file in the CLI's configuration folder. Use an item as local://<name> in a scan option that takes a reference or with safeguard vault exec. It is not accepted as a provider-file setting; use keychain:// for those.

safeguard vault local add staging/dast-password     # value from the terminal (no echo) or stdin, read to the end
safeguard vault local list                          # names and versions, never values
safeguard vault local show staging/dast-password    # the value's length class; --reveal prints it, terminal only
safeguard vault local rm staging/dast-password
safeguard vault local rotate-key

The first add creates the vault. By default it is locked with a random key held in the operating system keychain. --passphrase on the first add locks it with a passphrase instead (Argon2id). A new passphrase is at least 12 characters. rotate-key makes a new data key and re-encrypts every item. rotate-key --keychain also makes a new random key in the keychain and replaces the old one, and rotate-key --passphrase changes the lock to a passphrase and removes the old keychain key.

Item names use letters, digits and . _ - /, up to 128 characters.

What protects the file

  • Each item is encrypted with AES-256-GCM under a random data key. The ciphertext is bound to the store, the item name and its version, so an item cannot be moved to another name or, within the same file, replayed at an older version (see the rollback limit below).
  • A manifest check covers every item, its version and its nonce. Editing, adding, removing or swapping items by hand makes the vault refuse to open, and the read fails with an integrity message. Damage inside one item's ciphertext is found when that item is read.
  • Changes are written to a temporary file, flushed to disk and renamed into place under a lock, so a crash leaves the old or the new vault and two commands running together do not lose each other's writes.
  • On Linux and macOS the file is created with mode 600 and the CLI refuses a file that other users can read. On Windows it relies on the permissions (ACLs) of your user profile.
  • The data key is wrapped by the keychain key or the passphrase. Without one of them the file cannot be read.

What it does not do

  • Restoring an older copy of the whole file is not detected.
  • It protects a disk, a backup or a copied file. It does not protect against a program running under your user account: with the keychain lock, any such program can read the key at any time (on macOS the item is written by /usr/bin/security, so it needs no prompt). A passphrase-locked vault is only as safe as wherever SAFEGUARD_LOCAL_VAULT_PASSPHRASE is kept.
  • A local item is read only on this machine and is never delivered to Safeguard cloud consumers. Be aware that a scan job the platform sends to a runner is also resolved on the runner host: on the CLI local:// is on by default, but for platform jobs a runner reads local:// only if its provider file sets allow_local: true, and you should leave it off on shared runner hosts. The item's name (never its value) can appear in the audit records of a read.

In scans and commands

local://<name> works in the credential scan options that take a reference and in safeguard vault exec. When every reference given to vault exec is a local:// one, it needs no Safeguard sign-in and works offline; mixing in any other reference needs the usual sign-in. The command it runs does not receive SAFEGUARD_LOCAL_VAULT_PASSPHRASE or any other Safeguard token, key or password variable. A passphrase-locked vault needs SAFEGUARD_LOCAL_VAULT_PASSPHRASE set for a non-interactive run, so prefer the keychain lock for scans. To keep the file somewhere else, set SAFEGUARD_LOCAL_VAULT to its path. To turn local:// off for the CLI, set allow_local: false at the top level of the provider file; to allow it for platform jobs on a runner, set allow_local: true.

Agent sessions

When an agent runtime sets SAFEGUARD_AGENT_SESSION to any value other than empty, 0 or false, local:// reads and the vault local commands are refused. This is defence in depth, not a security boundary: a program can unset the variable. An agent that can run commands as you can read the vault, so keep agents in a sandbox that has no access to your keychain or the vault file.

Errors

MessageMeaning
NOT_FOUND: no local vault yetCreate it with safeguard vault local add <name>.
NOT_FOUND: no such itemCheck the name with safeguard vault local list.
AUTH_FAILED: could not be unlockedThe keychain is locked or its key is gone, or the passphrase is missing or wrong.
INTEGRITY: failed its integrity checkThe file was changed or damaged. Restore it from a backup.
DISABLEDallow_local: false is set.

On this page