Local dev survives a plaintext .env.local on a laptop nobody else touches
and no key-management layer. A deployed service does not: the process
environment, the image, and (if anyone ever runs git add -A in this tree)
the repo history all become plausible leak paths for a real-money Hyperliquid
key. This doc is the inventory + the containment story + the rotation
runbook. scripts/preflight_secrets.py is the machine-checked version of the
same rules — run it before every deploy and every restart of a deployed
service:
.venv/bin/python scripts/preflight_secrets.py # local check
.venv/bin/python scripts/preflight_secrets.py --deploy # simulate deploy-mode checks locallyIt prints findings by NAME, never by VALUE, and exits non-zero if anything is wrong. Wire it into the deploy pipeline as a hard gate (see Wire it into CI/CD below) — this doc explains why each check exists; the script is what actually enforces it.
| Var | Purpose | Reads it | Required | Missing behavior |
|---|---|---|---|---|
HYPERLIQUID_WALLET_ADDRESS |
Agent/API wallet address — the identity that signs orders | pathiel/client/exchange.py, pathiel/client/hl_client.py |
Always | Silent — defaults to ""; downstream calls that need a real address fail deep in the SDK, not at startup |
HYPERLIQUID_PRIVATE_KEY |
Agent/API wallet private key — signs every order | pathiel/client/exchange.py (the signer every order routes through — pathiel/agents/bracket.py's place_bracket/close_position and the MCP server call it the same way the now-deleted autonomous executor and trading loop used to, before both were deleted 2026-10-23, wave 2) |
Always | exchange.py itself just holds "" when unset — an actual sign attempt blows up in the SDK, not at startup. The dedicated {"executed": False, "reason": "private_key_missing"} loud-refusal check was the retired executor's own and went with it; not re-verified for bracket.py's path, which is a real gap this doc update did not close |
HYPERLIQUID_MASTER_ADDRESS |
Master account public address — where funds actually live | pathiel/client/exchange.py, pathiel/client/hl_client.py, scripts/treasury.py |
Always (for the agent-vs-master safety check — see below) | Silent — exchange.py's IS_AGENT flag quietly becomes False and the trading identity falls back to the wallet address alone. The app tolerates this; the preflight check does not |
HYPERLIQUID_MASTER_PRIVATE_KEY |
Master account private key — signs treasury transfers/swaps ONLY | scripts/treasury.py (nowhere else) |
Local-only — must never exist in a deployed environment | Loud: treasury.py prints an error and sys.exit(2) |
HYPERLIQUID_VPS_PRIVATE_KEY, HYPERLIQUID_VPS_WALLET_ADDRESS |
The rented server's own API wallet (trade only, no withdrawals), kept in the Mac's .env.local |
scripts/vps/make_server_env.py only. Nothing on the Mac signs with it; on the server it becomes HYPERLIQUID_PRIVATE_KEY / HYPERLIQUID_WALLET_ADDRESS, and the VPS_ names are dropped |
Optional (only for scripts/vps/push.sh) |
make_server_env.py falls back to a hidden prompt. A key that does not derive to the address is refused. Rotate: revoke on Hyperliquid (More → API) after the trip |
Wallet sign-in (EIP-4361) holds no secret at all, which is the point. There
is no password, no API key and no third-party vendor: eth-account is already a
dependency because it signs the Hyperliquid orders, and recovering a signer is
the same primitive.
| var | Purpose | Required |
|---|---|---|
PATHIEL_AUTH_DOMAIN |
The host that must appear inside the signed message. Never taken from the request's Host header, which an attacker controls | Yes in production |
PATHIEL_AUTH_URI / PATHIEL_AUTH_CHAIN_ID |
Cosmetic fields the wallet shows. Chain defaults to HyperEVM (999) | No |
PATHIEL_AUTH_DB |
Where users and sessions live. Defaults to $PATHIEL_STATE_DIR/auth.db |
No |
PATHIEL_PUBLIC_DASHBOARD |
1 reopens the account routes for a private single-operator box |
No |
See docs/security/SUPPLY_CHAIN_2026-10-25.md for why each exists.
| var | Purpose | Default |
|---|---|---|
PATHIEL_METRICS_TOKEN |
Secret. When set, /metrics requires Authorization: Bearer <token>. Set it on any internet-facing deploy (the k8s Secret); k8s/servicemonitor.yaml shows the scraper side |
unset: /metrics open |
PATHIEL_CORS_ORIGINS |
Comma-separated exact origins allowed to read the API cross-site. * is refused |
unset: no CORS headers, same-origin only |
PATHIEL_API_DOCS |
1 re-enables /docs, /redoc, /openapi.json on a deployment |
on locally, off on any deployment |
PATHIEL_MAX_BODY_BYTES |
Request-body ceiling; larger bodies get 413 | 1048576 (1 MiB) |
PATHIEL_LOCAL_HOSTNAMES |
Extra Host names local mode accepts besides localhost / 127.0.0.1 / ::1 (the DNS-rebinding check) | none |
PATHIEL_TRUST_FORWARDED_FOR |
1 makes rate limits key on the rightmost X-Forwarded-For entry off a deployment (behind your own proxy). Deployments do this already |
unset |
What is stored, and what deliberately is not: session tokens and login nonces
are persisted as SHA-256 only, never the value the client holds. A leaked
database file — a backup on a laptop, a snapshot in object storage — is not a
set of live sessions. Customer API keys for services/pathiel_data_api follow
the same rule, which is why "show me my key again" cannot be built.
If the wrong wallet claims the operator role (the first to sign in wins on a
fresh box), scripts/grant_operator.py is the way back — no database surgery.
Non-secret vars read alongside these (model names, timeouts, CLI binary
paths, scan-tuning knobs, state-file path overrides) are listed — grouped and
commented — in .env.local.example. They don't belong in this table because
leaking one costs nothing; the table above is specifically the set that
scripts/preflight_secrets.py treats as sensitive (required-presence check,
git-index scan, redaction).
One dead var found during this inventory: PATHIEL_CHAT_MODEL is set in
the live .env.local but is not read by any module in pathiel/,
services/, or scripts/ — grep across all three came up empty. Likely a
leftover from an earlier iteration. Safe to drop; harmless to leave (it is
not a secret, just an unused knob).
Never put a real value in a Dockerfile ENV line, a k8s ConfigMap, or
any tracked file — only in the platform's secret store, injected as process
environment variables at runtime. (Fly.io was dropped as a deploy target on
2026-10-25; Kubernetes is the one container target, see DEPLOY.md.)
Create the Secret straight from the operator's gitignored .env.local so
values never touch a tracked file:
kubectl create secret generic pathiel-secrets -n pathiel \
--from-literal=HYPERLIQUID_WALLET_ADDRESS="$HYPERLIQUID_WALLET_ADDRESS" \
--from-literal=HYPERLIQUID_PRIVATE_KEY="$HYPERLIQUID_PRIVATE_KEY" \
--from-literal=HYPERLIQUID_MASTER_ADDRESS="$HYPERLIQUID_MASTER_ADDRESS" \kubectl get secret pathiel-secrets -o yaml shows base64, not plaintext, but
base64 is encoding, not encryption — treat kubectl get -o yaml access on
that namespace as equivalent to reading the values directly when reasoning
about who can see secrets.
Set via the unit's Environment=/EnvironmentFile= pointed at a file with
0600 permissions and not under the app's working directory (so a
misconfigured static file server, backup job, or tar czf . can't sweep it
in). scripts/preflight_secrets.py's permission and gitignore checks apply
the same way to this file as to .env.local — point --env-file at it and
run the same command.
This is the single highest-value control in this document, and the one
scripts/preflight_secrets.py treats as a hard gate
(check_master_not_agent).
Hyperliquid supports two distinct keys per account:
- Master key — full control: trade, transfer, withdraw. This is the key behind your actual wallet/private key if you never set anything else up.
- Agent (API) wallet key — a separate keypair, approved on-chain by the
master account (
approveAgent), that can place and cancel orders but cannot withdraw or transfer funds. Hyperliquid's UI calls this "API wallet" under More → API.
The bot should trade with the agent key, full stop. Set:
HYPERLIQUID_WALLET_ADDRESS=<agent wallet address>
HYPERLIQUID_PRIVATE_KEY=<agent wallet private key>
HYPERLIQUID_MASTER_ADDRESS=<master account address> # public, not a secretWhy this is the boundary that matters: every other secret in this file, if
leaked, costs research quality (an API key someone else can spend against
your quota) or trading privacy (someone can see what the bot would have
done). A leaked agent private key costs the positions currently open —
real, but bounded, and rate-limited by however fast a thief can flatten and
re-open in the wrong direction before the bot or the operator notices. A
leaked master key costs everything the account holds, gone in one
transaction, with no bound. That asymmetry is why
check_master_not_agent() fails the preflight outright — not warns — when
HYPERLIQUID_WALLET_ADDRESS equals HYPERLIQUID_MASTER_ADDRESS, and why it
also fails when HYPERLIQUID_MASTER_ADDRESS is simply unset: an unset master
address means there's no way to prove the trading key isn't the master, and
"unprovable" gets treated as "unsafe" for a deploy gate, even though the app
itself tolerates it at runtime.
HYPERLIQUID_MASTER_PRIVATE_KEY is the one secret in this repo that can
actually withdraw. It exists purely for scripts/treasury.py — moving USDC
between spot/perp/HIP-3 dexes, a manual operation the operator runs by hand.
It has no business in any deployed process's environment: the trading loop
and the dashboard never read it, and since 2026-11-15 no shared loader puts
it in their environment: scripts/_state_env.WITHDRAW_KEYS is skipped unless
a script passes allow_withdraw_keys=True (approve_api_wallet.py,
approve_builder_fee.py; treasury.py has its own loader). All three take it
at a hidden prompt when it is not in the file, so the safest place for it is a
password manager, not .env.local. scripts/preflight_secrets.py warns if it's
present locally and fails if it detects a deploy context (FLY_APP_NAME
or KUBERNETES_SERVICE_HOST set) and finds it anyway.
The master key (HYPERLIQUID_MASTER_PRIVATE_KEY) is the one key that can
withdraw. No long-running pathiel process loads it, but while it sits in
.env.local anything that can read that file can read it. The macOS
Keychain is built in and free: the key is encrypted at rest, and macOS asks
before a program reads it.
scripts/master_key_to_keychain.py does steps 1 to 3 in one run (store,
read back and compare, then remove the line), printing no key. By hand:
-
Store it. With
-wlast,securityprompts for the value, so it never lands on the command line or in shell history. Paste the key, then paste it again to confirm:security add-generic-password -a "$USER" -s pathiel-master-key -w -
Check it is there. This prints the item's details, not the key:
security find-generic-password -a "$USER" -s pathiel-master-key -
Delete the
HYPERLIQUID_MASTER_PRIVATE_KEY=line from.env.localand save. -
Use it for one command. The key goes into that one process's environment and nowhere else; the shell history keeps the command, not the key. The first time, macOS asks whether
securitymay read the item: Allow asks again next time, Always Allow stops asking.HYPERLIQUID_MASTER_PRIVATE_KEY="$(security find-generic-password -a "$USER" -s pathiel-master-key -w)" \ .venv/bin/python scripts/treasury.py move --from spot --to xyz --amount 50treasury.py statusonly reads balances and needs no key.The same works for
scripts/approve_api_wallet.pyandscripts/approve_builder_fee.py. Or run any of the three without it and paste the key at their hidden prompt. -
Remove it when the wallet is retired:
security delete-generic-password -a "$USER" -s pathiel-master-key
The item shows in the Keychain Access app under the login keychain, named
pathiel-master-key. Every command above was run on macOS 15 with a dummy
item on 2026-11-16.
General shape for every credential below: generate/rotate at the provider, update the deploy secret store, redeploy (or restart, if the process re-reads env on the fly — none of these currently do; a restart is required), then revoke the old value at the provider once the new one is confirmed live.
| Secret | Rotate at | Redeploy needed | If it leaked |
|---|---|---|---|
HYPERLIQUID_PRIVATE_KEY |
Hyperliquid UI → More → API → revoke the old agent wallet, create a new one, approveAgent it |
Yes | Revoke the agent wallet in the Hyperliquid UI immediately (this alone stops it — an agent key cannot withdraw, so the blast radius is bounded to open positions). Flatten any open positions if you don't trust what a thief might have done with the window. Generate + wire a new agent wallet. The master funds were never exposed. |
HYPERLIQUID_WALLET_ADDRESS |
Follows the private key above (they're a pair) | Yes | Not a secret by itself (a public address) — rotate alongside the private key |
HYPERLIQUID_MASTER_ADDRESS |
This is your actual account; you don't "rotate" it. If it needs to change, you're moving to a different Hyperliquid account entirely — treat as a full re-provision | Yes | Not a secret (public address) — no action needed on its own, but if leaked alongside the master private key, see below |
HYPERLIQUID_MASTER_PRIVATE_KEY |
Hyperliquid does not support rotating a master wallet's key — it's an on-chain wallet, so "rotation" means moving funds to a new wallet | N/A (local-only, never deployed) | Treat as a full account compromise. Move all funds to a brand-new wallet immediately via the Hyperliquid UI from a separate trusted device if possible, then stop using the old wallet entirely. This is the one leak this doc cannot make routine — it is the master key, it can empty the account, and speed is the only mitigation. |
After rotating anything that touched a tracked file (it shouldn't have, but
if scripts/preflight_secrets.py's git-index scan ever fires): rotating the
credential is necessary but not sufficient — the old value is still in git
history. git filter-repo or BFG Repo-Cleaner to purge it, then force-push
with the team's explicit sign-off (never unilaterally force-push shared
history).
Run the preflight as the last step before a deploy actually starts serving traffic — it's deterministic and offline, so it costs nothing to run on every deploy:
.venv/bin/python scripts/preflight_secrets.py --deploy || exit 1--deploy forces the deploy-mode checks (currently just
HYPERLIQUID_MASTER_PRIVATE_KEY absence) even when run from a CI runner that
doesn't carry the k8s platform env var itself. In the actual pod
KUBERNETES_SERVICE_HOST is set automatically and --deploy isn't needed —
running the bare command is enough.