docs(security): document HSTS_INCLUDE_SUBDOMAINS and the reach of includeSubDomains - #940
Conversation
|
Thanks for assigning #867, @cevheri! The branch has no conflicts with main. Since this is my first contribution here, the CI workflows are waiting on maintainer approval before they run. Locally |
…ludeSubDomains Closes libredb#867
7e24714 to
2f59929
Compare
|
One thing I'd like a second opinion on. The .env.example comment (and the readHstsIncludeSubDomains() JSDoc) say enabling it on studio.example.com would upgrade unrelated sibling hosts. Per RFC 6797, includeSubDomains covers subdomains of the host that sent the header, so from studio.example.com it reaches *.studio.example.com, not shop.example.com. Siblings are only affected when Studio is served from the parent domain itself. The note describes it that way. Happy to also correct the two comments in this PR, or reword the note if I've misread the intent. |
|
your website is great, love it :) |
|
Thanks @cevheri, and thanks for the kind words about the site :) On the HSTS wording: since this PR is already approved, I'd rather not change its diff. I can open a small follow-up after it merges that corrects the |
Your reading is right, and the note in this PR is the one that matches RFC 6797: includeSubDomains covers names under the host that sent the header, so from studio.example.com it reaches *.studio.example.com, and siblings like shop.example.com are only affected when Studio is served from the parent domain itself. That means the doc you added is now correct and two places in the repo are not: the comment at .env.example:545-546 ("on studio.example.com it would also upgrade every unrelated sibling host") and the JSDoc above readHstsIncludeSubDomains() at src/lib/security/config.ts:65-66. The behaviour they describe is not what the code does on a dedicated host. Let us keep this PR as it is and merge it, since the approval and the green run are on this diff. A separate follow-up Thanks for measuring this instead of copying the existing comment across. |
Description
Adds a note to
docs/SECURITY.mdnamingHSTS_INCLUDE_SUBDOMAINSand what turning it on does, next to the existing notes on row 1.1.Type of Change
Related Issue
Closes #867
Changes Made
max-age(HSTS_MAX_AGE_SECONDS= 15 552 000), cannot be switched off, and is ignored over plain HTTP.includeSubDomainsis opt-in viaHSTS_INCLUDE_SUBDOMAINS=true(defaultfalseinreadHstsIncludeSubDomains()) and that its reach depends on the hostname, with no server-side way to withdraw a cached pin.Testing
Docs-only change. Ran
bun run security:check(20 controls documented, 21 security tests accounted for),bun run format(no changes), and the unit and security tests that read the docs:security-check,env-documentation,agent-documentation,vulnerability-disclosure,credential-at-restand related (232 pass).Checklist
Additional Notes
One thing I'd like a second opinion on. The
.env.examplecomment (and thereadHstsIncludeSubDomains()JSDoc) say enabling it onstudio.example.comwould upgrade unrelated sibling hosts. Per RFC 6797,includeSubDomainscovers subdomains of the host that sent the header, so fromstudio.example.comit reaches*.studio.example.com, notshop.example.com. Siblings are only affected when Studio is served from the parent domain itself. The note describes it that way. Happy to also correct the two comments in this PR, or reword the note if I've misread the intent.