Verified 2026-12-03 · AI Agent Security Guide · Claude Code + MCP
How to Give Claude Code Access to Secrets Safely (Without .env Files)
Pasting API keys into plaintext .env files or Claude Code's chat context exposes production credentials to prompt injection, git leaks, and cloud conversation logs. With liso mcp, you configure Claude Code in one command using a scoped la1.<id>.<key> agent token restricted to specific vaults or folders, require human biometric/OS approval before secret reads, inject keys directly into child processes via run_with_secrets (with automatic stdout/stderr redaction), and hard-block your recovery phrase and master password at the cryptographic layer.
Step-by-step setup (5 steps)
Install the liso CLI and unlock a session
Install the signed Apache-2.0 liso binary, sign in via QR pairing (liso login --qr) or your 12-word recovery phrase, and export a time-limited session key (12h max / 2h idle default).
# Install liso CLI (verifies SHA-256 and optional Sigstore cosign)
curl -fsSLO https://raw.githubusercontent.com/Liso-Vault/liso/main/dart/cli/install/install.sh
bash install.sh --require-cosign
# Pair with your unlocked Liso app and start a local session
liso login --qr
export LISO_SESSION="$(liso unlock --raw)"Create a least-privilege profile for Claude Code
Scope Claude Code strictly to a non-production vault, folder, or tag—and enable --exec so Claude can run commands with injected secrets without reading raw values into context.
# Restrict Claude Code to the "Staging" folder in your "Work" vault
liso mcp profile add claude-dev \
--vault Work \
--folder Staging \
--exec \
--approval first-use \
--ttl 12hWrite Claude Code's MCP config automatically
Run liso mcp setup to mint a cryptographically bound la1.<id>.<key> token for that profile, back up ~/.claude.json, and merge the liso MCP server entry with private 0600 file permissions.
liso mcp setup \
--client claude-code \
--profile claude-dev \
--create-token \
--writeLink desktop biometric approvals and run doctor
Optionally link the Liso desktop app over HMAC-SHA256 local IPC for Touch ID / biometric confirmations (otherwise Liso falls back to a native macOS/Linux/Windows OS dialog), then verify with liso mcp doctor.
# Route approvals to the Liso desktop app (optional; native OS dialog works out of the box)
liso mcp link-app
# Verify account, token validity, approver health, and ~/.claude.json wiring
liso mcp doctorUse run_with_secrets and audit every call locally
Ask Claude Code to execute deploy or test commands via run_with_secrets with liso:// references so credentials never enter the LLM transcript, and inspect the hash-chained local audit log anytime.
# Tail the hash-chained local audit log (never uploaded to any server)
liso mcp audit tail
# Immediately revoke every active session key and agent token on this machine
liso lockSecurity model & threat defenses
| Threat / Scenario | How Liso 2 mitigates it |
|---|---|
| Prompt injection asks Claude for your recovery phrase | Hard-blocked in every mode (even --approval none): arguments, labels, BIP-39 checksums against your Recovery Auth key, Argon2id password slot, and encoded in-memory keys are all blocked before output. |
| Agent prints an injected API key to stdout/stderr | run_with_secrets injects liso:// secrets into argv (no shell), strips LISO_* env vars, and redacts raw, base64, URL-encoded, JSON-escaped, and hex forms of every secret from command output. |
| Compromised script tries to run liso export with the agent token | Normal CLI commands reject la1.<id>.<key> tokens with exit code 8. Editing the profile policy on disk invalidates the token's authenticated XChaCha20 kid hash. |
| Agent probes for secrets in your personal or finance vaults | Items outside the profile's --vault / --folder / --tag scope return identical not-found responses so the agent cannot enumerate restricted vaults. |