espressostreamdocs
On this page

Security

This page covers what espressostream does to protect recordings, accounts and visitors, and what you should check when you run a server. The server's test suite checks the access rules and headers below (internal/web/security_test.go).

On your machine

  • espresso rec records only on your machine and never uploads by itself. Keyboard input is not recorded unless you pass --record-input.
  • Before uploading, espresso upload shows what will be sent and lists likely secrets. Under --yes, it refuses to upload when it finds any, unless you add --allow-secrets.
  • Markers from shell integration contain your command lines. A secret typed as an argument ends up in a marker as well as in the output.
  • espresso auth login stores your token in a file that only you can read (mode 0600).
  • The exec trace (--trace-exec) never records environment variables.
  • espresso stream --local has no login: anyone who can reach the address can watch. By default it listens on 127.0.0.1 only.
  • The players never touch your clipboard. Clipboard escape sequences (OSC 52) in a recording are ignored. Links in a recording don't open by themselves; a viewer has to click them.

Who can see what

  • Public: listed on the home page, the owner's profile and in search; anyone can watch.
  • Unlisted: anyone who has the link (the id is random, 100 bits) can watch it; it is not listed or searchable by others, and pages carry noindex.
  • Private: only the owner, signed in or with their token. Admins can't see it either. Embeds and oEmbed refuse private recordings even for the owner, because an embed can't know who is watching.

A refused read is always 404, never 403, so no one can tell whether a private id exists. Changing or deleting a recording needs its owner: a session plus a CSRF token, or a bearer token with full scope. Everyone else gets 404. Tokens with upload scope can only upload.

Read access

Actor × visibility page /r/{id} cast .cast trace .trace.jsonl meta GET /api/v1/recordings/{id} embed /e/{id} oEmbed /oembed live stream /s/{id}, watch search (/search, /api/v1/search)
anon × public 200 200 200 200 200 200 200 listed
anon × unlisted 200 200 200 200 200 200 200 not listed
anon × private 404 404 404 404 404 404 404 not listed
other × public 200 200 200 200 200 200 200 listed
other × unlisted 200 200 200 200 200 200 200 not listed
other × private 404 404 404 404 404 404 404 not listed
admin × public 200 200 200 200 200 200 200 listed
admin × unlisted 200 200 200 200 200 200 200 not listed
admin × private 404 404 404 404 404 404 404 not listed
owner × public 200 200 200 200 200 200 200 listed
owner × unlisted 200 200 200 200 200 200 200 listed (own)
owner × private 200 200 200 200 404 404 200 listed (own)

Notes:

  • Embeds and oEmbed are 404 for a private recording even for the owner. An embed is served without cookies, so it can't know who is viewing, and a private recording must never appear on another site.
  • Search returns public recordings plus the viewer's own recordings of any visibility. Unlisted recordings belonging to others are never listed.
  • /u/<name> shows public recordings to everyone, and all of the user's recordings (with unlisted/private badges) to that user only.
  • Private live streams follow the same rule: the page and the watch socket are 404 to everyone but the owner.

Write access

Actor PATCH /api/v1/recordings/{id} POST /api/v1/recordings/{id}/edit DELETE /api/v1/recordings/{id} form POST /r/{id}/meta GET /r/{id}/delete (confirm)
anon 401 401 401 403 (no CSRF token) 303 → /login?next=…
other 404 404 404 404 404
admin 404 404 404 404 404
owner 200 200 204 303 200

This is the same for every visibility. A non-owner gets 404 (not 403) here as well. API calls need either a bearer token with full scope (an upload-scope token gets 403 "this token may only upload") or the session cookie plus a valid X-CSRF-Token header.

CSRF

  • Every state-changing form (/login, /signup, /logout, /settings/*, /r/{id}/meta, /r/{id}/delete, /admin/*) needs a csrf form field. When signed in, it is the session's token. When signed out (login/sign-up), it is a double-submit token that must match the esp_csrf cookie. Without a token the form returns 403.
  • A request whose Origin header names another origin is refused with 403, even if the token is right.
  • API calls made with the session cookie need X-CSRF-Token. A missing header means the cookie is not accepted as credentials (401). A wrong header gives 403. Bearer-token calls don't use cookies and need no token.
  • Form bodies are capped at 64 KB.

Sessions and cookies

  • esp_session and esp_csrf are HttpOnly, SameSite=Lax and Path=/. They are Secure when --base-url is https://…, when the request came over TLS, or when a trusted proxy (--trusted-proxies) sends X-Forwarded-Proto: https.
  • The database stores only a hash of the session id. Every sign-in creates a new session, which expires after --session-ttl (default 30 days). Expired sessions are purged by the hourly sweep.
  • Changing a password signs out the user's other sessions. admin set-password signs them out everywhere. On /settings a user can sign out all other sessions and revoke API tokens.
  • Passwords are hashed with argon2id (19 MiB, t=2, p=1), with at most 2 hashes running at once. A password must be 10–256 characters. Unknown users still cost one hash, so timing doesn't reveal which names exist.
  • Sign-in is rate limited per user (default 5/min) and at 2× that per IP. Sign-up is rate limited per IP. Sign-up is closed by default (--signup); invites are hashed, single use and expiring.

Response headers

Every response has:

  • X-Content-Type-Options: nosniff
  • Referrer-Policy: same-origin
  • Cross-Origin-Opener-Policy: same-origin
  • Permissions-Policy: camera=(), microphone=(), geolocation=(), interest-cohort=()
  • X-Frame-Options: DENY and CSP frame-ancestors 'none'. The only exception is a successful /e/{id}.

Content-Security-Policy:

  • Pages: default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; style-src-attr 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; font-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'. There are no inline scripts and no eval. 'wasm-unsafe-eval' lets the player's Sixel decoder compile WebAssembly, and nothing else. style-src-attr is needed for the terminal renderer's per-cell styles.
  • Data (.cast, trace, JSON API, oEmbed, API errors): default-src 'none'; sandbox; frame-ancestors 'none'.
  • Embed (/e/{id}): the page policy, with form-action 'none' and frame-ancestors <--embed-ancestors> (default *). The value is checked so it can't inject another directive. The embed page sets no cookies. The player needs connect-src 'self' to fetch the recording and 'wasm-unsafe-eval' to decode images.

Signed-in pages send Cache-Control: private, no-cache and Vary: Cookie, so shared caches don't store them.

Escaping

Titles, descriptions, user names, search queries and text from inside recordings are rendered with html/template everywhere, including the search snippets, the delete confirmation and the embed page. The html field of an oEmbed response is built with escaping as well. The test stores <script>…</script>"'&<img onerror> in a title, a description and the cast output, then checks every page that shows them.

Limits

Sizes, durations, quotas and rate limits (429 with Retry-After) are listed in Configuration.

Checklist for operators

  • Run behind TLS. Set ESPRESSO_BASE_URL=https://…, so sign-in cookies are always Secure.
  • Set ESPRESSO_TRUSTED_PROXIES to your proxy's own address only (e.g. 127.0.0.1/32), never to a network that clients can reach.
  • Keep sign-up closed or invite unless you want strangers to store data on your server. If you open it, set --quota.
  • Restrict who may embed with --embed-ancestors if recordings shouldn't appear on other sites.
  • Give CI and agents --scope upload tokens, and revoke tokens you no longer use (admin list-tokens, admin revoke-token).
  • Back up the data directory (espresso-server backup) and practise a restore.
  • Run the server as an unprivileged user. The Docker image already runs as uid 65532 with a read-only root filesystem in the example compose file.

Reporting a problem

Please report security issues privately to the maintainers of your espressostream copy, not in a public issue.