security(auth,ws): fix Auth/TOTP/WebAuthn/bootstrap vulnerabilities, session idle TTL & real-time WS revocation

This commit is contained in:
tyuXX 2026-11-27 22:31:37 +00:00
parent e3f716d24f
commit 1b2e425a00
13 changed files with 1248 additions and 477 deletions

View file

@ -56,6 +56,7 @@ export interface ServerOptions {
publicDir?: string;
secretFilePath?: string;
envMasterKey?: string;
envDbKey?: string;
trustCloudflare?: boolean;
trustedProxyCidrs?: string[];
allowLanTunnels?: boolean;
@ -135,8 +136,11 @@ export async function createGCoordinatorServer(
const authService = new AuthService(db, {
getSecuritySettings: () => configManager.getSettings().security,
getRuntimeLimits,
recoveryStore,
vaultService,
dataDir,
envDbKey: options.envDbKey,
});
const backupKey = configManager.getSettings().security.enableEmergencySecretsBackup
@ -163,7 +167,10 @@ export async function createGCoordinatorServer(
}
const httpServer = http.createServer(app);
const wsHub = new WsHub(httpServer, authService, vaultService);
const wsHub = new WsHub(httpServer, authService, vaultService, { trustCloudflare });
authService.onSessionsRevoked((idHashes) => {
wsHub.disconnectSessions(idHashes);
});
const knownHosts = new KnownHostsService(db, auditService);
const sshPool = new SSHPool(configManager, vaultService, knownHosts);
@ -374,8 +381,8 @@ export async function createGCoordinatorServer(
tunnelManager.stopAll();
ptyManager.closeAll(true);
sshPool.closeAll('panic_lock');
authService.revokeAllSessions();
wsHub.handlePanicLock();
authService.revokeAllSessions();
});
configManager.onChange((event) => {
@ -437,6 +444,8 @@ export async function createGCoordinatorServer(
recoveryStore,
rateLimiter,
trustCloudflare,
webauthnRpId: options.webauthnRpId,
webauthnOrigins: options.webauthnOrigins,
}),
);
@ -628,6 +637,7 @@ export async function createGCoordinatorServer(
tunnelManager.stopAll();
ptyManager.close();
sshPool.closeAll('shutdown');
authService.close();
wsHub.close();
await configManager.close();
await new Promise<void>((resolve) => {