Repository navigation
Send HSTS from the security headers component without preload - #33
Merged
Merged
Conversation
HSTS was emitted by a data-diff helper, so only some save actions sent it, and it carried preload, which is hard to undo. Send it on every production response instead, drop preload, and make includeSubDomains opt-in until every subdomain is confirmed to be HTTPS. 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.
執行規劃 PR-5(S7)第一部分:HSTS。CSP 回報端點另開 PR。
原本 HSTS 由
ArrayHelper::getAttributesMigration()以header()送出,這是比對資料差異的輔助函式,因此只有修改使用者、設定、候選人配置/資料、群組等存檔請求才帶 HSTS,而且帶有難以撤回的preload與includeSubDomains。同一處也送出多餘的Content-Type。修改:
header()。SecurityHeadersBootstrap在APP_ENV=production時,每個回應(含檔案下載)送出Strict-Transport-Security: max-age=31536000。preload。includeSubDomains改為HSTS_INCLUDE_SUBDOMAINS=true才開啟,確認同網域所有子網域皆為 HTTPS 後再設定;HSTS_MAX_AGE可調整,設為 0 停用。.env.example與 CHANGELOG 已更新。部署影響:正式環境改為每個回應都帶 HSTS(一年)。曾收到舊標頭的瀏覽器會保留
includeSubDomains直到原有效期結束;之後的回應不再帶此參數,不會擴大範圍。驗證(dev6,PHP 8.2.35,HEAD
d1cc6e1):SecurityHeadersBootstrapTest10 tests/18 assertions 通過(新增 6 項);新案例在修改前的程式上有 4 項失敗。ArrayHelperTest37 tests/89 assertions 通過。🤖 Generated with Claude Code