feat(security): add security response headers - #753
Draft
dgaponov wants to merge 1 commit into
Draft
Conversation
The site sent no security headers at all: no HSTS, X-Content-Type-Options,
X-Frame-Options, Referrer-Policy or Permissions-Policy, and it disclosed
its framework via X-Powered-By.
Adds a headers() rule for all routes plus poweredByHeader: false.
Two deliberate deviations from the usual boilerplate:
- X-Frame-Options is SAMEORIGIN, not DENY. SandboxBlock embeds
`${window.location.origin}/sandbox/<libId>/<componentId>` in an iframe on
every component page, and DENY blocks same-origin framing too, so DENY
would break every live component demo.
- HSTS omits `preload`. Submitting to the preload list is effectively
irreversible, and max-age is 1 year rather than 2. `includeSubDomains` is
set, which assumes every subdomain is HTTPS-only — verify before deploy.
CSP is not included; it needs its own pass to build an allow-list for
storage.yandexcloud.net and GTM.
Verified in dev and in a production build: all five headers present on
pages and on the sandbox route, X-Powered-By gone everywhere, and the
sandbox iframe still loads and hydrates (checked in a real browser:
contentDocument accessible, no framing errors in console). Build, lint and
typecheck pass. E2E not run — Playwright browsers are not installed locally.
Co-Authored-By: Claude Opus 5 (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.
Сайт не отдавал ни одного заголовка безопасности и раскрывал фреймворк через
X-Powered-By. Добавлены HSTS,X-Content-Type-Options,X-Frame-Options,Referrer-Policy,Permissions-Policy+poweredByHeader: false.Два отступления от шаблона:
X-Frame-Options: SAMEORIGIN, неDENY—SandboxBlockвстраивает same-origin iframe на каждой странице компонента,DENYсломал бы все демо.preloadи на год, а не на два: попадание в preload-список необратимо.includeSubDomains. Если какой-то поддомен отдаётся по HTTP, он станет недоступен, и браузеры запомнят это на год. Скажите — уберу.CSP не добавлял, ему нужен отдельный allow-list под
storage.yandexcloud.netи GTM.🤖 Generated with Claude Code