Developer & AI SecurityBy Stackwares Engineering · · 6 min read

Stop Putting API Keys in .env Files for AI Coding Agents

Key Takeaway

AI coding tools like Claude Code, Cursor, VS Code Copilot, Windsurf, and Codex routinely read workspace files, run terminal commands, and send context to remote LLMs. Leaving plaintext API keys in .env files turns a single prompt injection or accidental tool call into a credential leak. Liso's Apache-2.0 liso mcp server fixes this with scoped la1 agent tokens, human biometric/OS approvals, run_with_secrets output redaction, and cryptographic hard blocks on master keys.

1. Why plaintext .env files break down in the AI coding era

For years, local .env files were a tolerable convenience because only your own scripts read them. With AI coding agents running inside your repo, workspace files are indexed, grepped, summarized, and passed to shell tools automatically. Even when .env is in .gitignore, a single agent command like `cat .env` or `env` during debugging dumps production Stripe, Cloudflare, or database tokens straight into the LLM conversation transcript.

Worse, giving an AI agent a broad password-manager CLI session key (or an unscoped service token) lets a prompt-injected dependency read every personal login, 2FA seed, and production credential in your vault.

2. Three guardrails every AI agent secret workflow needs

Safe agent access requires three layered defenses working together: (1) **Cryptographic scoping** so the agent token can only see a narrow non-production vault, folder, or tag and cannot run general CLI export commands; (2) **Human-in-the-loop confirmation** outside the LLM context (biometric app prompt or native OS dialog) so a hijacked agent cannot silently approve its own reads; and (3) **Zero-exposure execution** so deploy and test scripts receive secrets via environment variables without the agent ever seeing the raw token string.

3. How liso mcp implements zero-exposure secrets in one command

Liso builds a 36-tool Model Context Protocol server directly into the Apache-2.0 `liso` CLI. Running `liso mcp setup --client claude-code --create-token --write` (also supporting `cursor`, `claude-desktop`, `vscode`, `windsurf`, and `codex`) creates a scoped profile, mints a dedicated `la1.<id>.<key>` token wrapped with XChaCha20-Poly1305 whose authenticated `kid` hashes the token ID, TTL, and profile policy, and writes your client config with 0600 permissions.

When the agent needs to run a command with secrets, it invokes `run_with_secrets` passing `liso://` references. Liso decrypts the values locally, spawns the binary directly via `argv` (never through a shell), strips `LISO_*` variables, and scrubs raw, base64, URL-encoded, JSON-escaped, and hex forms of every injected secret from stdout and stderr before returning output to the agent.

4. Hard blocks & instant local revocation

Even if a developer explicitly sets `--approval none` for sandboxed CI automation, `liso mcp` enforces multi-layer cryptographic hard blocks: tool inputs and outputs are screened for BIP-39 phrases matching your Recovery Auth key, Argon2id password slot matches, and encoded in-memory keys so your recovery phrase and master password can never leave the vault.

Every approved, denied, or blocked call is appended to a hash-chained local audit log (`liso mcp audit tail`) that never leaves your machine—and `liso lock` revokes every active session key and agent token immediately.

Explore further

Try Liso 2 free in your browser or self-host on Cloudflare

No email address required. Start free with unlimited passwords and a 14-day Premium trial, or deploy your own AGPL-3.0 Worker free.

More from the Liso Blog

Article FAQ

Direct answers to common questions raised in this post.

Does liso mcp require a paid Liso Cloud plan?

No. Both the liso CLI and the 36-tool liso mcp server are Apache-2.0 open source and included free on Liso Cloud Free, Self-Hosted, and This Device Only.

Can a malicious prompt run liso export using my agent token?

No. Standard CLI commands (liso get, liso export, liso run) reject la1.<id>.<key> agent tokens with exit code 8, and editing the profile policy file on disk invalidates the token's authenticated XChaCha20 kid.

What if the agent tries to base64-encode a secret and echo it back?

run_with_secrets automatically scans stdout and stderr for raw, base64, URL-encoded, JSON-escaped, and hex encodings of every injected secret and replaces them with [redacted] before the agent sees command output.