security(alerts,ai): fix secret exfiltration, ReDoS/redactor bypasses, probe double-counting & add Security Event Alerting

This commit is contained in:
tyuXX 2026-11-28 05:09:46 +00:00
parent 2b878c1d99
commit 67137056f8
11 changed files with 613 additions and 173 deletions

View file

@ -245,6 +245,7 @@ export async function createGCoordinatorServer(
sshPool,
wsHub,
auditService,
getRuntimeLimits,
);
const backupScheduler = new BackupScheduler(
dataDir,
@ -396,6 +397,21 @@ export async function createGCoordinatorServer(
});
});
authService.setSecurityEventListener((ev) => {
void alertEngine.emitSecurityEvent(ev.type, {
ip: ev.ip,
details: ev.details,
message: `${ev.type}${ev.ip ? ` from ${ev.ip}` : ''}`,
});
});
knownHosts.onHostKeyMismatch((alert) => {
void alertEngine.emitSecurityEvent('ssh.host_key_mismatch', {
serverId: alert.serverId,
message: `Host key mismatch on ${alert.hostPortKey} (${alert.algorithm})`,
});
});
monitoringService.start();
void tunnelManager.syncAutoStart();
customSystemsEngine.syncBackgroundChecks();
@ -419,6 +435,9 @@ export async function createGCoordinatorServer(
});
vaultService.onPanicLock(() => {
void alertEngine.emitSecurityEvent('vault.panic_lock', {
message: 'Emergency Panic Lock activated',
});
aiService.cancelAll();
backupScheduler.stop();
alertEngine.handlePanicLock();
@ -442,6 +461,9 @@ export async function createGCoordinatorServer(
warnings: event.warnings,
errors: event.errors,
});
if (event.entityType === 'alerts' || event.entityType === 'server' || event.entityType === 'all') {
alertEngine.syncWithConfig();
}
if (
event.entityType === 'server' ||
event.entityType === 'system' ||
@ -456,22 +478,32 @@ export async function createGCoordinatorServer(
customSystemsEngine.invalidateCache(event.id);
} else if (event.entityType === 'system' && event.id) {
customSystemsEngine.invalidateCache(undefined, event.id);
} else {
} else if (event.entityType === 'all') {
customSystemsEngine.invalidateCache();
}
if (event.entityType === 'settings') {
if (event.entityType === 'settings' || event.entityType === 'all') {
applyDatabaseThrottlePragmas(db, getRuntimeLimits());
if (!configManager.getSettings().security.enableEmergencySecretsBackup) {
recoveryStore.wipeAll();
} else {
authService.syncRecovery();
}
backupScheduler.sync();
}
if (event.entityType === 'server' || event.entityType === 'all') {
monitoringService.syncServers();
void tunnelManager.syncAutoStart();
}
if (
event.entityType === 'server' ||
event.entityType === 'system' ||
event.entityType === 'all'
) {
customSystemsEngine.syncBackgroundChecks();
}
if (event.entityType === 'workflow' || event.entityType === 'all') {
workflowEngine.syncCronJobs();
}
monitoringService.syncServers();
customSystemsEngine.syncBackgroundChecks();
workflowEngine.syncCronJobs();
backupScheduler.sync();
void tunnelManager.syncAutoStart();
}
});
@ -593,9 +625,9 @@ export async function createGCoordinatorServer(
);
app.use(
'/api/alerts',
createAlertsRouter({ authService, configManager, auditService, alertEngine }),
createAlertsRouter({ authService, configManager, auditService, alertEngine, stepUpGuard }),
);
app.use('/api/ai', createAiRouter({ authService, aiService }));
app.use('/api/ai', createAiRouter({ authService, aiService, stepUpGuard }));
app.use(
'/api/servers/:id/sftp',
createSftpRouter({ authService, configManager, auditService, sftpService, stepUpGuard }),