Skip to content

fix(security): set anti-framing headers at the server level#26

Open
camreeves wants to merge 2 commits into
mainfrom
security/clickjacking-headers
Open

fix(security): set anti-framing headers at the server level#26
camreeves wants to merge 2 commits into
mainfrom
security/clickjacking-headers

Conversation

@camreeves
Copy link
Copy Markdown

Summary

Add X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' to the default server block in config/nginx.conf.template. The headers propagate to every location that doesn't declare its own add_header directives — i.e. to the HTML surface (frontend 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 per Nginx's add_header inheritance rules. Those responses are JSON or otherwise not a framing target, so the loss is intentional.

Behaviour

URL pattern New X-Frame-Options New CSP frame-ancestors
/, /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 via location ~* ^/(favicon\.ico|...) DENY 'none'
/api/* JSON responses with their own add_header unchanged (JSON, not framable) unchanged
/monitor/ proxied to Kibana DENY 'none'

Backwards compatibility

frame-ancestors 'none' is identical in effect to X-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

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>
@github-actions github-actions Bot added the type: bug something isn't working label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants