Skip to content

fix(hsts): don't award preload credit when includeSubDomains is absent#81

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-3xpxk1
Open

fix(hsts): don't award preload credit when includeSubDomains is absent#81
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-3xpxk1

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Problem

The checkHSTS rule awarded +2 for the preload directive independently of includeSubDomains. This means a header like:

Strict-Transport-Security: max-age=31536000; preload

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, and preload. A preload directive without includeSubDomains is rejected by the preload list and is essentially inert.

Fix

  • The +2 preload bonus is now only awarded when includeSubDomains is also set (the only config that is actually preload-eligible).
  • When preload appears without includeSubDomains, a targeted finding is emitted instead:

    "preload requires includeSubDomains — this config is not eligible for the HSTS preload list"

Before / After:

Header value Before After
max-age=31536000; includeSubDomains; preload 20 ✅ 20 ✅
max-age=31536000; includeSubDomains 18 ✅ 18 ✅
max-age=31536000; preload (no ISD) 17 ✅ (misleading) 15 + finding ✅

Changes

  • src/rules.ts — gate the preload bonus on hasIncludeSubDomains; 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 for preload-without-includeSubDomains

All 86 tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Szyfsw63nhZSYXqfq2269F


Generated by Claude Code

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants