# Shared media backend security notes The backend rewrite consolidates the security boundary in `internal/`. Implemented controls include: - bcrypt passwords, PostgreSQL cookie sessions, TOTP verification, role checks, and disabled-user checks; - explicit CORS and WebSocket origin validation, security headers, and bounded request bodies; - additive PostgreSQL migrations with a startup advisory lock; - traversal, absolute-path, drive-path, and symlink-escape protection for every configured media root; - fixed ffmpeg argument construction and bounded workflow workers; - HTTPS-only downloader URLs with credential, private-IP, link-local, metadata-host, and DNS-rebinding checks; - internal-service secret checks for mount, download, reload, upload, and catalog mutation routes; - non-root Docker images and no Node server runtime. Before deployment, set a unique `INTERNAL_SERVICE_SECRET`, use a strong database password, configure `CORS_ORIGIN` to the real frontend origin, and enable TLS so `COOKIE_SECURE` can remain enabled. Review the canonical Go routes when adding a capability; do not reintroduce the removed JavaScript server paths or Socket.IO transport.