Vault sealing (Preview)
Learn how the sandbox credential vault seals each value with a macOS Keychain or Secret Service key, what the seal pin checks and covers. Preview.
Reference for how the credential vault (Preview) is kept on disk. You do not need it to add or use secrets.
Storage modes
The first line of defenseclaw sandbox vault list says how the vault is kept (--json has it as storage, with sealed true or false).
| Storage | Meaning |
|---|---|
sealed (macOS Keychain) | Each value is encrypted. The key is in your default (login) keychain, item defenseclaw-vault, which the DefenseClaw program that made it reads without asking. A new DefenseClaw build asks once. |
sealed (Secret Service) | Each value is encrypted. The key is in your Secret Service keyring (GNOME Keyring or KWallet), reached through secret-tool. |
file (owner-only, not encrypted) | No keystore was usable, or DEFENSECLAW_VAULT_STORE=file is set. Anything running as your account can read the values, as it can read your shell environment. |
DEFENSECLAW_VAULT_STORE | Effect |
|---|---|
| unset | Seal when a keystore is usable, else keep a plain file. |
file | Keep a plain file. |
keychain | Require sealing. A vault change, sandbox setup, run, start and connect wait for the keystore and stop with a message when the vault cannot be sealed, instead of writing a plain file or starting the sandbox. |
Over SSH, in a service, or on Linux without a desktop keyring the keystore is often not usable. The vault then stays a plain file, and sandbox setup, the vault change and vault list say why.
When sealing starts
Sealing starts the first time one of these commands runs with a usable keystore. With no vault yet it makes an empty sealed one, so every secret captured after that is sealed when it is written. The command that seals the vault says so.
| Command | Waits for the keystore |
|---|---|
sandbox setup, and vault changes (vault add, replace, bind, rename, remove, confirm) | As long as it needs. |
sandbox run (before it creates or resumes a sandbox), sandbox start and sandbox connect (before they start a stopped sandbox) | About two seconds. A keystore that does not answer by then (a Secret Service waiting to be unlocked) leaves the vault a plain file for that command, which goes on. On Linux they skip the Secret Service when DBUS_SESSION_BUS_ADDRESS is not set, as in most SSH logins. |
vault list and vault show only read and never seal a plain-file vault, with one exception: vault list seals again a vault that had been sealed and is now a plain file (the seal pin).
The gateway and the sandbox daemon never seal a plain-file vault themselves and never read the keystore. A secret they capture into a plain-file vault is written to that file, and is sealed with the rest by the next sandbox run, start, connect, setup or vault change that can use the keystore. A kept sandbox that the gateway resumes on its own does not seal the vault.
Working without the key
Names, hosts, status and use times stay readable, so vault list and vault show work without the key. The gateway and the sandbox daemon store a captured secret with the vault's public key only, so capture also works where the keystore cannot be reached, and it never asks you anything. vault confirm works without the key too; it then says the secret's last characters are not readable.
A sealed vault is never written back as a plain file. When its key cannot be read (keychain locked over SSH, no Secret Service in this session, DEFENSECLAW_VAULT_STORE=file):
- listing, showing, confirming, removing and capture keep working;
- adding, replacing, binding or renaming a secret and
sandbox run --vaultstop with a message that says why.
Unlock the keychain (security unlock-keychain on macOS) or run the command in your desktop session. After an upgrade, the macOS keychain may refuse the new DefenseClaw build over SSH until you allow it once in a desktop session. On Linux, secret-tool answers the same way for a missing key and a locked keyring, so DefenseClaw asks you to unlock the keyring and never treats the key as gone.
Only if you know the key is gone (keychain reset, a vault copied from another account or computer) are the values lost: move vault.json aside and add the secrets again.
What a sealed value is tied to
Each sealed value is tied to its entry's name, host and port. A value moved to another entry or pointed at another host does not open, and a vault that fails this check, or whose header is damaged, is refused and left as it is. The other fields (confirmed, exposed, where a secret came from, when it was used) are not protected: a program that can write the file as your account can change them.
When another DefenseClaw command is writing the vault at the moment a secret is exposed, the exposure is kept in a small record next to the vault (a keyed digest, never the value) and written into the vault right after. From the moment it is recorded, the secret reads as exposed and no sandbox gets it.
The seal pin
The gateway and the sandbox daemon seal a captured secret with the public key written in the vault file, without the private key. On their own they could not tell a real header from one a program rewrote, so they keep a pin: a digest of the sealed vault's header (its public key, key ID and fingerprint salt) in vault-pin.json, next to the vault directory (for example ~/.defenseclaw/vault-pin.json).
- The CLI writes the pin when it seals the vault, and when it reads the key for a vault that has no pin yet. A sealed vault with no pin yet is otherwise pinned by its first capture.
- Only
vault listreplaces a pin that differs from the vault. - Before a capture, the gateway and the sandbox daemon compare the vault with the pin. When the header is not the pinned one, or a vault that was sealed is now a plain file or gone, they keep nothing: the call is still stopped, the secret is not sent on, the vault file is left as it is, the answer tells you to run
defenseclaw sandbox vault list, and the gateway records a high-severity alert. - A plain-file vault that was never sealed has no pin and captures as before.
defenseclaw sandbox vault list then checks the vault:
| Found | What vault list does |
|---|---|
| Sealed, header not the pinned one | Reads your key and checks that it matches the header, that every value opens, and that every stored fingerprint matches the header's salt. When all of that holds, it renews the pin and capture works again. When it does not, the file was changed: list warns, nothing is pinned, and capture and vault changes stay off. Move vault.json aside; the next vault change or sandbox run makes a new sealed vault and pins it. Without the key in this session it says it cannot check and changes nothing. |
| Sealed before, now a plain file or gone | With a usable keystore it seals the vault again with a new key and pins it (check the entries: DefenseClaw did not write that plain file). A vault change, sandbox setup, run, start or connect that can use the keystore does the same. Without a keystore it warns, and vault changes stop rather than write a plain file. To keep a plain-file vault on purpose, set DEFENSECLAW_VAULT_STORE=file and run vault list, which removes the pin. |
--output json has the result as pin (changed, unsealed or not pinned yet; absent when the vault matches) with pin_note or pin_warning.
What sealing protects
| Protects against | Does not protect against |
|---|---|
| A copy of the file (a backup, a synced folder, a copied home directory, a program that collects files) showing the values. | A program running as your account while your keystore is unlocked: it can ask DefenseClaw or the keystore for them. The sandbox stays the boundary. |
| A change to the vault file alone: a header rewritten so later captures are sealed to someone else's key, a sealed vault replaced with a plain copy or one sealed under another key, or a sealed vault deleted so later captures would be written in the clear (the seal pin). | A program that rewrites the vault and the pin together: the pin is a file of your account too. An older copy of the same sealed vault (same key) matches the pin, so going back to it is not detected. |
Your account is the trust boundary, here and on a managed computer, where the sandbox daemon's state directory is also yours. Sealing an existing plain file replaces it but does not wipe its old blocks from the disk: rotate a secret if that matters to you.
Unused keychain items on macOS
A key made for a change that was then not written stays in the keychain as an unused defenseclaw-vault item. This happens when two DefenseClaw commands seal the vault at the same time, or when the keychain answered too late. An unused item opens nothing.
To remove extras, find the key in use: the key_id in the seal part of vault.json. Every other item with service defenseclaw-vault (its account is vault- followed by a key ID) is unused. Delete one in Keychain Access, or with security delete-generic-password -s defenseclaw-vault -a vault-KEY_ID. Never delete the item of the key in use: the vault's values cannot be opened without it.
Credential vault (Preview)
Keep the secrets your sandboxed agents need in a vault bound to the one host each may go to, so the agent sees only a placeholder. Preview.
Policy packs and admin controls
Pick the open, balanced, or strict OpenShell sandbox policy pack, write a custom pack, and set organization-wide limits with openshell.admin.