Reviewed in November 2026 against the code in lib/session.ts, lib/passwords.ts, lib/rate-limit.ts, lib/api.ts and next.config.ts.
- Session cookie: httpOnly, SameSite=lax, Secure in production, 7-day TTL. The server stores only a SHA-256 hash of the token in Redis (
sess:<hash>), so a Redis dump does not reveal live tokens. - Passwords: bcrypt with cost 11. Reset tokens are single use.
- Rate limits: login (per IP and per email), registration, password reset, OAuth callback. Fixed-window counters in Redis. The limiter fails open if Redis is down, which keeps the site up but removes the limit during an outage.
- Headers: X-Frame-Options DENY, nosniff, Referrer-Policy, Permissions-Policy, and a partial CSP (
frame-ancestors 'none'; object-src 'none'; base-uri 'self') innext.config.ts. HSTS is added by Vercel. - Cross-site writes:
route()rejects POST/PATCH/DELETE whoseOriginis not the app's own. SameSite=lax alone still sends the cookie from sibling subdomains of the same site. - Post-login redirects:
safeNext()parses the target the way a browser does and keeps only same-origin paths (/\evil.comused to pass). - Input validation: zod schemas at every route boundary; errors return 400 with field messages.
- Client IP trust.
clientIp()now usesX-Real-IP(Vercel sets it and overwrites any client value), else the lastX-Forwarded-Forhop. Open question: the site sits behind Cloudflare's proxy, so Vercel may see a Cloudflare edge address instead of the visitor's. In that case every visitor behind the same edge shares one per-IP bucket. Check one request'sx-real-ipin the Vercel logs. If it is a Cloudflare address, either switch the DNS record to DNS-only or decide whether to trustCF-Connecting-IP. Trusting it is only safe if the origin cannot be reached directly through*.vercel.app. - Field encryption. The app stores names, emails, and report locations. Passwords are already hashed, and nothing else is classed as sensitive. Field-level encryption is not added yet: it would break email lookups unless a deterministic hash is kept alongside. Add an AES-256-GCM helper only if the data changes (for example phone numbers or ID documents).
- Fail-open limiter. Acceptable for availability; add an alert on Redis errors (the health endpoint already reports Redis as unreachable).
- Secrets. Rotate any secret that appeared in chat or logs: the database password and the Facebook app secret.
- No email verification. Anyone can register with an address they do not own. A later Google sign-in with that verified address is linked to the existing account, whose password the first registrant still knows (account pre-hijacking). Registration also answers 409 for a taken address (enumeration). Both need a product decision: verify the address before activating password accounts, or refuse to link OAuth to password accounts that were never verified.
- Content-Security-Policy. There is no
script-srcpolicy yet. A strict one needs per-request nonces (Next.js middleware). Try it inContent-Security-Policy-Report-Onlyfirst, because MapLibre workers, Vercel Analytics and inline Next scripts all need allowances. - PDF attachments are served inline from the app origin. Browser PDF viewers sandbox them, but serving them from a separate domain or with
Content-Disposition: attachmentwould remove the residual risk.