Repository navigation
Send security headers: CSP, no framing, HSTS on HTTPS - #49
Merged
Merged
Conversation
Every response now carries a Content-Security-Policy that allows only openRun's own scripts (the inline theme script by hash) and OpenStreetMap tiles, forbids framing (clickjacking), and on HTTPS asks browsers never to use plain HTTP. The Referrer-Policy sends only the origin elsewhere, which OpenStreetMap's tile servers require. Zod's fast path probes eval, which the policy blocks, so the web app turns it off before any schema is created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Fly guide puts instances on the public internet, and openRun sent no security headers: any site could frame it (clickjacking), and nothing limited what scripts a page could run.
What changed
apps/api/src/security-headers.ts, using Hono'ssecureHeaders, on every response:index.htmlallowed by its hash (read from the built page at startup, so editing the script can't break it). Images, fetches and workers from openRun,data:/blob:where needed (logo preview, MapLibre), andhttps://tile.openstreetmap.org.frame-ancestors 'none',object-src 'none',base-uri/form-action 'self'. Styles allow inline (react-easy-crop adds a<style>tag).nosniff, COOP/CORP same-origin and so on).ORIGINis HTTPS, so plain-HTTP local installs are unaffected.no-referrer: OpenStreetMap's tile servers require a Referer, and this sends the origin, never the path.new Function, which the policy blocks and the browser reports on every page.apps/web/src/zod-config.tsturns it off, imported first because Zod probes as each schema is created.Checks
🤖 Generated with Claude Code