fix(security): address multiple security findings from audit
- Fix SQLCipher PRAGMA key interpolation (hex-encode key to prevent crash on single quotes) - Enforce min password length (8 chars) on admin user creation - Add length bounds on username/display_name and login inputs - Invalidate other sessions on password change - Multi-stage Docker build (exclude build tools from runtime) - Exclude docs/ from Docker image - Consolidate dotenv.config() to single entry point - Document flat family authorization model in SECURITY.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+2
-3
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Modul: Datenbank (Database)
|
||||
* Zweck: SQLite/SQLCipher Verbindung, Schema-Migration (versioniert) und Query-Helfer
|
||||
* Abhängigkeiten: better-sqlite3, dotenv
|
||||
* Abhängigkeiten: better-sqlite3
|
||||
*
|
||||
* SQLCipher-Hinweis:
|
||||
* Verschlüsselung funktioniert nur wenn better-sqlite3 gegen SQLCipher kompiliert wurde.
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
require('dotenv').config();
|
||||
const Database = require('better-sqlite3');
|
||||
const path = require('path');
|
||||
|
||||
@@ -34,7 +33,7 @@ function init() {
|
||||
|
||||
if (DB_KEY) {
|
||||
// Nur wirksam wenn Binary gegen SQLCipher kompiliert ist (Docker)
|
||||
db.pragma(`key='${DB_KEY}'`);
|
||||
db.pragma(`key=x'${Buffer.from(DB_KEY, 'utf8').toString('hex')}'`);
|
||||
// Sicherstellen dass die Datenbank tatsächlich entschlüsselbar ist
|
||||
try {
|
||||
db.prepare('SELECT count(*) FROM sqlite_master').get();
|
||||
|
||||
Reference in New Issue
Block a user