Skip to content

Security and Threat Model

github-actions[bot] edited this page Dec 1, 2026 · 12 revisions

Security and threat model

Tiedenwerk is designed for a single trusted home network. Read that sentence once more — the entire authorization model rests on it.

What the auth model actually is

Identity is a 2-tuple:

  1. Family — identified by a 6-character join_code. Anyone with the code can register a device and read/write the family's data.
  2. Device — identified by a UUID stored in a cookie. Each device that joins a family gets its own row in public.devices with a last_seen timestamp.

There are no user accounts. There is no password protection on data access by default beyond the join code. There is an optional 4-digit PIN gate on the /settings/* area (see "Settings PIN" below).

The database enforces the family boundary. The browser talks to the database API (PostgREST) directly, so row-level security is on for every family-scoped table, and every policy reads the caller's family from a family_id claim on the request's token:

  • The anon key in the browser bundle reads nothing. It is public by design and carries no family. This was not always so: until 2026-08 RLS was off, and on 2026-08-04 an unauthenticated request from outside the network read a family's join code straight from the API. migrations/049_row_level_security.sql closed that.
  • A joined device gets a family-scoped token from /api/session/token, exchanged for the HttpOnly device-session cookie. It lasts an hour and is refreshed automatically. Knowing a family_id is not enough: the token is signed with the stack's JWT secret, which never leaves the server.
  • Within a family, the rules that matter are enforced by the server, not trusted to the screen. The browser can't write pocket money, points, rewards, creatures, settings, or create and delete families: those tables are read-only for it, and the change goes through an API route that checks the settings PIN and the other rules. No browser role can TRUNCATE a table.
  • The service-role key bypasses all of this and is held only by the Next.js server process. API routes and cron jobs establish the family from the device session first and filter on it themselves.

What RLS does not change: the join code is the household's key. Anyone who has it can join a device and get a token for that family, and then read everything the family can. RLS keeps the public key and other families out; it does not make the join code less important. Technical detail: Architecture → Row-Level Security.

Integration credentials get their own locked-down table, with no browser access at all — see Integration credentials below.

What this is good for

  • A trusted LAN. Everyone in the house has the join code. Nobody else does. A new family member joining just needs the code, like a Wi-Fi password.
  • Low-friction kiosk and PWA UX. No login screens to confuse the kids. No tokens to refresh. No password resets.
  • Self-hosters who already secure their LAN. The rest of your home network has the same trust model — your printer doesn't need OAuth either.

What this is NOT good for

  • Public internet exposure without a wrapping auth layer. The join code is 6 alphanumeric characters (~30 bits of entropy). Brute force is possible. Don't expose /join publicly without something like Authelia, Authentik, Cloudflare Access, or Traefik forward-auth in front.
  • Untrusted users on the same family. Anyone with the code can read every event, todo, recipe, photo URL, and device fingerprint of every other device in the family. The model assumes "everyone in the family has the same trust level."
  • Compliance scenarios. No audit logs, no role-based access, no per-resource ACL. Don't use Tiedenwerk for anything that needs HIPAA, GDPR-data-controller distinction, or similar.

Sensitive data Tiedenwerk handles

If something goes wrong, these categories are at risk:

  • OAuth refresh tokens for Google Calendar, and CalDAV account passwords (both in integration_secrets, encrypted at rest by Postgres only if you enable disk encryption — Tiedenwerk itself does not encrypt the column, but the table is locked down from anon/authenticated reads; see Integration credentials). Prefer a provider-issued app password over your main account password for CalDAV: it can be revoked on its own if a backup leaks.
  • Long-lived access tokens for Home Assistant
  • API keys for Immich, OpenWeatherMap, Bring! account credentials
  • VAPID push notification keys at host level (in webapp/docker/.env)
  • Family content: events, todos, shopping lists, recipe library, uploaded avatars, screensaver photo URLs, camera RTSP URLs (and embedded credentials), HA entity history
  • The Supabase JWT secret (JWT_SECRET) and service role key — host-level, in webapp/docker/.env

A vulnerability that lets an unauthenticated client read or write any of the above qualifies as high-severity. See SECURITY.md in the repo for disclosure.

Recommended hardening

For the typical home deployment:

Required

  • Don't expose the stack directly to the public internet. Use a reverse proxy with auth in front, or restrict via WireGuard / Tailscale / Cloudflare Tunnel + Access.
  • Generate strong secrets via setup.sh. Don't hand-edit .env to use easily-guessed passwords.
  • Set the Settings PIN if you have curious kids or visiting guests with the join code. See below.

Recommended

  • Limit the Postgres port to localhost. The default docker-compose.yml exposes 5432 to the host network so you can psql for ops. If you don't need that, change "5432:5432" to "127.0.0.1:5432:5432".
  • Rotate the family join code occasionally. Settings → the join-code card has a "Rotate" action, plus an opt-in expiry (never / 1 hour / 24 hours / 7 days) — expired codes are rejected at join time.

Nice-to-have

  • Disable kiosk auto-login on the wall display if family members have different trust levels. Tiedenwerk's PIN gate covers /settings/* but not the dashboard itself.
  • Apply Postgres at-rest encryption at the filesystem layer (LUKS, ZFS encryption, etc.).

The Settings PIN

Settings → Settings PIN sets a 4-digit code that's required to enter /settings/*. It's a "keep curious kids out" feature, not a real auth boundary — there's no per-user identity behind it, just a shared 4-digit code for the whole family.

As of v1.4.0, the PIN is checked and stored server-side: the value lives in integration_secrets (not the settings table every screen of the family can read) and verification happens in /api/pin, rate-limited to 5 failed attempts per minute per family. Before v1.4.0 the PIN was compared client-side against a plaintext value any device on the network could read via PostgREST — that's fixed now; existing PINs migrated automatically on upgrade.

Once set, the PIN persists for the browser session via sessionStorage. Closing the tab requires re-entry; navigating between settings sub-pages does not.

The desktop app

The desktop app shows the server's own pages and gives them a small bridge to the PC (fullscreen, display power, the radar, quitting). What keeps that bridge for your server only:

  • One origin. The bridge exists only in pages from the server the app connected to. Other sites open in a separate sheet without it.
  • The server's identity key. Over plain http on a LAN, anything that answers at the server's address would otherwise get the bridge. So the server holds an Ed25519 key pair (in its database, kinboard.server_identity, readable only by the owner role) and signs a fresh challenge from the app (/api/desktop/identity). The app keeps the public key from its first connection and checks it on every start, page load and reconnect. A different key closes the dashboard; only someone at the PC can accept it. Following a server to a new address (mDNS) needs the same proof.
  • A wall screen is chosen at the PC. The kiosk flag on the server can ask, but the first switch to a wall screen waits for a yes in the app's own overlay, which the page can't draw over or press.
  • The PIN goes to the app, not the page. On a wall screen the app menu, quitting, leaving fullscreen and changing the server ask for the Settings PIN in the app's overlay; the app checks it itself (/api/desktop/pin, same check and rate limit as /api/pin). For when the server is away it keeps a salted Argon2id hash of the last PIN that was right on this PC. A correct PIN there opens the app's menu, not the webapp's Settings.
  • Presence from the app is reported with the device's own session, for that device only; the token path for scripts is unchanged.
  • Display rules (devices.display_policy) are written only by the server, behind the Settings PIN; one screen can't switch another's display off.
  • Updates are signed with the project's key; the app refuses an update whose signature doesn't match the key built into it.
  • The log (Copy log) drops secret fields and cuts every address to its origin, so a pasted log carries no tokens or paths.

Integration credentials

OAuth tokens (Google, Home Assistant), CalDAV passwords, and API keys (Immich, Unsplash, Bring!) live in public.integration_secrets, a table with anon/authenticated database privileges revoked and never streamed live — only the server's service-role client can read it. Before v1.4.0 these lived in the same settings table as everything else, which every screen of the family can read by design (so the dashboard can live-sync); that meant any device on the network could read another family member's Google refresh token or Home Assistant long-lived token via PostgREST. Settings pages now read a merged, secret-stripped view to show "connected" status without the browser ever receiving the actual token. Existing installs migrate their previously-exposed credentials into the locked-down table automatically on upgrade — no reconnecting required.

How device recognition works

Tiedenwerk recognizes a returning device by a random device id the device generated when it joined (hardware_id). It is kept in a cookie, localStorage, IndexedDB and the service worker, in sync across all four, so one of them going missing doesn't lose it. Only that device has it, which is what makes it proof.

Where the lookup runs. Server-side, in /api/session/recognize, using the service role. It cannot run in the browser: devices joins to families, and families hold join codes, so a row-level-security policy permissive enough to let an anonymous caller read devices would let anyone enumerate households. The route answers with the family's name and the device's name only — never the join code, never the family id, never the other devices — and at most one match.

Resuming is a separate step, and it verifies the claim. /api/session/resume issues the session. A device id alone is not enough, since those travel in responses: the request must carry the row's own hardware_id. A wall display with no session in its store is signed back in this way silently, which is how it returns to the dashboard after a power cut.

No fingerprint. Before 1.15 a device whose saved id was gone could also be recognized, and signed in, by a browser fingerprint (language, screen size, time zone, CPU count). Those are common values: another tablet of the same model on the same network could be offered a family's name and a session. Since 1.15 only the saved id counts. devices.fingerprint and fingerprint_history are still recorded at join, but nothing reads them for sign-in.

What this means after a wipe: a device whose site data was cleared, a new device or another browser joins with the family code. Any device still connected can show it (Settings → "Family code"); on the new one, open /join, enter the code, name the device and tap "Join". The old row stays in Settings → Devices until you delete it.

All of these routes are rate-limited per address and, because a forwarded address can be forged, also across all callers.

Source: webapp/src/lib/device-id.ts (the device id), webapp/src/app/api/session/recognize/route.ts (the lookup, and what it will say), webapp/src/app/api/session/resume/route.ts (issuing the session).

Trusted-LAN-but-still-paranoid checklist

  • Stack runs on a host that's not directly reachable from the WAN
  • If using Traefik publicly, an auth middleware sits in front of it
  • setup.sh was run with no manual edits to the generated secrets
  • webapp/docker/.env is mode 600 and belongs to your own user, not root. setup.sh creates it that way and keeps both on every run; an older install's file may need chmod 600 once; one an earlier automatic update gave to root, the automatic update gives back to the folder's owner by itself
  • Backups encrypt the pg_dump output
  • GO2RTC_HTTP_BIND left at 127.0.0.1 if you use cameras — go2rtc's /api/streams lists the sources it holds, and a camera added through Tiedenwerk's settings appears there as a full rtsp://user:pass@… URL (see Cameras)
  • No real production data lives in development checkouts (webapp/.env.local should be empty or have non-prod values)
  • If multiple families share a host, each runs in its own Compose project (PROJECT_NAME differs)

Reporting a vulnerability

Email security@tiedenwerk.com. Don't open public issues. Acknowledgement within 7 days, fix targeted within 30 days for high-severity. Full text in SECURITY.md.

Clone this wiki locally