mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-04 08:19:16 +00:00
fix(auth): add security hardening per code review
- Add timing-safe username comparison to prevent timing attacks - Regenerate session on login to prevent session fixation - Add warning log when session secret persistence fails
This commit is contained in:
@@ -56,8 +56,9 @@ function getSessionSecret(): string {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
fs.writeFileSync(SESSION_SECRET_PATH, newSecret, { mode: 0o600 });
|
||||
} catch {
|
||||
// If we can't persist, still return the secret for this session
|
||||
} catch (err) {
|
||||
// Log warning - sessions won't persist across restarts
|
||||
console.warn('[!] Failed to persist session secret:', (err as Error).message);
|
||||
}
|
||||
|
||||
return newSecret;
|
||||
|
||||
Reference in New Issue
Block a user