Security model
ApiVault is built for developers who read the security model. This page covers encryption, authentication, session management, and best practices across all integration surfaces.
Encryption
All API key values are encrypted at rest before storage. ApiVault supports two encryption modes, configured in Settings → Encryption Key.
Default mode
Secrets are encrypted using server-managed keys. No passphrase is required to reveal keys — your authenticated session (or CLI/MCP token with appropriate scope) is sufficient.
Custom mode
You set a personal vault passphrase (vault key) that ApiVault never stores. Secrets are encrypted with a key derived from your passphrase. Decrypt operations require the passphrase via:
- Web UI vault key prompt
- CLI:
--key,APIVAULT_KEY, configvaultKey, or interactive prompt - MCP:
vault_keyparameter onreveal_key,add_key,update_key
You can switch between modes, change your vault key, or disable custom encryption from the encryption settings page. Changing or disabling custom encryption requires your current vault passphrase and re-encrypts existing keys.
Authentication
The web app supports multiple authentication methods:
| Method | Description |
|---|---|
| Google OAuth | Sign in with your Google account. Manage linked accounts in Settings → OAuth Connections. |
| Email & password | Traditional credentials. Set or change password in Settings → Security & MFA. |
| Passkeys | WebAuthn passkeys for passwordless sign-in (Touch ID, Face ID, Windows Hello, hardware keys). |
| TOTP 2FA | Time-based one-time passwords via an authenticator app. Can be required after initial setup. |
Passkeys can also serve as a second factor when MFA is enabled.
Sessions & tokens
ApiVault uses three independent credential types. Revoking one does not affect the others:
| Credential | Used by | Revoke via |
|---|---|---|
| Browser session | Web dashboard, settings | Settings → Sessions & Devices, or sign out |
| CLI token | apivault commands | apivault logout or Settings → Sessions & Devices |
| MCP OAuth token | Cursor, Claude, MCP clients | Settings → MCP Connections |
CLI security
- Browser-based pairing — CLI auth uses a one-time browser approval flow. No passwords are typed in the terminal.
- Local token storage — tokens are stored in
~/.apivault/token.jsonwith owner-only permissions on Unix. - Dotenv isolation —
apivault runtemporarily hides local.envfiles so injected vault secrets take precedence. - No secrets in shell history — prefer
config set vaultKey(hidden prompt) orAPIVAULT_KEYover typing passphrases inline.
apivault run to inject secrets into a process instead of writing decrypted values to a .env file on disk. Fewer files means fewer leak paths.MCP security
- Scoped OAuth — agents receive only the permissions you approve (
keys:read,keys:write,keys:reveal). - Least privilege — grant read-only scopes when agents only need to browse keys; avoid
keys:revealunless necessary. - Short-lived access tokens — MCP access tokens expire after 1 hour; refresh tokens last 30 days.
- Revocable connections — each MCP client appears separately in Settings → MCP Connections.
keys:reveal scope lets an agent read raw secret values. Only grant it when the agent truly needs plaintext keys, and revoke the connection when the task is done.See MCP Integration → Security practices for agent workflow guidance.
Best practices
- Never commit
~/.apivault/, exported.envfiles, tokens, or vault passphrases - Add
.envand.env.localto.gitignore - Use custom encryption mode for an extra layer of zero-knowledge protection
- Enable 2FA and passkeys on your account
- Review and revoke stale CLI and MCP connections periodically
- Use
apivault runinstead of exporting secrets to disk when possible - Do not paste raw secrets into chat, commits, logs, or issue trackers
- Request minimum MCP scopes for AI agents
.env, .env.local, and any exported dotenv files to .gitignore before your first commit. A single accidental push exposes every key in that file permanently in git history.Data storage
ApiVault stores encrypted key values, metadata (name, service, environment, notes), and account data in a MySQL database via Prisma. Secret values are never stored in plaintext. The CLI and MCP server communicate with ApiVault over HTTPS only — they never access the database directly.