security: keep signing keys out of deployable team vaults (CLI 0.13.0) (#264)
Some checks are pending
CI / build (push) Waiting to run
Deploy to dev2 / deploy (push) Waiting to run
test / test (push) Waiting to run

* security: keep signing keys out of deployable team vaults (CLI 0.13.0)

After the 2026-10-27 dev2 incident, root on the box drained every wallet
whose key sat in an app.env, and deploys write app.env from team vaults.
Wallet keys, seed phrases, hsm secrets and SSH/deploy keys now stay out of
that path:

- server: a machine (deploy) key never receives a signing key from
  GET /vaults/:id/secrets (listed as `withheld`, audited as
  secrets:withheld:signing) and cannot write or delete one (403
  signing_key_machine_write). People still see them, so they can move them.
- CLI `teams push` refuses a .env holding signing keys, by name or by value
  shape (PEM private key, 0x-hex, Solana base58/byte array, mnemonic), unless
  --allow-signing-keys.
- CLI `teams pull` withholds signing keys by default; --include-signing-keys
  needs a person at a terminal, so deploy-app.sh's fallback to the logged-in
  account withholds them too.
- One name rule in packages/opencreds/src/signing-keys.ts, mirrored in
  apps/pwa/src/lib/signing-keys.mjs, both held to one fixture file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: bound the wallet-name regex, build PEM fixtures at runtime

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Anthony Ettinger <anthony@profullstack.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sh1pt-actions-fleet[bot] 2026-10-28 19:31:28 +00:00 • committed by GitHub
parent 1bff3e975c
commit b5f875837a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 297 additions and 12 deletions

View file

@ -18,6 +18,7 @@ import { id, sha256, token } from "../lib/crypto.mjs";
import { keyFingerprint, requestOriginInfo } from "../lib/keyfp.mjs";
import sodium from "libsodium-wrappers";
import { bearer, keyForBearer, keyCoversVault, normalizeKey } from "../lib/apikey.mjs";
import { isSigningKeyName } from "../lib/signing-keys.mjs";
import {
TeamMemberError,
normEmail,
@ -709,9 +710,14 @@ credshareRouter.delete("/api/credshare/vaults/:id/key-grants/:keyId", api(async
credshareRouter.get("/api/credshare/vaults/:id/secrets", api(async (req, res, user, key) => {
const vault = await vaultCtx(res, req.params.id, user.id, key); if (!vault) return;
const rows = await all(`SELECT * FROM credshare_secrets WHERE vault_id = ? ORDER BY name`, [vault.id]);
const all_ = await all(`SELECT * FROM credshare_secrets WHERE vault_id = ? ORDER BY name`, [vault.id]);
// A deploy box never receives a signing key (wallet key, seed, SSH key): root
// on a box running 24/7 must not mean the keys that move money.
const withheld = isMachine(key) ? all_.filter((s) => isSigningKeyName(s.name)).map((s) => s.name) : [];
const rows = withheld.length ? all_.filter((s) => !withheld.includes(s.name)) : all_;
await audit({ req, teamId: vault.team_id, vaultId: vault.id, actorUserId: user.id, action: "secrets:fetch", keyName: key?.name ?? (req.user ? "browser session" : null) });
res.json({ vaultId: vault.id, keyVersion: Number(vault.key_version ?? 1), secrets: rows.map((s) => ({ name: s.name, nonce: s.nonce, ciphertext: s.ciphertext, fingerprint: s.fingerprint, version: s.version, updatedAt: s.updated_at })) });
if (withheld.length) await audit({ req, teamId: vault.team_id, vaultId: vault.id, actorUserId: user.id, actorKeyId: key.id, action: "secrets:withheld:signing", keyName: withheld.join(",") });
res.json({ vaultId: vault.id, keyVersion: Number(vault.key_version ?? 1), withheld, secrets: rows.map((s) => ({ name: s.name, nonce: s.nonce, ciphertext: s.ciphertext, fingerprint: s.fingerprint, version: s.version, updatedAt: s.updated_at })) });
}, { machine: "read" }));
credshareRouter.put("/api/credshare/vaults/:id/secrets", api(async (req, res, user, key) => {
@ -728,6 +734,10 @@ credshareRouter.put("/api/credshare/vaults/:id/secrets", api(async (req, res, us
}
const upserts = Array.isArray(req.body?.upserts) ? req.body.upserts : [];
const deletes = Array.isArray(req.body?.deletes) ? req.body.deletes : [];
if (isMachine(key)) {
const signing = [...upserts.map((u) => u?.name), ...deletes].filter((n) => typeof n === "string" && isSigningKeyName(n));
if (signing.length) return res.status(403).json({ error: `A machine key cannot write signing keys (${signing.join(", ")}). Keep them in \`logicsrc keyring\` and unlock them where they are used.`, code: "signing_key_machine_write" });
}
const applied = [];
for (const u of upserts) {
if (!u || typeof u.name !== "string" || typeof u.nonce !== "string" || typeof u.ciphertext !== "string" || typeof u.fingerprint !== "string") {