mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 17:24:48 +00:00
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>
This commit is contained in:
parent
1bff3e975c
commit
a7cd896ae3
12 changed files with 295 additions and 12 deletions
37
packages/opencreds/src/signing-keys.test.ts
Normal file
37
packages/opencreds/src/signing-keys.test.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { isSigningKey, isSigningKeyName, looksLikeSigningKeyValue } from "./signing-keys.js";
|
||||
|
||||
const fx = JSON.parse(readFileSync(new URL("./signing-keys.fixtures.json", import.meta.url), "utf8")) as { signing: string[]; not_signing: string[] };
|
||||
|
||||
describe("isSigningKeyName", () => {
|
||||
it.each(fx.signing)("%s is a signing key", (n) => expect(isSigningKeyName(n)).toBe(true));
|
||||
it.each(fx.not_signing)("%s is not", (n) => expect(isSigningKeyName(n)).toBe(false));
|
||||
});
|
||||
|
||||
describe("looksLikeSigningKeyValue", () => {
|
||||
const hex = "ab".repeat(32);
|
||||
it("catches PEM, 0x-hex, Solana base58 and byte arrays, and mnemonic shapes", () => {
|
||||
expect(looksLikeSigningKeyValue("-----BEGIN OPENSSH PRIVATE KEY-----\nb3Bl\n-----END OPENSSH PRIVATE KEY-----")).toBe(true);
|
||||
expect(looksLikeSigningKeyValue("-----BEGIN EC PRIVATE KEY-----")).toBe(true);
|
||||
expect(looksLikeSigningKeyValue(`0x${hex}`)).toBe(true);
|
||||
expect(looksLikeSigningKeyValue(`"0x${hex}"`)).toBe(true);
|
||||
expect(looksLikeSigningKeyValue("4".repeat(44) + "5".repeat(44))).toBe(true);
|
||||
expect(looksLikeSigningKeyValue(`[${Array.from({ length: 64 }, (_, i) => i).join(",")}]`)).toBe(true);
|
||||
expect(looksLikeSigningKeyValue(Array(12).fill("abandon").join(" "))).toBe(true);
|
||||
expect(looksLikeSigningKeyValue(Array(24).fill("zoo").join(" "))).toBe(true);
|
||||
});
|
||||
it("leaves ordinary secrets alone", () => {
|
||||
expect(looksLikeSigningKeyValue(hex)).toBe(false); // bare hex: HMAC/session secrets look like this
|
||||
expect(looksLikeSigningKeyValue("sk_live_51Habc")).toBe(false);
|
||||
expect(looksLikeSigningKeyValue("postgres://u:p@h/db")).toBe(false);
|
||||
expect(looksLikeSigningKeyValue("-----BEGIN PUBLIC KEY-----")).toBe(false);
|
||||
expect(looksLikeSigningKeyValue("hello world this is a normal sentence of eleven words ok")).toBe(false);
|
||||
expect(looksLikeSigningKeyValue(Array(12).fill("Abandon").join(" "))).toBe(false);
|
||||
});
|
||||
it("isSigningKey checks the name, then the value", () => {
|
||||
expect(isSigningKey("NOTES", `0x${hex}`)).toBe(true);
|
||||
expect(isSigningKey("SOLANA_PRIVATE_KEY")).toBe(true);
|
||||
expect(isSigningKey("NOTES", "plain")).toBe(false);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue