fix(security): set anti-framing headers at the server level#26
Open
camreeves wants to merge 2 commits into
Open
fix(security): set anti-framing headers at the server level#26camreeves wants to merge 2 commits into
camreeves wants to merge 2 commits into
Conversation
Add `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'` to the default server block. The headers propagate to every location that doesn't declare its own `add_header` directives — i.e. to the HTML surface (front-end SPAs, login screens, static assets) where clickjacking is a concern. Locations with their own `add_header` directives (the `/api/*` CORS preflight handlers, the `/auth/` CORS branch, the `if ($secure_static)` branch under `/`) do not inherit the new headers — those responses are JSON or otherwise not a framing target. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Add
X-Frame-Options: DENYandContent-Security-Policy: frame-ancestors 'none'to the default server block inconfig/nginx.conf.template. The headers propagate to every location that doesn't declare its ownadd_headerdirectives — i.e. to the HTML surface (frontend SPAs, login screens, static assets) where clickjacking is a concern.Locations with their own
add_headerdirectives (the/api/*CORS preflight handlers, the/auth/CORS branch, theif ($secure_static)branch under/) do not inherit the new headers per Nginx's add_header inheritance rules. Those responses are JSON or otherwise not a framing target, so the loss is intentional.Behaviour
/,/staff/*,/concierge/*,/backoffice/*(frontend SPAs, HTML)DENY'none'/auth/*proxied to auth service (login, oauth pages)DENY(unless CORS branch fires)'none'(unless CORS branch fires)/login,/index.html, static assets vialocation ~* ^/(favicon\.ico|...)DENY'none'/api/*JSON responses with their ownadd_header/monitor/proxied to KibanaDENY'none'Backwards compatibility
frame-ancestors 'none'is identical in effect toX-Frame-Options: DENY— both deny framing entirely. Any deployment that needs to embed the UI in another origin will need to relax either policy. None of the existing PlaceOS hosted UIs frame each other from a different origin, so no expected breakage.🤖 Generated with Claude Code