Security: close the 9 items from the June review + one found along the way
Findings from the 2026-06-24 security review, now mandatory before this platform leaves the LAN for a public VPS (see budget/externalization note): - Timing attack on admin password: hmac.compare_digest instead of != - CORS wildcard removed, restricted to ALLOWED_ORIGINS (needed for credentials) - hCaptcha now fails closed on network error instead of open - HMAC signatures use the full SHA-256 digest instead of a 64-bit truncation - Consultation-scoped submissions were missing the consent/cooldown checks the global submission route already had - Admin search capped at 200 chars (ILIKE cost) - Webhook URLs validated against SSRF (private/loopback/link-local/metadata IPs rejected, re-checked at trigger time too, redirects not followed) - Flood tracker backed by Redis when REDIS_URL is set (shared across Gunicorn workers, survives restarts), falls back to in-memory otherwise - Admin session moved from sessionStorage/Bearer token to an httpOnly+Secure+ SameSite=Strict cookie; new /api/admin/logout and /api/admin/session routes Also found while wiring ProxyFix for the cookie's Secure flag: the app never told Flask about the Nginx reverse proxy, so request.remote_addr saw Nginx's own IP for every request in production — silently breaking rate limiting, flood detection, and IP blacklist (everyone would collapse onto one shared key). Added ProxyFix (1 hop). CSV exports now stream instead of loading everything into memory. AI prompts delimit citizen-submitted content explicitly and instruct the model to treat it as inert data, never instructions, to reduce prompt injection surface. Docs (DEX.md, SECURITE_ANTI_ABUS.md, README.md, DEPLOIEMENT.md) and dev-local.sh updated to match.
This commit is contained in:
1 parent
2c0bb379c9
commit
defc07648c
10 files changed
+382
-116
No files matched your search
@@ -30,6 +30,13 @@ ADMIN_SECRET=CHANGEZ_CE_MOT_DE_PASSE_ADMIN
|
||||
FLASK_ENV=production
|
||||
PORT=8080
|
||||
|
||||
# ─── CORS ─────────────────────────────────────────────────────────────────────
|
||||
# Origines autorisées à appeler l'API en cross-origin, séparées par des virgules.
|
||||
# Jamais de wildcard "*" — incompatible avec les cookies de session (admin, RGPD,
|
||||
# cooldown). Sans cette variable, retombe sur VITE_APP_URL ci-dessous ; si aucune
|
||||
# des deux n'est définie, aucune origine cross-origin n'est autorisée.
|
||||
# ALLOWED_ORIGINS=https://votredomaine.fr
|
||||
|
||||
# ─── Anti-abus (optionnel — valeurs par défaut raisonnables) ─────────────────
|
||||
# REDIS_URL=redis://localhost:6379/0 # Rate limiting persistant (recommandé en prod)
|
||||
# RATE_LIMIT_CONTRIBUTIONS=5 per minute;3 per hour # Limite de soumissions
|
||||
|
||||
Reference in new issue
Block a user