If you discover a security vulnerability, please report it through GitHub Security Advisories. Do not open a public issue for security vulnerabilities.
We will acknowledge reports within 48 hours and provide a timeline for fixes.
| Feature | Implementation |
|---|---|
| Password storage | bcrypt (legacy PBKDF2-SHA256 hashes are verified and auto-rehashed on login) |
| Password policy | New passwords need at least 12 characters, with no rules on character types. Passwords set before this rule keep working. |
| Authentication | httpOnly cookie (JWT HS256), Bearer token fallback for API testing |
| Two-step sign-in | Optional authenticator app codes (TOTP, RFC 6238) for password logins, 10 single-use recovery codes stored as hashes, 5 wrong codes pause the second step for 15 minutes. A family admin can reset it for a member; python -m app.reset_mfa <email> in the backend container resets it for anyone. Single sign-on accounts use the identity provider's MFA. The instance admin can require it for every account with a password (Admin > Sign-in); until an account has set it up, its sessions reach only the setup, and the mobile app asks to set it up on the web first. Single sign-on-only accounts and access tokens (API, calendar sync) are not affected. |
| Account recovery | A family admin can reset a member's password in the app, and an admin who forgot their own can run python -m app.reset_password <email> in the backend container (docker exec -it), which asks for the temporary password instead of printing one. Both give a temporary password that must be changed at the next sign-in, and sign the account out everywhere. |
| Sign-ins | Successful sign-ins (password, two-step code, single sign-on) and wrong two-step codes appear in each family's audit log with the method, not the address. A wrong password writes no audit entry, so it costs no more than an unknown email. Every failed attempt writes Failed sign-in: ip=<address> method=<password|two-step> to the backend log, for banning at the reverse proxy (see below). The address is the last X-Forwarded-For hop that isn't a trusted proxy, so entries a client puts in front are ignored. |
| Password guessing | After 3 wrong passwords for an email, further attempts must be at least 1 s, then 2 s, 4 s, ... up to 5 minutes apart, however many addresses the guesses come from; each attempt claims the next wait at once, so parallel guesses get one try per wait. It counts per email whether or not an account uses it, so an unknown email answers the same way, and it lives in the rate-limit storage (Valkey when REDIS_URL is set). A right password clears the count. During a wait the right password is not checked either, so someone who knows an email and sends a wrong guess whenever a wait runs out keeps its owner out for as long as they keep going. Every guess that gets through writes the failed sign-in log line, so fail2ban or similar can ban those addresses. |
| Rate limiting | 10/min for registration, 20/min for login (slowapi) |
| CORS | Restricted to localhost, 127.0.0.1, and 192.168.x.x via regex |
| Data isolation | All queries filtered by family_id with membership verification |
| Docker containers | Frontend runs as tribu; backend creates tribu and drops privileges with gosu when supported |
| Docker networking | PostgreSQL and Valkey are not exposed to the host and stay inside the Docker network |
| Build process | Multi-stage frontend build, .dockerignore files for both services |
| CSV import | Row limit (500), range checks on month/day fields, email format validation |
The backend will refuse to start without these variables set:
JWT_SECRET: Used for signing authentication tokens. Generate withopenssl rand -hex 32.DATABASE_URL: PostgreSQL connection string. In Docker Compose, this is constructed fromPOSTGRES_PASSWORD.POSTGRES_PASSWORD: Database password. Generate withopenssl rand -hex 16.
Never use default or placeholder values for these secrets.
- Copy
docker/.env.exampletodocker/.envand generate strong secrets - If exposing Tribu to the internet, put it behind a reverse proxy (nginx, Caddy, Traefik) with TLS
- Keep Docker images up to date for security patches
fail2ban, CrowdSec or similar can read the backend log (docker logs <backend-container>) and ban addresses that keep failing. For fail2ban:
[Definition]
failregex = Failed sign-in: ip=<HOST> method=The backend only sees the address of whatever passed the request on: Tribu's own frontend container, and any reverse proxy in front of it. Set TRUSTED_PROXY_CIDRS to cover both (for a standard Docker setup, the Docker networks, for example 172.16.0.0/12), or every line shows the same internal address and a ban locks everyone out. Only do this with a reverse proxy in front that sets X-Forwarded-For; without one, clients could put any address there.
Feature work that touches authentication, integrations, exports, backups, self-hosted deployment, or shared-device surfaces should include the defensive review described in CONTRIBUTING.md. It lists the boundaries to check and explains when to create narrow, public-safe follow-up issues.
Follow these steps before exposing Tribu to the internet:
- TLS termination: Place Tribu behind a reverse proxy (Caddy, nginx, or Traefik) with a valid TLS certificate. Caddy handles this automatically with Let's Encrypt.
- Check secure cookies: With the default
SECURE_COOKIES=auto, auth cookies get theSecureflag whenever the browser reaches Tribu over HTTPS, including behind a proxy that sendsX-Forwarded-Proto. SetSECURE_COOKIES=trueto enforce it regardless of what the proxy reports. - Generate strong secrets: Use
openssl rand -hex 32forJWT_SECRETandopenssl rand -hex 16forPOSTGRES_PASSWORD. Never reuse secrets across instances. - Keep direct backend access narrow: Browsers normally reach the backend through the frontend on the same origin. Only list origins you control in
CORS_ALLOWED_ORIGINS, and leaveCORS_ALLOW_LAN_ORIGINSoff unless you deliberately serve the backend to192.168.x.xbrowser origins. - Backups: Schedule regular PostgreSQL backups and test restore procedures. The Backup & Restore guide documents the supported operations flow.
- Keep images updated: Rebuild Docker images periodically to pick up security patches in base images and dependencies.
| Limitation | Context |
|---|---|
| No HTTPS in dev | Cookies follow the request scheme by default, so plain-HTTP development keeps working without the Secure flag. |
| No CSRF token | SameSite=Lax plus a Fetch Metadata check: cookie-authenticated requests that another site starts, including other apps on the same host, are rejected. Top-level links, native apps, DAV clients and bearer tokens are not affected; origins in CORS_ALLOWED_ORIGINS are trusted. |
| No email verification | Registration does not require email confirmation. |
| No account lockout | Failed login attempts are rate-limited but do not lock accounts. |
The frontend image runs as the dedicated non-root tribu user. The backend image creates the same user and the entrypoint drops privileges with gosu when the runtime supports it; in constrained environments where gosu is unavailable, the backend logs that it is running as root. The Docker Compose configuration does not expose database or cache ports to the host, keeping PostgreSQL and Valkey accessible only within the Docker network.
Build artifacts are minimized through:
- Multi-stage builds for the frontend (build step separated from runtime)
.dockerignorefiles excluding development files, git history, and documentation from images