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) (#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
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:
parent
1bff3e975c
commit
b5f875837a
12 changed files with 297 additions and 12 deletions
|
|
@ -270,6 +270,36 @@ test("a read-only machine key is refused every write; a read-write one may write
|
|||
await run(`DELETE FROM credshare_secrets WHERE vault_id = ? AND name = 'NEW'`, ["v_web"]);
|
||||
});
|
||||
|
||||
test("a machine key never receives or writes a signing key; a person still sees it", async () => {
|
||||
await run(`INSERT INTO credshare_secrets (vault_id, name, nonce, ciphertext, fingerprint, version, updated_by, updated_at) VALUES (?,?,?,?,?,?,?,?)`,
|
||||
["v_web", "SOLANA_PRIVATE_KEY", "n", "c", "fp", 1, "u_ann", now]);
|
||||
const m = await machineKey({ readOnly: false });
|
||||
await http.post("/api/credshare/keys", m.token, { publicKey: "pk-signing" });
|
||||
await http.post("/api/credshare/vaults/v_web/key-grants", annKey, { keyId: m.id, wrappedDek: "sealed-signing" });
|
||||
|
||||
const got = await http.get("/api/credshare/vaults/v_web/secrets", m.token);
|
||||
assert.equal(got.status, 200);
|
||||
assert.deepEqual(got.body.secrets.map((s) => s.name), ["API_KEY"]);
|
||||
assert.deepEqual(got.body.withheld, ["SOLANA_PRIVATE_KEY"]);
|
||||
const logged = await get(`SELECT * FROM credshare_audit WHERE vault_id = ? AND action = 'secrets:withheld:signing' AND actor_key_id = ?`, ["v_web", m.id]);
|
||||
assert.equal(logged.key_name, "SOLANA_PRIVATE_KEY");
|
||||
|
||||
const person = await http.get("/api/credshare/vaults/v_web/secrets", annKey);
|
||||
assert.deepEqual(person.body.secrets.map((s) => s.name).sort(), ["API_KEY", "SOLANA_PRIVATE_KEY"]);
|
||||
assert.deepEqual(person.body.withheld, []);
|
||||
|
||||
for (const body of [
|
||||
{ upserts: [{ name: "EVM_PRIVATE_KEY", nonce: "n", ciphertext: "c", fingerprint: "f" }], deletes: [] },
|
||||
{ upserts: [], deletes: ["SOLANA_PRIVATE_KEY"] }
|
||||
]) {
|
||||
const put = await http.put("/api/credshare/vaults/v_web/secrets", m.token, body);
|
||||
assert.equal(put.status, 403);
|
||||
assert.equal(put.body.code, "signing_key_machine_write");
|
||||
}
|
||||
assert.ok(await get(`SELECT 1 FROM credshare_secrets WHERE vault_id = ? AND name = 'SOLANA_PRIVATE_KEY'`, ["v_web"]));
|
||||
await run(`DELETE FROM credshare_secrets WHERE vault_id = ? AND name = 'SOLANA_PRIVATE_KEY'`, ["v_web"]);
|
||||
});
|
||||
|
||||
test("expired and revoked keys are 401, and revoking drops the key's grants", async () => {
|
||||
const expired = await machineKey({ expiresAt: Date.now() - 1000 });
|
||||
assert.equal((await http.get("/api/credshare/me", expired.token)).status, 401);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue