security: Härtung der CMS-API + Deployment

App-Level:
- Security-Header (secureHeaders) global; /images/* mit strikter CSP+sandbox
  → bösartiges SVG kann kein JS im Origin ausführen
- Body-Limit 256 KB auf /api/*; Login-Rate-Limit (10/5min) gegen Brute-Force
- Upload: 8-MB-Limit + Format-Verifikation (sharp-Metadaten, SVG/GIF-Signatur)
- Comment-Längenlimit (10k) gegen DB-Bloat
- DB-Fehler nicht mehr roh ausliefern (serverError-Helper)
- Profil-PUT koalesziert Hugo-Builds (kein Build-Sturm)

Infra:
- Container läuft non-root (USER node, uid 1000) + Proxmox-Repo-chown
- Ports binden per Default auf 127.0.0.1 (BIND_ADDR-Escape-Hatch)
- Kong-CORS auf SITE_URL beschränkt statt "*"
- README: Härtungs- + Migrationshinweise

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 22:05:57 +02:00
parent 6d20be036a
commit 2650913050
13 changed files with 222 additions and 22 deletions
+9
View File
@@ -147,9 +147,18 @@ pct exec "$CTID" -- bash -euo pipefail -c "
sed -i \"s|^SITE_URL=.*|SITE_URL=http://\${HOSTIP}:8080|\" .env
sed -i \"s|^API_EXTERNAL_URL=.*|API_EXTERNAL_URL=http://\${HOSTIP}:8000|\" .env
sed -i \"s|^ADMIN_EMAILS=.*|ADMIN_EMAILS=${ADMIN_EMAIL}|\" .env
# Out-of-box LAN-Direktzugriff (kein Reverse-Proxy) → auf allen Interfaces
# lauschen. Für Domain/HTTPS hinter Proxy: BIND_ADDR=127.0.0.1 setzen.
sed -i \"s|^BIND_ADDR=.*|BIND_ADDR=0.0.0.0|\" .env
# CORS auf die Browser-Origin (= SITE_URL) festnageln statt „*\".
sed -i \"s|__CORS_ORIGIN__|http://\${HOSTIP}:8080|g\" kong.yml
echo 'OK: .env generiert.'
fi
# Der CMS-Container läuft als non-root (uid 1000). Das gemountete Repo muss
# ihm gehören, damit Hugo public/ bauen und content/ schreiben kann.
chown -R 1000:1000 '${APP_DIR}'
if [ '${COMPOSE_UP}' = 'true' ]; then
echo '→ Baue + starte Stack (dauert beim ersten Mal ein paar Minuten)…'
docker compose up -d --build