Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Security

What Tablo does by default, and what your deployment must provide for those defaults to hold.

Your deployment must provide

  • HTTPS. The session, CSRF and notification cookies are __Host- cookies marked Secure. Browsers accept them over plain HTTP only on localhost; anywhere else, without HTTPS, the browser drops them and every form POST fails its CSRF check with 403.
  • The client’s address behind a proxy. Tablo throttles sign-ins per login and client address. Behind a reverse proxy, trust it with the router’s TrustedProxies so the address is the client’s; otherwise a guesser who knows a login can lock its owner out. The first sign-in that carries a forwarding header the router ignored logs a warning.
  • Per-IP and multi-replica rate limiting at your proxy or firewall, for what the panel’s throttle does not count: LoginThrottle lists it.
  • The panel gate, whoever signs users in. Put a panel behind an app’s own sign-in with Auth::external, not with Auth::disabled() and a layer of your own: the panel’s endpoints serve at /_topcoat/runtime, outside its prefix, and only its gate covers them.
  • Session revocation. Call auth::revoke_sessions_for_user when a password changes outside the panel’s edit form, in a custom action, or a custom user’s credentials change. An edit form that changes an AdminUser’s, or another PasswordAccount’s, email or password hash ends that user’s sessions itself, and deactivating one ends them at its next request.
  • Deleting an account. Call erase_user in the transaction that deletes the user, rather than deleting Tablo’s tables by name: it deletes the user’s rows from every table Tablo ships, the ones a later release adds included.

Requests and writes

  • Every panel POST, login and logout included, verifies a double-submit CSRF token before any write it asks for; a missing or wrong token answers 403.
  • Topcoat’s runtime calls carry no CSRF token: the notification bell’s procedures, the search and notification shards, and any shard or procedure the app adds. The router’s OriginPolicy, on by default, refuses them from another site. Keep it: a router built with OriginPolicy::dangerous_disable, or exempting /_topcoat/runtime, leaves them open to cross-site requests, and Tablo cannot tell.
  • Delete and bulk-delete POSTs also require the confirm=1 marker the confirmation dialog sends. It prevents accidental deletes; it is not a security boundary.
  • A form POST with a key the form does not declare answers 400, so a client cannot write a field the form does not show, such as role or tenant_id (RecordForm).
  • Update, delete and custom action handlers load the target through the resource’s scoped query inside the write’s transaction and check policy on that row. See Policy.
  • Table search binds the term as a parameter; no user input is interpolated into SQL (Table).

Authentication

  • Passwords are hashed with Argon2id, and a login for an unknown email takes as long as a wrong password: PasswordAuth.
  • Sign-ins are throttled per login and client address, five a minute unless Auth::throttle says otherwise, and, opt-in, per login across addresses with Auth::account_throttle, which lets anyone who knows a login keep its owner out; sign-ups per address (Auth::sign_up_throttle).
  • Sessions are stored server-side as a hash of the cookie’s token, and replaced on login and on sign-up: AuthSession.
  • A redirect after login follows next only to a same-origin path.
  • A two-factor challenge ends after five wrong codes in a row, later codes wait longer each time, up to an hour, and the account is mailed that its password was used. Whoever holds the password can keep the owner’s app codes waiting until the owner changes it: Auth::two_factor.
  • A Google or other OpenID Connect sign-in is bound to the browser that started it by a sealed cookie, its state and its PKCE verifier, and its ID token to the sign-in by its nonce. The token comes from the provider’s token endpoint over TLS, and the app’s linker decides which account an identity is. A pending sign-in lasts ten minutes, and its callbacks count against the sign-in throttle: Auth::oidc.
  • Acting as another user is off until the app gives a rule, which every request asks again. It lasts an hour by default, never nests, writes nothing unless the app makes it writable, keeps the actor off the target’s credential pages, and the audit log names the actor: Auth::impersonation.

Several panels, one user type

Two panels whose authenticators load the same user type share that type’s accounts. What each panel keeps to itself, and what it does not:

  • Sessions are per panel. A session belongs to the panel that signed the user in; another panel’s gate treats the request as anonymous (AuthSession).
  • Accounts and credentials are not. A sign-up on one panel writes an account every sibling panel looks up. The same password signs in to each panel that admits the user, and a password change or reset on one ends the user’s sessions and reset links on each.
  • Access is the user type’s to decide, per panel. PanelUser::can_access_panel receives the panel’s PanelId, so one type can admit staff to /admin and every customer to /portal. A PanelId equals its prefix in any spelling, "admin" or "/admin/", and offers no string to match a part of. Name each panel and answer false for the rest: a panel added or renamed later then admits nobody until it has a rule.
  • A second factor is shared too. A factor set up on one panel is asked on every sibling that installs Auth::two_factor, so a password alone neither signs in there nor sets up a factor of its holder’s. Turning it off on one panel turns it off on all, and takes a code.
  • The weakest panel is the floor. Email verification, two-factor sign-in, requiring a factor and tenant registration are each declared per panel. A sibling without Auth::two_factor asks no account for a code, so a password alone signs in there. An account that holds no factor signs in to every sibling with its password, and one that requires a factor lets the holder set up their own, which then stands on each. A sibling that mails no codes asks an account set up for mailed codes for a recovery code.

