Skip to content

fix(hsts): only award preload bonus when max-age meets the hstspreload.org 2-year minimum#87

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

fix(hsts): only award preload bonus when max-age meets the hstspreload.org 2-year minimum#87
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-gssf9y

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Summary

The HSTS preload bonus (+2 points) was awarded whenever preload appeared in the header and max-age > 0. But hstspreload.org actually requires max-age ≥ 63072000 (2 years). A site with max-age=31536000; includeSubDomains; preload would receive a perfect HSTS score (20/20) even though it cannot be submitted to the preload list.

Changes:

  • src/rules.ts: Gate the +2 preload bonus on maxAge >= 63072000. When the directive is present but the age is too short, emit a finding and recommendation explaining the shortfall instead of silently awarding credit.
  • test/analyzer.test.ts: Update three tests that assumed max-age=31536000 + preload should earn a perfect 20/20 HSTS score (they now use 63072000). Add one new dedicated test that asserts a finding is emitted — and no bonus awarded — when preload is set with an insufficient max-age.

Before:

max-age=31536000; includeSubDomains; preload  →  score 20/20 ✓  (misleading)

After:

max-age=31536000; includeSubDomains; preload  →  score 18/20  +  finding: "preload is set but max-age=31536000 is below the 63072000 (2 year) minimum required by hstspreload.org"
max-age=63072000; includeSubDomains; preload  →  score 20/20 ✓

All 86 tests pass (85 prior + 1 new).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WpgTDYqyYdTqvMqXEhL6A9


Generated by Claude Code

…g 2-year minimum

The preload +2 bonus was awarded for any max-age > 0 with a preload
directive. hstspreload.org requires max-age >= 63072000 (2 years), so
sites with max-age=31536000 (1 year) were receiving a misleading bonus
for a preload status they could not actually attain.

Now the bonus is only awarded when max-age >= 63072000; a finding and
recommendation are emitted otherwise. Updated three existing tests that
assumed max-age=31536000 + preload earned a perfect HSTS score, and
added a dedicated test for the new behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpgTDYqyYdTqvMqXEhL6A9
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