DEV Community

CJDARKLORD
CJDARKLORD

Posted on Originally published at tenlux.tech

AI agents ask for passwords. I made sure they never see them

AI agents ask for passwords. I made sure they never see them

How to give an AI agent access to secrets without leaking them. Based on a real product: TenVault 1.0 / AgentVault (Windows, Rust + Tauri).

The problem that arrived quietly

A year ago an "AI agent" was a toy: it wrote code and sometimes hallucinated. Today agents (Claude Desktop, Cursor, VS Code extensions, custom bots) work on real projects — which means they need keys and passwords: OpenAI, Stripe, databases, staging environments.

The usual workarounds are bad:

  1. .env in the project. The agent reads it. Best case it does not decide to "improve" the config or paste it into a 100k-token context.
  2. Copy the key into a prompt. It lands in logs, chat history and the provider's cache. Game over.
  3. A cloud secrets manager. Overkill for a personal project, and in some countries a data-residency and payment question.
  4. Do nothing. The agent simply cannot work with real secrets, and you paste keys manually every time.

I wanted a third way: secrets stay local, the agent gets them only with my consent and only for a while. That is how AgentVault appeared — the "Agents" tab inside my password manager TenVault.

What a regular MCP setup gets wrong

MCP (Model Context Protocol) is the standard that connects tools to models. There are already servers that serve secrets from Vault/1Password/Bitwarden. Typical flow:

Agent  ->  MCP server  ->  vault API (with a master token)  ->  secret
Enter fullscreen mode Exit fullscreen mode

The problem: the MCP server usually holds full access. If it is compromised (or prompt-injected), the agent gets everything the token allows, without you noticing.

What I wanted instead:

  • the agent sees only the names of the records you explicitly shared;
  • the value is released after your approval in the UI, not on request;
  • access is a lease with a TTL (one hour by default), not a permanent grant;
  • everything is written to an audit log you can read;
  • the master password is never passed to the agent and never sits in an env variable.

How it works

Components:

  1. TenVault desktop — a Rust password manager (XChaCha20-Poly1305 + SQLCipher), GUI as a local HTTP server, tray icon.
  2. tenvault-mcp — an MCP server (stdio JSON-RPC). It talks to the running app over a local bridge (HTTP + token file), not through the master password.
  3. Agents tab — approvals, leases, limits, policies, audit.
  4. Encrypted audit — a separate file, key derived from user + machine + vault path.

Request flow:

Agent (MCP) --get_secret--> tenvault-mcp
                              |
                   local bridge (HTTP, token)
                              v
                        TenVault GUI
                              |
                  banner "Agent requests a secret..."
                              |
                 [Allow for 1 hour] [Deny]
                              |
                    lease (TTL) ----> value to agent
                              |
                      encrypted audit log
Enter fullscreen mode Exit fullscreen mode

Key decisions:

  • MCP never knows the master password. It gets a bridge token from the running app. No app — no access (or an explicit "agent key" you can create and revoke).
  • Per-record granularity. A record has an "Available to agents" flag. Only those records appear in list_secrets.
  • Categories. Policies: API keys allowed, website passwords denied, records with notes separate.
  • Leases. A grant lives for a TTL (3600 seconds), the number of leases per record is limited (3), and "revoke all leases" is one click.
  • Limits. A daily request limit per agent; after exceeding it — denial and an audit entry. A denial starts a 10-minute cooldown to prevent request spam.
  • Process checks. off/warn/strict: in strict mode the agent only gets access if its parent process is on the allowlist (e.g. cursor.exe).

Setup, in practice

  1. Install TenVault (no admin rights needed).
  2. Optionally generate an "agent key" if the MCP server must work while the vault is locked.
  3. Point your client at the MCP server:
{
  "mcpServers": {
    "tenvault": {
      "command": "C:\\Users\\you\\AppData\\Local\\Programs\\TenVault\\tenvault-mcp.exe",
      "args": ["--vault", "C:\\Users\\you\\AppData\\Roaming\\TenVault\\vault.json"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode
  1. The agent calls get_secret("STRIPE_SECRET") and receives -32003 confirmation required until you press Allow.
  2. Then the agent repeats the call and receives the value, under a lease.
  3. Everything lands in the audit log: who asked, when, what, and how it ended.

What is actually protected — and what is not

Protected:

  • secret values never leave the machine;
  • the agent sees only shared records;
  • nothing is released without approval (or an explicit auto-grant);
  • access is time- and count-limited;
  • the audit is encrypted and accessible only to the user.

Not protected (being honest):

  • if the agent is compromised and already has the value, it can use it until the lease expires;
  • prompt injection can make the agent ask for a secret — but it still needs your approval;
  • unsigned Windows binary: SmartScreen complains (code signing is planned);
  • no mobile approvals yet (in progress); meanwhile Telegram/VK notifications with buttons.

It is not a silver bullet — it is surface reduction: the agent has no standing access, and you have a log.

Implementation notes

  • Rust for the core and the local GUI server: small binary, no C dependencies.
  • Tauri + WebView2 for the window: the UI is plain HTML over a local server (easy to test).
  • SQLCipher for the database, XChaCha20-Poly1305 for fields.
  • A custom NSIS installer (the Tauri bundler had to be bypassed), per-user install, start menu shortcut, clean uninstall.
  • Updates: download exe → verify SHA256 → install or swap → restart; rollback keeps the previous installer.
  • Notifications: local toast + sound; Telegram through a small PHP relay on our domain (in some regions api.telegram.org is not directly reachable), with Allow/Deny buttons right in the message.

What is next

  • mobile approvals (the Android app exists; an "Agents" screen is being added);
  • ready-to-use configs for Claude Desktop and Cursor;
  • code signing and macOS (when resources allow);
  • more integrations: custom MCP clients, CI secrets.

Links

How do you give secrets to your agents: .env, a password manager, cloud, or manually? Tell us in the comments.

Top comments (0)