Files
token-circles/SECURITY.md
T
Komediruzecki f1d2da0a04 security: fix category IDOR, add security headers and rate limits
Security-critical audit batch for the Worker backend.

S1 — cross-user category disclosure (IDOR). Several reads joined the
categories table without scoping it to the row's profile, and category_id is
a client-supplied foreign key that isn't ownership-checked on write. A user
could reference another user's category id (ids are global sequential
integers) and read back its name/color via /api/bills, /api/recurring,
/api/budgets/improvements and /api/categories/mappings. Every category JOIN
is now scoped with `AND c.profile_id = <parent>.profile_id`, so a foreign id
resolves to NULL instead of leaking.

S2 — no security headers. The API set none. Added Hono secureHeaders on all
responses: a CSP that allows inline styles (for the transactional HTML pages)
but no scripts and forbids framing, plus HSTS, X-Frame-Options: DENY,
X-Content-Type-Options: nosniff and Referrer-Policy. Added frontend/public/_headers
(served with the static app) with framing/sniffing/transport protections; a
full content CSP for the SPA is deferred as a browser-tested follow-up because
it must account for the Stripe/Turnstile/Google integrations.

S3 — unthrottled expensive/destructive endpoints. Added per-user rate limits
(the existing D1 limiter) to the imports, PDF/report generation and full data
export endpoints, and to the destructive clear-all / profile-data reset /
reseed-demo endpoints.

Also rewrote SECURITY.md, which described the deprecated Express app (bcrypt,
Helmet, sessions), to reflect the Worker reality (PBKDF2 JWT, the headers
above, the real rate-limit and authorization model).

Adds worker regression tests proving the category name no longer leaks and
the headers are present.
2026-07-12 15:55:37 +02:00

2.6 KiB

Security Policy

Reporting a Vulnerability

If you discover a security vulnerability in Finance Manager, please use GitHub's private vulnerability reporting to disclose it securely. Alternatively, you can open a public issue stating that you found a potential security issue and a maintainer will provide a private channel for details.

Do not include exploit details or sensitive information in public issues.

Supported Versions

Version Supported
5.x (latest) Yes
< 5.0 No

Security Features

These describe the maintained Cloudflare Worker backend (worker/). The legacy Express server (backend/) is deprecated and not deployed.

  • Passwords hashed with PBKDF2-HMAC-SHA256 (WebCrypto), per-user random salt, constant-time verification. Login is protected against user enumeration (a dummy hash is always verified) and rate-limited per IP and per email.
  • Authentication is a stateless HS256 JWT in an HttpOnly, SameSite=Lax, Secure cookie. "Sign out everywhere" is supported by bumping a per-user token version, which invalidates all outstanding tokens.
  • Parameterized SQL everywhere (D1); table/column identifiers in the query helpers are validated against an allowlist regex to prevent injection.
  • Per-request authorization: every data query is scoped to the caller's profile/user; foreign keys supplied by the client (accounts, categories, transactions, receipts, …) are ownership-checked.
  • Security headers on API responses (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy) and on the static app responses.
  • Rate limiting on authentication endpoints and on expensive/destructive endpoints (imports, PDF/report generation, data export, and profile-data reset).
  • CORS locked to a single configured origin with credentials (fails closed if unset).
  • Bot protection via Cloudflare Turnstile on the auth forms.
  • Billing webhooks (Stripe) are verified by signature with a timestamp replay window, and the user's plan is only ever set from a verified webhook — never trusted from the client.

Data storage & encryption

Data is encrypted at rest by the platform (Cloudflare D1 and R2 use AES-256) and in transit via TLS. In the default local-first mode, data never leaves the browser (IndexedDB). End-to-end (zero-knowledge) encryption of synced data is on the roadmap, not yet implemented; see the docs.