mcky.space
mcky.space

ตู้เซฟรหัส

vaultctl

A zero-knowledge, password-gated credentials vault that runs on your own box: everything encrypted at rest, one master password, nothing leaving the machine.

AES-256-GCM PBKDF2 600k go cli + flask service MIT

Repository The other tool: mem

ปัญหาที่แก้ · the problem

Keys end up in the worst places

Secrets spread: a .env per project, tokens in shell history, a password in a note the agent can read. Hosted secret managers solve it by asking for an account, a bill and trust in someone else's infrastructure.

vaultctl takes the other path. It is a small Flask service that encrypts everything with a key derived from one master password, keeps that key in memory only while unlocked, and answers on loopback. The threat model is stated plainly: the machine is yours, the password is yours, and if you lose the password the data is gone.

how it works

One password in, one encrypted file out

key derivation and storage

master password ──▶ PBKDF2-HMAC-SHA256 (600,000 iterations) ──▶ 32-byte key
key + value     ──▶ AES-256-GCM (fresh random 12-byte nonce)   ──▶ credentials.enc (0600)
Properties
Key derivation PBKDF2-HMAC-SHA256, 600,000 iterations, per-vault salt
Encryption AES-256-GCM, a fresh random nonce for every value
At rest credentials.enc, mode 0600, useless without the password
Sessions HttpOnly cookie plus a CSRF token, 30-minute idle expiry
Brute force Exponentially increasing delay after a wrong password
Dependencies Service: Python 3, Flask, cryptography. CLI + TUI: one static Go binary

The derived key lives in process memory and nowhere else. Restart the service, or run vaultctl lock, and every session is gone; unlocking again re-derives the key from the password.

three ways in

A UI for humans, a CLI for everything else

web ui · go cli · terminal dashboard

vaultctl list                          # entry names only
vaultctl get NOUS_API_KEY              # print to stdout (trusted shells only)
vaultctl set MY_TOKEN                  # masked prompt, keeps it out of shell history
vaultctl copy NOUS_API_KEY             # clipboard over OSC52 (works over SSH)
vaultctl audit 50                      # last 50 decisions, never values
vaultctl ui                            # terminal dashboard

Output adapts to where it goes: a terminal gets the styled interface, a pipe gets plain text or JSON. list prints one name per line when redirected, status prints JSON, and --json forces machine output on any command.

safe consumption

The agent uses the key, it never sees it

vaultctl get prints a value to stdout, which means it lands in your terminal, the transcript, and any log that captures output. vaultctl exec is the safer path: it resolves the value internally, injects it into the child process environment, and masks every occurrence (and any fragment of six characters or more) in the child's stdout and stderr.

vaultctl exec NOUS_API_KEY -- my-tool --auth          # env name defaults to the entry name
vaultctl exec NOUS_API_KEY --env AUTH_TOKEN -- my-tool # or pick the variable
vaultctl exec NOUS_API_KEY -- python3 -c 'import os; print(len(os.environ["NOUS_API_KEY"]))'

The child's exit code is propagated, so exec composes like a normal command. This is the piece that makes the vault useful to an agent: a tool can be handed a credential without the credential ever entering the conversation.

audit trail

A record of access, never a record of secrets

Every unlock, list, get, set and delete is appended to data/audit.jsonl (mode 0600) as one JSON object per line. The log records the decision and the reason, so a failed attempt is visible without the value behind it being visible at all.

{"ts":"2026-10-28T04:48:56Z","action":"get","name":"NOUS_API_KEY","decision":"allow","reason":"ok","remote":"127.0.0.1"}
{"ts":"2026-10-28T04:51:02Z","action":"get","name":"DEPLOY_KEY","decision":"deny","reason":"locked","remote":"127.0.0.1"}

http api

The whole surface

base url http://127.0.0.1:8787

Endpoint Method Purpose
/api/statusGETinit and unlock state
/api/setupPOSTfirst-time master password
/api/unlockPOSTopen a session, returns the CSRF token
/api/lockPOSTclose the session
/api/entriesGETlist entry names
/api/entries/<name>GETread one value
/api/entriesPOSTcreate or update
/api/entries/<name>DELETEremove one
/api/change-passwordPOSTrotate the master password
/api/auditGETlast N audit records

development

Build against a mock, not against your secrets

The repository is the dev tree, not the live service. Run ./run.sh with no flags and you get a mock vault: in memory, seeded with fake entries, any password unlocks it, but the same HTTP surface. Point VAULT_URL at it and every consumer keeps working.

./run.sh                    # mock vault (default) on 127.0.0.1:8787
VAULT_PORT=9787 ./run.sh    # mock on another port
VAULT_REAL=1 ./run.sh       # the real encrypted vault

ข้อจํากัด · known limits

What it will not do