The sharing follows the user type, not the table. Two user types over one table share passwords, yet a password change on one type’s panel ends no session on the other’s. To give two panels separate credentials, give each its own user type, over its own table, with its own Authenticator: a staff password then signs in to no customer panel, and a customer panel’s weaker sign-in reaches no staff account.

Several panels, one origin

Each panel keeps its session in its own cookie, and the page a request comes from decides which cookie counts. That decides which session a request means; it does not separate panels. They share an origin, so a script running on one panel’s page, or on any page of the host app, can send requests to another panel as whoever the browser is signed in as there. HttpOnly keeps the cookie from being read, not from being sent.

Put panels of different trust on separate hosts. One binary serves both when each panel names its host:

builder.panel(Panel::new("admin").host("admin.example.com"))?;
builder.panel(Panel::new("app").host("app.example.com"))?;

A panel bound with Panel::host answers 404 on every other host: its pages, its sign-in, the directories it serves and its runtime endpoints. No admin session starts on the customer host, and __Host- cookies stay on the host that set them, so a cross-site script on the customer panel has no admin session to use. Point both names at the binary, and have the reverse proxy pass the browser’s Host header on: the panel reads no X-Forwarded-Host.

The app’s own routes outside the panels still answer on both hosts. A script injected on one of them at the admin host acts on the admin panel, so keep what the admin host serves as trusted as the panel.

Responses

  • Headers. Every response under the panel prefix carries a Content-Security-Policy that loads script files from the panel’s origin only and lets no other site frame the panel or receive its forms, along with X-Content-Type-Options: nosniff, Referrer-Policy: same-origin and Cache-Control: no-store, so the back button after sign-out shows no record. The policy does not stop an injected script; escaping does. Topcoat’s live regions need 'unsafe-inline' and its client expressions need 'unsafe-eval', so dropping either breaks the panel, as Panel::DEFAULT_CONTENT_SECURITY_POLICY details. What a custom policy can tighten is where an injected script sends data: with no images, fonts or media on other hosts, set img-src, font-src and media-src to 'self' plus the data: and blob: sources the default has. Panel::content_security_policy replaces the policy, for assets on another origin or a panel framed by an intranet, and lists the responses the headers miss. Behind a proxy that serves HTTPS only, turn on HSTS with Panel::strict_transport_security.
  • Compression. Pages are compressed, and a page shows text the URL chooses, such as a search. An observer of the encrypted traffic who also makes the browser load chosen URLs can guess, from response sizes, a value that repeats on every load of such a page (BREACH). The panel’s own secrets change on each render: a form carries the CSRF token masked afresh (csrf::mask), and an upload’s URL is signed under a new nonce. A record’s values do repeat, so a column showing a secret, such as an API key, exposes it on the list page. Compression::disable() on the router turns compression off; a proxy that compresses has the same exposure.
  • Search engines neither index a panel’s pages nor follow their links, per the robots tag Panel documents.
  • Redirects. Return Err(redirect(..)) (307) from a GET and Err(see_other(..)) (303) after a write, so a reload does not repeat it. A redirect raised after streaming started becomes a window.location.replace. A failed page load shows the panel’s error page; wrap part of a page in error_boundary to show a fallback in its place instead.
  • Notifications are one-time flash cookies set on the redirect after a write and consumed by the next page, so a reload does not show them again.
  • Rich text is the one stored value Tablo renders as HTML, cleaned to the elements its toolbar’s tools produce. A page of your own renders one through rich_text::clean, never unescaped as stored.

Uploaded files

  • A file field stores only a value that came from a file part, never a path typed into the form, and renders a stored value as a link only when it is a root-relative path or an http(s) URL: Uploader.
  • Panel::uploads_dir serves a file only at a signed URL that expires within two hours, which a page renders after checking the user may see the record, so a link copied into a chat or a log stops working. The signature covers a path, not a record: a column showing a value users type signs whatever path they type, so show stored uploads only from file fields: Panel::uploads_dir.
  • Files served with Panel::serve_dir or uploads_dir share the panel’s origin, so they carry headers that make an uploaded HTML or SVG file download instead of running script. A serve_dir directory is public unless it sits under the panel prefix: Panel::serve_dir.