Some checks failed
Build and Push Docker Image / build (push) Successful in 59s
CI / Security audit (push) Successful in 1m5s
CI / Tests & coverage (push) Successful in 1m24s
Docs Check / Markdown lint (push) Failing after 45s
Docs Check / Mermaid diagram parse check (push) Successful in 1m27s
CI / Security audit (pull_request) Successful in 51s
CI / Tests & coverage (pull_request) Successful in 1m1s
Docs Check / Markdown lint (pull_request) Failing after 39s
Docs Check / Mermaid diagram parse check (pull_request) Successful in 1m12s
Phase 1 - Licensing & Compliance: - Add MIT LICENSE file - Add copyright headers to server/index.js, poller.js, config.js, sanitizeError.js, and new loadSecrets.js Phase 2 - Security Hardening: - Add server/utils/loadSecrets.js: Docker secrets support via _FILE env var pattern (COOKIE_SECRET_FILE, EMBY_API_KEY_FILE, etc.) - Add SSRF/URL validation in config.js: validates all configured service instance URLs for scheme and well-formedness at startup - Add SIGTERM/SIGINT graceful shutdown: stops poller, drains HTTP connections, 10s force-exit fallback - Warn at startup if COOKIE_SECRET is shorter than 32 characters - Validate EMBY_URL scheme at startup - Improve sanitizeError: redact host:port from axios error URLs while preserving path/query for other redaction patterns Phase 3 - Config Robustness: - Weak COOKIE_SECRET warning (< 32 chars) - EMBY_URL validated via validateInstanceUrl on startup Phase 4 - Docker & Deployment: - .dockerignore: add tests/, coverage/, vitest.config.js, CHANGELOG.md, SECURITY.md, LICENSE, .markdownlint.json - docker-compose.yaml: add commented Option B (Docker secrets _FILE pattern) alongside existing plain-env Option A Phase 5 - Docs & Release Readiness: - Add CHANGELOG.md with entries from v1.0.0 to v1.2.0 - Update SECURITY.md: supported versions table, fix Docker secrets note to reflect _FILE support now implemented - Add public/.well-known/security.txt for responsible disclosure - Bump version to 1.2.0
5.2 KiB
5.2 KiB
Security Policy & Hardening Guide
Supported Versions
| Version | Supported |
|---|---|
| 1.2.x | ✅ Yes |
| 1.1.x | ✅ Yes |
| 1.0.x | ❌ No |
| < 1.0 | ❌ No |
Reporting a Vulnerability
Please do not open a public issue for security vulnerabilities. Email: gordon@i3omb.com — expect acknowledgement within 48 hours.
Threat Model
sofarr is a personal dashboard intended for a small trusted group (household/team). It proxies requests to *arr stack services using stored API keys and authenticates users via Emby. The primary threat surface when exposed to the public internet:
| Threat | Mitigations |
|---|---|
| Credential brute-force | Rate limiting (10 fails/15 min per IP), account lockout window |
| Session hijacking | HMAC-signed cookies, httpOnly, secure, sameSite=strict, short TTL |
| CSRF | Double-submit cookie pattern (X-CSRF-Token header required on all mutations) |
| API key leakage via errors | sanitizeError() redacts keys/tokens from all error responses and logs |
| Token theft after logout | Server-side token store; Emby token revoked on logout |
| XSS → token theft | httpOnly cookies; CSP with per-request nonce blocks inline injection |
| Clickjacking | X-Frame-Options: DENY + CSP frame-ancestors 'none' |
| Info disclosure via headers | Helmet v7 removes X-Powered-By, sets noSniff, xssFilter, etc. |
| Privilege escalation (container) | Non-root user (UID 1000), no-new-privileges, all caps dropped |
| Unbounded log growth | Size-based rotation: 10 MB cap, 3 rotated files kept |
| Dependency vulnerabilities | npm audit --audit-level=high in CI on every push |
Production Deployment Checklist
Required
COOKIE_SECRETset to a random 32-byte hex string (openssl rand -hex 32)NODE_ENV=productionTRUST_PROXY=1set if behind a reverse proxy- sofarr bound to
127.0.0.1only (not0.0.0.0) — expose via proxy - HTTPS enforced by the reverse proxy with a valid certificate
- Firewall rules: only 443/80 open externally; 3001 not directly exposed
Recommended
- Reverse proxy: Nginx, Caddy, or Traefik with TLS termination
- Set
Strict-Transport-Securityat proxy level (sofarr also sends HSTS) DATA_DIRon a named Docker volume (not bind-mounted to sensitive host path)- Rotate
COOKIE_SECRETperiodically (causes all users to re-login) - Enable Docker's
--read-onlyflag (already indocker-compose.yaml) - Monitor
/healthendpoint with an uptime checker
Docker Secrets (alternative to env vars)
For production environments that support Docker secrets, you can mount secret files and reference them:
secrets:
cookie_secret:
file: ./secrets/cookie_secret.txt
emby_api_key:
file: ./secrets/emby_api_key.txt
services:
sofarr:
secrets:
- cookie_secret
- emby_api_key
environment:
- COOKIE_SECRET_FILE=/run/secrets/cookie_secret
- EMBY_API_KEY_FILE=/run/secrets/emby_api_key
Since v1.2.0, sofarr natively supports the
_FILEpattern. SetCOOKIE_SECRET_FILE=/run/secrets/cookie_secretand sofarr will read the secret value from that file at startup. Seedocker-compose.yamlfor a complete example.
Reverse Proxy Example (Caddy)
sofarr.example.com {
reverse_proxy localhost:3001
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Robots-Tag "noindex, nofollow"
}
}
Reverse Proxy Example (Nginx)
server {
listen 443 ssl;
server_name sofarr.example.com;
ssl_certificate /etc/letsencrypt/live/sofarr.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sofarr.example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Required for SSE (Server-Sent Events) — disable response buffering
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
}
}
Security Headers (emitted by sofarr)
| Header | Value |
|---|---|
Content-Security-Policy |
default-src 'self'; script-src 'self' 'nonce-…'; style-src 'self' 'nonce-…'; style-src-attr 'unsafe-inline'; img-src 'self' data: blob:; object-src 'none'; frame-ancestors 'none' |
Strict-Transport-Security |
max-age=31536000; includeSubDomains; preload (production only) |
X-Content-Type-Options |
nosniff |
X-Frame-Options |
DENY |
Referrer-Policy |
strict-origin-when-cross-origin |
Permissions-Policy |
camera=(), microphone=(), geolocation=(), payment=(), usb=() |
Rate Limits
| Endpoint | Limit |
|---|---|
POST /api/auth/login |
10 failed attempts per 15 min per IP |
All /api/* routes |
300 requests per 15 min per IP |
Supply Chain
- All dependencies pinned to minor version ranges in
package.json npm audit --audit-level=highruns in CI on every push and pull requestnpm audit fixshould be run when vulnerabilities are reported