security(vault,recovery,config): harden Vault keyfile/seal, strip recovery passwords, guard config & symlinks
This commit is contained in:
parent
005c82e6bf
commit
e3f716d24f
12 changed files with 504 additions and 207 deletions
|
|
@ -202,20 +202,13 @@ describe('Bundle size budget & full-stack Express + WS lifecycle', () => {
|
|||
).toBe(200);
|
||||
|
||||
// 6. Vault Init + Step-Up guard + Drop Elevation + Generate Ed25519 key
|
||||
const vInit = await api('/api/vault/init', { method: 'POST', body: {} });
|
||||
expect(vInit.status).toBe(201);
|
||||
const generatedMasterKey = String(vInit.data.generatedKeyHex);
|
||||
|
||||
// v1.1 defaults elevateOnLogin=false; step up first, then verify drop-elevation clears it
|
||||
// v1.1 defaults elevateOnLogin=false; verify non-elevated session cannot init vault
|
||||
const statusInitial = await api('/api/auth/status');
|
||||
expect(statusInitial.data.elevatedUntil).toBeNull();
|
||||
|
||||
const noStepUp = await api('/api/vault/generate-ed25519', {
|
||||
method: 'POST',
|
||||
body: { id: 'prod-key', name: 'Prod Key' },
|
||||
});
|
||||
expect(noStepUp.status).toBe(403);
|
||||
expect(noStepUp.data.error).toBe('STEP_UP_REQUIRED');
|
||||
const vInitDenied = await api('/api/vault/init', { method: 'POST', body: {} });
|
||||
expect(vInitDenied.status).toBe(403);
|
||||
expect(vInitDenied.data.error).toBe('STEP_UP_REQUIRED');
|
||||
|
||||
const stepUpRes = await api('/api/auth/step-up', {
|
||||
method: 'POST',
|
||||
|
|
@ -223,6 +216,10 @@ describe('Bundle size budget & full-stack Express + WS lifecycle', () => {
|
|||
});
|
||||
expect(stepUpRes.status).toBe(200);
|
||||
|
||||
const vInit = await api('/api/vault/init', { method: 'POST', body: {} });
|
||||
expect(vInit.status).toBe(201);
|
||||
const generatedMasterKey = String(vInit.data.generatedKeyHex);
|
||||
|
||||
const statusBeforeDrop = await api('/api/auth/status');
|
||||
expect(typeof statusBeforeDrop.data.elevatedUntil).toBe('number');
|
||||
const dropped = await api('/api/auth/drop-elevation', { method: 'POST' });
|
||||
|
|
|
|||
|
|
@ -250,6 +250,9 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
expect(anyLogin.status).toBe(200);
|
||||
|
||||
// Switch settings.json to strict multi-factor 'all' + 'every-action' + password step-up
|
||||
expect(
|
||||
(await api.call('/api/auth/step-up', { method: 'POST', body: { code: totp1.generate() } })).status,
|
||||
).toBe(200);
|
||||
const rawSettings = await api.call('/api/config/file?path=settings.json');
|
||||
expect(rawSettings.status).toBe(200);
|
||||
const parsedSettings = JSON.parse(String(rawSettings.data.rawContent)) as Record<
|
||||
|
|
@ -431,7 +434,7 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
const bundle = JSON.parse(fs.readFileSync(bundlePath, 'utf8')) as EmergencySecretsBundle;
|
||||
expect(bundle.vaultMasterKeyHex).toBe(masterKeyHex);
|
||||
expect(bundle.admin.username).toBe('admin');
|
||||
expect(bundle.admin.passwords.some((p) => p.plaintextPassword === password)).toBe(true);
|
||||
expect(bundle.admin.passwords.some((p) => p.label === 'Primary Password' && !('plaintextPassword' in p))).toBe(true);
|
||||
expect(bundle.admin.totps.some((t) => t.secretBase32 === secretBase32)).toBe(true);
|
||||
expect(bundle.admin.recoveryCodes).toEqual(recoveryCodes);
|
||||
expect(bundle.vaultCredentials['backup-key']).toBeDefined();
|
||||
|
|
|
|||
|
|
@ -121,10 +121,10 @@ describe('Phase 2 E2E: /api/servers, TOFU, Live Metrics WS, Key Rotation & Panic
|
|||
});
|
||||
ws.send(JSON.stringify({ type: 'sub', channels: ['metrics', 'alerts', 'config'] }));
|
||||
|
||||
expect((await api('/api/vault/init', { method: 'POST', body: {} })).status).toBe(201);
|
||||
expect(
|
||||
(await api('/api/auth/step-up', { method: 'POST', body: { code: totp.generate() } })).status,
|
||||
).toBe(200);
|
||||
expect((await api('/api/vault/init', { method: 'POST', body: {} })).status).toBe(201);
|
||||
|
||||
const keyRes = await api('/api/vault/generate-ed25519', {
|
||||
method: 'POST',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue