Skip to content

Security

Security considerations specific to Booking's design. Configuration flags are documented in Operations → Configuration.

Public, unauthenticated endpoints

By design, the poll voting surface requires no login - the poll URL is the capability:

  • GET /booking/v1/polls/{pollId} (single-poll read)
  • GET/POST /booking/v1/polls/{pollId}/voters (a voter is created together with their ballot)
  • PATCH/DELETE /booking/v1/polls/{pollId}/voters/{voterId}, gated by an edit token (below)
  • POST /booking/v1/polls/{pollId}/voters/{voterId}/edit-link and .../edit-link/redeem (edit-link recovery, below)

This is a deliberate, inherited product decision (see Voting). It makes these routes the service's main abuse target: anyone with a poll id can list its voters, add new ones and trigger an edit-link mail to an entry's address.

The same model extends to Appointment Booking's public routes (page read, slot listing, booking, and the manage-token routes) and to the MCP endpoint at POST /booking/mcp, which exposes that flow as agent tools with the capability ids as tool parameters. The endpoint authenticates nobody by design and is off unless mcp.enabled is set - see MCP endpoint for its contract and ADR-0012 for why it is hosted here.

Voter edit tokens

Creating a voter returns an editToken once, in the POST response. It has the same shape as the booking manage token (base64url(randomBytes(32)), 43 characters) and is stored in voter.edit_token. No poll read or voter listing includes it. Changing or deleting a voter needs one of three things: that token in the X-Voter-Token header, the poll owner's session, or a logged-in App Suite session whose primary address or one of whose aliases equals the voter's mail, ignoring case and surrounding spaces. Anything else gets 403 with code 0x1005. A voter's mail is either empty or one valid address; anything else gets 400. On a poll with mailRequired, creating a voter without an address or setting it to empty also gets 400 with code 0x1. Voters created before the column existed have NULL there, so until they recover their entry with an edit link (below), only the owner or an address match can change them.

The address is unverified, so typing someone else's address into an entry lets that person edit it. It gives the person who typed it nothing beyond the token they already hold. The single-poll read returns viewer.voterIds, the entries the session may change by address, so the page can show their menus without seeing any address.

The poll page keeps the tokens of the entries a browser created in localStorage, per poll.

A participant who lost the token can ask for an edit link: POST /booking/v1/polls/{pollId}/voters/{voterId}/edit-link. It mails a one-time link to the voter's stored mail with the poll-edit-link template. For an existing voter of an open poll it answers 202 {}, whether or not the voter has an address, is inside the cooldown or got a mail, so the answer reveals nothing. The link carries #voter=<id>&recover=<token> in the fragment, which never reaches server logs. The token is 32 random bytes; only its SHA-256 hash is stored in voter.edit_link_hash. Limits:

  • one link per voter every 10 minutes (voter.edit_link_sent_at), on top of the per-IP PUBLIC_WRITE_LIMIT
  • a link expires after 60 minutes, and requesting a new one replaces the old
  • a stored mail that is not exactly one address gets no mail, which covers rows saved before addresses were validated
  • closed polls refuse both steps
  • no mail goes out unless pollBaseURL is set or the request host matches linkOrigins; the service logs a warning instead

The page trades the link for a new edit token with POST .../edit-link/redeem and removes the fragment from the address bar. Redeeming replaces voter.edit_token and clears the link hash, so the link works once and the previous token stops working. A wrong, used or expired link gets 403 with code 0x1006. Voters created before edit tokens existed get their first token this way.

Rate limiting

@fastify/rate-limit is registered with global: false (src/plugins/rate-limit.ts); only the public write endpoints opt in via config: { rateLimit: PUBLIC_WRITE_LIMIT }. The limit is per client IP (request.ip), RATE_LIMIT_PUBLIC_MAX requests per minute (default 60).

The client IP is the TCP peer unless the peer is listed in TRUST_PROXY (src/trust-proxy.ts, passed to Fastify's trustProxy). Only then does X-Forwarded-For count, read from the right and skipping trusted hops. The default trusts no proxy, because a trusted range that also holds clients lets them choose their own key. Behind an ingress with TRUST_PROXY unset, every visitor shares the ingress's bucket, so one client can get everyone else refused. true and hop counts are rejected at startup: the first trusts every peer, and Fastify 5 ignores the second. Operators choose the value per topology, see Client address behind an ingress. 429 responses are mapped by the error handler like any other error, to {code: 9999, message: "Too Many Requests"} on /booking/v1 - see Error contract.

This is hardening the original Java service never had (see the CHANGELOG [Unreleased] entry) and is the main defense against scripted voting abuse.

Ownership and capability gating

Poll owner routes (create/list/update/delete a poll, slot changes, finalize and reopen) require:

  1. A resolved App Suite session (src/plugins/session.ts), and
  2. The booking capability for that user's context (/appsuite/api/capabilities), and
  3. For mutations, that the caller is the poll's recorded owner - cross-owner access returns 403 (POLL_AUTHORIZATION_USER_IS_NOT_OWNER_OF_POLL / 0x102).

Session resolution precedence

session query parameter wins over any cookie. open-xchange-session* cookies are only honored after a route explicitly calls allowCookieOnlySession() - the public poll-read route does this so an invitee who happens to be logged into App Suite is recognized, without making a session a requirement, and the v1 finalize and reopen routes do it so the owner can act from the standalone poll page. Don't flip this precedence: it exists so an owner's session param can't be silently overridden by a stale cookie from a different account in the same browser.

Even then, the cookie only counts for same-origin requests (isSameOriginRequest from @open-xchange/fastify-sdk: Sec-Fetch-Site: same-origin, or a matching Origin, or a safe method when neither header is present). App Suite uses the session parameter as its CSRF token, and the browser sends the session cookie on requests from any page of the same site, sibling subdomains included. Without the origin check, such a page could finalize or reopen a poll in the owner's name.

Input validation

All routes use Fastify JSON Schema validation (AJV). Validation failures are mapped to {code: 0x1, message, errors: [{field, message}]} with HTTP 400 by the same error handler that owns the rest of the error contract.

Outbound calls to App Suite middleware

All calls to /appsuite/api/* go through a single undici client (src/appsuite/client.ts) with a 5-second timeout; network failures and non-2xx responses become SERVICE_NOT_AVAILABLE (0x81, HTTP 503) rather than leaking raw connection errors to callers.

Reporting issues

Follow the process documented at Open-Xchange Security Contact. Do not open public issues for security reports.