fix(hsts): don't award preload credit when includeSubDomains is absent#81
Open
dmchaledev wants to merge 1 commit into
Open
fix(hsts): don't award preload credit when includeSubDomains is absent#81dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
The HSTS preload list (hstspreload.org) requires both includeSubDomains and preload. Previously, a header like `max-age=31536000; preload` (without includeSubDomains) scored 17/20 as 'good' despite being ineligible for preload — misleading operators into thinking their config was preload-ready. Now the preload bonus is only awarded when includeSubDomains is also set. When preload appears alone, a targeted finding is emitted instead. Adds a test asserting the corrected score (15) and the new finding. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Szyfsw63nhZSYXqfq2269F
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.
Problem
The
checkHSTSrule awarded+2for thepreloaddirective independently ofincludeSubDomains. This means a header like:scored 17/20 (
'good') despite being ineligible for the HSTS preload list — misleading operators into thinking their configuration was preload-ready when it isn't.The HSTS preload list explicitly requires all three of: a
max-age≥ 1 year,includeSubDomains, andpreload. Apreloaddirective withoutincludeSubDomainsis rejected by the preload list and is essentially inert.Fix
+2preload bonus is now only awarded whenincludeSubDomainsis also set (the only config that is actually preload-eligible).preloadappears withoutincludeSubDomains, a targeted finding is emitted instead:Before / After:
max-age=31536000; includeSubDomains; preloadmax-age=31536000; includeSubDomainsmax-age=31536000; preload(no ISD)Changes
src/rules.ts— gate the preload bonus onhasIncludeSubDomains; emit a finding otherwise (~10 lines)test/analyzer.test.ts— rename existing preload test for clarity; add a new test asserting the corrected score (15) and the new finding forpreload-without-includeSubDomainsAll 86 tests pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Szyfsw63nhZSYXqfq2269F
Generated by Claude Code