Skip to content

Security

  • Each user’s Sonarr URL and API key are encrypted with Fernet (AES-128-CBC with an HMAC-SHA256 integrity check) before they’re stored in SQLite (tokens.db).
  • A master encryption key is generated on first start and stored in /app/data/.master.key, created once with mode 0600.
  • Keys are decrypted in the session only, never stored in plain text.
  • Passwords are hashed with bcrypt.
  • After 5 failed logins in a row an account is locked for 5 minutes. Simultaneous attempts are counted one by one, so a burst of parallel guesses checks at most 5 passwords.
  • A wrong password gets the same answer whether the account exists, is disabled or not; the sign-in form never shows internal errors.
  • Disabled or deleted users are signed out on their next action.
  • Each user sees only their own instances, history and schedules.

Any user can point the app at any URL, so the server makes requests on their behalf. On shared installs, set SONARR_ANALYZER_ALLOWED_HOSTS (e.g. sonarr,192.168.1.10:8989) to allow only your Sonarr hosts.

The mobile apps sign in with a device token per phone, through the mobile API on port 8502.

  • Tokens (sa_ plus 32 random bytes) and the one-time pairing codes are stored only as SHA-256 hashes, in users.db.
  • A pairing code is valid for 5 minutes and works once, even if two phones try it at the same moment.
  • Revoke a device from My profile → Mobile devices. Changing your password revokes all of them, and disabling or deleting a user stops their tokens working.
  • The API’s sign-in and pairing endpoints allow 10 failures per IP in 10 minutes, on top of the account lockout.
  • The API is read-only and never returns Sonarr URLs or API keys.

The mobile apps only connect over HTTPS, so tokens and passwords never travel in the clear. Use HTTPS for the web app too whenever it’s reachable from outside your LAN. There are two ways.

Set SONARR_ANALYZER_TLS=self-signed. On first start the app creates a certificate and key in /app/data/tls (the key readable only by the app, valid for ten years), prints the certificate’s SHA-256 fingerprint in the logs and serves both ports over HTTPS.

Browsers warn about it once. The apps don’t rely on a certificate authority: they pin the fingerprint when you pair, from the QR code or after you compare it with My profile → Mobile devices. From then on they connect only if the server presents exactly that certificate.

To replace it, delete /app/data/tls and restart; then pair your phones again.

A reverse proxy with a public certificate (Let’s Encrypt) in front of both ports. Send /api to port 8502 and everything else to 8501 (the web app needs WebSockets). Then set SONARR_ANALYZER_PUBLIC_URL to the public address and FORWARDED_ALLOW_IPS to the proxy’s IP or Docker network, so the API’s sign-in limit sees each client’s real address. Without it, every client looks like the proxy, and ten failed sign-ins from anyone block sign-in for everybody for 10 minutes.

Caddy

Caddyfile
sonarr-analyzer.example.com {
reverse_proxy /api/* sonarr-analyzer:8502
reverse_proxy sonarr-analyzer:8501
}

Traefik (labels on the sonarr-analyzer service; the longer /api rule takes priority):

docker-compose.yml
labels:
- traefik.enable=true
- traefik.http.routers.sa-web.rule=Host(`sonarr-analyzer.example.com`)
- traefik.http.routers.sa-web.tls.certresolver=letsencrypt
- traefik.http.routers.sa-web.service=sa-web
- traefik.http.services.sa-web.loadbalancer.server.port=8501
- traefik.http.routers.sa-api.rule=Host(`sonarr-analyzer.example.com`) && PathPrefix(`/api`)
- traefik.http.routers.sa-api.tls.certresolver=letsencrypt
- traefik.http.routers.sa-api.service=sa-api
- traefik.http.services.sa-api.loadbalancer.server.port=8502

Nginx Proxy Manager: add a proxy host for your domain forwarding to sonarr-analyzer port 8501 with Websockets Support on; under Custom locations, add /api forwarding to sonarr-analyzer port 8502; under SSL, request a Let’s Encrypt certificate and force SSL.

With a proxy, publish the container’s ports on localhost only (or not at all if the proxy shares its Docker network), and leave SONARR_ANALYZER_TLS unset.

To reach the server away from home without exposing anything, a VPN such as Tailscale or WireGuard works with either option. The apps then connect to the server’s VPN address.

  • Runs as a non-root user (UID 1000), with privileges dropped by setpriv.
  • Supports a read-only root filesystem; the hardened Compose file enables it with no-new-privileges.
  • Streamlit’s CORS and XSRF protection stay at their secure defaults, and usage statistics are off.
  • CI runs pip-audit on every push and pull request.

Do: use strong passwords, back up the data volume, use HTTPS if you reach it from outside, set FORWARDED_ALLOW_IPS behind a reverse proxy, revoke phones you no longer use, set SONARR_ANALYZER_ALLOWED_HOSTS on shared installs.

Don’t: share the master key, port-forward 8501 or 8502 on your router, publish them on a server with a public IP, or set FORWARDED_ALLOW_IPS=* while 8502 is reachable directly. Publishing them on your LAN is fine.

Open an issue on GitHub. For anything sensitive, don’t include API keys, .master.key or database files.

Sonarr Analyzer v0.7.0 · GitHub · Docker Hub ·Report an issue

No trackers · MIT License · © Carlos Medina · Not affiliated with Sonarr