← Back to Portfolio

Agent Vault Architecture

A zero-knowledge blind file locker and browser-encrypted secret vault built specifically for AI-agent workflows — so agents can run authenticated scripts and decrypt archives without ever exposing plaintext secrets to the server or LLM context.

Browser KDF
PBKDF2 600k
Secret Envelope
AES-256-GCM
Agent Sessions
HKDF-SHA256
Archive Standard
.7z -mhe=on

How Agent Vault works end to end

Every decryption key stays inside your browser or your local CLI runner. The host acts strictly as a blind, hardened ciphertext relay.

Stage 1 · Browser Master Key

Client-Side Key Derivation & Envelope Wrapping

Your master passphrase never leaves the browser. WebCrypto derives a non-extractable AES-256-GCM master key via PBKDF2-HMAC-SHA256 (≥ 600,000 iterations, 16-byte salt), verified with an AAD-bound verifier (av-verifier-v1). Each secret set or file password receives its own random 32-byte key wrapped by the master key.

Stage 2 · HKDF Session Minting

Split Auth, Encryption & Write Keys

When delegating work to an AI agent, the browser mints an ephemeral sv_... token and derives three independent keys via HKDF-SHA256: an auth key (only its SHA-256 hash is stored on the server), an enc key (decrypts the session bundle locally), and an optional write key for inbox proposals.

Stage 3 · Child-Process Injection

vault_env.py Run & Auto-Decryption

Instead of pasting credentials into chat prompts, the agent runs vault_env.py run -- <command>. The CLI decrypts the bundle in memory, strips VAULT_SESSION_TOKEN from child env, and injects secrets straight into the target script—or downloads and decrypts .7z / WEV2 archives locally.

Stage 4 · Pending Inbox & Kill Switch

Human-Approved Writes & Logout Binding

Read/write sessions can encrypt new .env secrets back to the owner's Pending Inbox, never overwriting existing vault items automatically. Sessions honor fetch/write caps, expiration timers, allowed_paths, and kill_on_logout revocation.

Interface walkthrough: using Agent Vault day to day

Captured from an isolated local demo instance using synthetic keys and archives. No real deployment domains or credentials are ever exposed.

Step 1 · Blind File Locker

Upload client-encrypted archives

Encrypt backups or credential bundles locally with 7z a -p -mhe=on before dragging them into the locker. The server validates archive headers and stores opaque blobs without ever receiving the archive password.

Step 2 · Browser Master Key

Store .env sets & file passwords in RAM

Unlocking derives your PBKDF2 master key strictly in browser RAM. You can version .env secret sets alongside matching archive passwords while keeping every secret payload AES-256-GCM encrypted at rest.

Step 3 · Scoped Agent Sessions

Mint ephemeral sv_... tokens for AI agents

Pick exact readable items, allowed inbox names, TTL, fetch/write caps, and kill_on_logout. Copy the ready-to-run vault_env.py run -- <cmd> snippet so scripts get injected env vars without pasting keys into LLM prompts.

Step 4 · Pending Inbox Review

Inspect & approve agent writes before sealing

When an agent provisions a new service and runs vault_env.py write, ciphertext lands in Pending Inbox. You decrypt and inspect every line in the browser before clicking Approve & Seal.

Architecture Modules & CLI Reference

Explore the three core layers across the Flask + Waitress backend, WebCrypto UI, and local CLI tools.

Flask · Waitress · WebCrypto · Python

Client-Side Master Key & Per-Item Wrapping

Secrets are encrypted entirely inside the browser via WebCrypto before a single byte leaves the device. The server stores only ciphertext, salt, and an AAD-bound verifier.

Master KDF
PBKDF2-HMAC-SHA256 (>= 600,000 iterations, 16-byte random salt)
Item Encryption
Random 32-byte AES-256-GCM key wrapped per item (av-itemkey-v1)
Versioning
Retains 5 encrypted history snapshots with 1-click restore
Fail-Closed DB
0600 file-locked store with automatic .bak recovery & 503 guard
vault_env.py / crypto flow Zero-Knowledge
master = PBKDF2(passphrase, salt, 600_000)
item_k = GCM_Unwrap(master, wrapped_key)
secret = GCM_Decrypt(item_k, ciphertext)

Honest Threat Model & Hardening

Zero-knowledge is documented transparently without security theater — separating what server-blind cryptography guarantees from out-of-band client verification.

What It Protects Against

  • Leaked server disks, database snapshots, or backups (secrets.json holds only wrapped ciphertexts)
  • Accidental credential leaks into LLM prompt transcripts during autonomous CLI workflows
  • Weak archive uploads — rejects unencrypted ZIP entries, legacy ZipCrypto, and plain .7z headers
  • Concurrent config/session races via atomic file locking, compare-and-set rotation, and fsync uploads

Defense in Depth & Verification

  • Scoped API keys (read, write, admin) with zero access to /api/session/*
  • Single-use TOTP 2FA replay protection + 64-bit recovery codes + persisted rate limits
  • Rotating 0600 JSONL audit trail logging session events without secret values
  • Out-of-band CHECKSUMS.sha256 verification for local CLI & offline HTML tools

Request Agent Vault Source Code

Interested in running Agent Vault on your own infrastructure, reviewing the full test suite, or collaborating on zero-knowledge agent tooling? Send a quick note below.

Stack
Python 3 · Flask · Waitress · WebCrypto
Included Tools
vault_env.py · vault_crypto.py · vault-tool.html
Author
Shohanur Rahman (@Hacker-Shohan)

Expect a reply within one business day.