Skip to content

feat: add security.txt and security headers for the frontend - #680

Merged
JuliusHenke merged 1 commit into
masterfrom
claude/project-thread-j78zll
Nov 4, 2026
Merged

JuliusHenke merged 1 commit into
masterfrom
claude/project-thread-j78zll

Conversation

@JuliusHenke

Copy link
Copy Markdown
Member

Requested by ju · project thread

Hardening based on the internet.nl website tests for tormap.org and api.tormap.org.

Changes

  • security.txt (RFC 9116) at /.well-known/security.txt on both hosts, pointing to the GitHub advisory form and SECURITY.md. Expires is 180 days after the build (frontend) or the request (backend), so it never goes stale while the project is maintained.
    • Backend: new SecurityTxtController, explicitly permitted for GET in SecurityConfig, covered by SecurityRulesTest.
    • Frontend: small Vite plugin emits the file; it's left out of the service worker precache. firebase.json no longer ignores dot paths, so .well-known/ gets deployed.
  • Frontend security headers on Firebase and in the nginx image (security-headers.conf, included in every location): Content-Security-Policy, X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: no-referrer. The CSP allows scripts only from the own origin, images from the own origin, data:, the CARTO tile host and GitHub avatars, and connections only to the own origin and api.tormap.org. Styles need 'unsafe-inline', because MUI/Emotion inserts <style> elements at runtime and static hosting can't add per-request nonces.
  • Backend default CSP now also sets form-action 'none'.
  • nginx: server_tokens off, charset utf-8 for .well-known, missing .well-known files return 404 instead of index.html.
  • THREAT_MODEL.md documents the frontend CSP and adds a checklist item for new external hosts.

Testing

  • SecurityRulesTest, SecurityTxtControllerTest and the other config/controller tests pass; frontend unit tests (120) and lint pass.
  • Served the build from the pinned nginx-unprivileged image with the new config and checked the headers on /, /assets/, /sw.js and /.well-known/.
  • Loaded the app in Chromium with this CSP (API and tiles mocked): the map, panels, heatmap toggle, search and About dialog work, the service worker registers, and there are no CSP violations. With style-src 'self' only, MUI renders unstyled, which is why 'unsafe-inline' stays.
  • Please click through the Firebase preview channel before merging, especially relay details and the date picker.

Deployment notes

The api.tormap.org reverse proxy should pass through /.well-known/security.txt and the backend's security headers.


Generated by Claude Code

Serve /.well-known/security.txt (RFC 9116) from the backend and the
frontend, pointing to the GitHub advisory form. The frontend hosts
(Firebase and the nginx image) now send a Content-Security-Policy,
X-Content-Type-Options, X-Frame-Options and Referrer-Policy. The
backend's default CSP also restricts form-action.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWRrkKuxAPsQcvYvcdPEZh
@JuliusHenke JuliusHenke added enhancement New feature or request frontend backend labels Nov 3, 2026 — with Claude
@JuliusHenke JuliusHenke self-assigned this Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 397244e):

https://tormap-36f44--pr680-claude-project-threa-se84h1mr.web.app

(expires Fri, 06 Nov 2026 22:42:44 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 0c1f71965de18e60b0e686b0d0356977fec090dc

@JuliusHenke
JuliusHenke merged commit 6834bac into master Nov 4, 2026
16 checks passed
@JuliusHenke
JuliusHenke deleted the claude/project-thread-j78zll branch November 4, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants