OpenClaw Credential Vault
Encrypted credential management for OpenClaw. Keeps API keys, tokens, and passwords out of the AI agent's context window — where they could be exfiltrated, leaked into transcripts, or exposed through tool output.
What You Get
- Credentials never enter the AI's context. Decrypted and injected only into the specific subprocess that needs them, then scrubbed from output before the agent sees it.
- Encryption at rest. Each credential individually encrypted with AES-256-GCM, Argon2id key derivation.
- Automatic output scrubbing. Multiple independent scrubbing layers catch credentials in tool output, outbound messages, and session transcripts.
- ~700 tests across 36 files covering crypto, injection, scrubbing, adversarial attacks, and end-to-end scenarios.
- Open source. Full source code at GitHub — review hook/injection/scrubbing implementation before installing.
Storage and File Access
The vault stores all data under ~/.openclaw/vault/:
~/.openclaw/vault/*.enc— Individual encrypted credential files (AES-256-GCM, one per tool). File permissions are set to owner-only (600).~/.openclaw/vault/tools.yaml— Injection rules mapping tools to credentials (which command patterns trigger which credential injection, which URL patterns get auth headers).~/.openclaw/vault/.vault-meta.json— Vault metadata (initialization timestamp, version).~/.openclaw/vault/audit.log— Credential access audit log.
No environment variables are required. The vault derives its encryption key from the system and does not store keys in env vars or config files.
Install
Install the plugin via npm:
npm install -g openclaw-credential-vault
Then restart the gateway to load the plugin. The plugin registers four OpenClaw hooks:
before_exec— Injects credentials into subprocess environment for matching commandsafter_exec— Scrubs credential patt[VAULT:gmail-app]utbefore_send— Scrubs credentials from outbound messagessession_transcript— Scrubs credentials from session transcripts
To review the hook implementations before installing, see src/hooks/ in the GitHub repository.
Quick Start
# Initialize the vault
openclaw vault init
# Add a credential (interactive — picks the right injection type)
openclaw vault add github --key "ghp_your_token_here"
# Verify it works end-to-end (injection + scrubbing)
openclaw vault test github
# Add more
openclaw vault add stripe --key "sk_live_..."
openclaw vault add npm --key "npm_..."
That's it. Your agent can now use gh, call Stripe APIs, and publish npm packages without ever seeing the credentials.
How It Works
When the agent runs a tool like gh pr list:
- before_exec hook matches
ghagainsttools.yamlinjection rules - Decrypts
~/.openclaw/vault/github.encusing the derived key - Injects the token as
GITHUB_TOKENinto the subprocess environment only ghruns with the credential, returns results- The subprocess exits — the credential dies with it
- after_exec hook scrubs output for any credential patterns before the agent sees it
- The agent gets clean results — no credential anywhere in context
For API calls, the before_exec hook injects Authorization headers into matching URL patterns (configured in tools.yaml).
Commands
vault init— Initialize vault and create~/.openclaw/vault/directoryvault add <tool> --key <cred>— Add a credential (interactive usage selection: API, CLI)vault list— Show all stored credentials and statusvault show <tool>— Show credential details and injection configvault test <tool>— Verify injection and scrubbing work end-to-endvault rotate <tool> --key <new>— Rotate a credential (re-encrypts in place)vault rotate --check— Show credentials overdue for rotationvault remove <tool>— Remove credential file and injection rules
Non-Interactive Mode
# API header injection
openclaw vault add stripe --key "sk_live_..." --use api --url "api.stripe.com/*" --yes
# CLI env injection
openclaw vault add github --key "ghp_..." --use cli --command gh --env GITHUB_TOKEN --yes
Security Model
- Agent never sees credentials — injection happens in
before_exechook, not in the agent's context - Encryption at rest — AES-256-GCM with per-credential salts, stored in
~/.openclaw/vault/*.enc - Key derivation — Argon2id (memory-hard, resistant to GPU cracking)
- Subprocess isolation — credentials exist only in the child process environment, die when it exits
- Output scrubbing — 4 independent hooks (
after_exec,before_send,session_transcript, plus pattern-based fallback) catch credential leaks - Audit logging — all credential access logged to
~/.openclaw/vault/audit.log - Open source — full source code and 700-test suite available for review at GitHub
