Skip to content

Match the committed HSTS max-age to what the edge serves - #42

Merged
FlyOverCoderKY merged 1 commit into
mainfrom
claude/hsts-max-age-reconcile
Jul 30, 2026
Merged

FlyOverCoderKY merged 1 commit into
mainfrom
claude/hsts-max-age-reconcile

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Follow-up to #41. Zone-wide HSTS is now enabled in Cloudflare (SSL/TLS → Edge Certificates: includeSubDomains, preload, 12 months), so the Worker's /api/* responses carry the header too — verified live on both https://pegma.dev/ and https://pegma.dev/api/health.

That surfaced a mismatch. Cloudflare's longest max-age option is 12 months and the zone setting overrides public/_headers, so the committed 63072000 (2 years) was never what visitors actually received. This lowers it to the 31536000 the edge serves, so the committed header is honest about production, and adds a comment recording why a longer value here would be pointless.

src/security-headers.test.ts already asserts a one-year floor rather than an exact value, so it covers the new value unchanged.

Preloading: deliberately declined

The apex was not submitted to hstspreload.org. That site now states plainly that "HSTS preloading is not recommended" — Chrome and Safari already upgrade all HTTP navigations to HTTPS regardless of HSTS policy, so preloading only helps when that upgrade fails against an active on-path attacker, while list entries are hardcoded into Chrome and take months to add or remove. The domain does meet all four submission requirements (valid certificate, http://pegma.dev → 301 → HTTPS, www serves HTTPS, and the header carries max-age ≥ 31536000 with includeSubDomains and preload) should that trade ever look worthwhile. The preload token stays to match the zone setting; it is inert without a list submission.

Both changes are recorded against the HSTS finding in docs/securityscan.md.

Verification

  • npm run check — clean
  • npm test — 191 tests passing (node) + D1 suite passing
  • npm run build — 11 pages built

🤖 Generated with Claude Code

Zone-wide HSTS is now enabled so the Worker's /api/* responses carry the
header too, but Cloudflare's longest max-age option is 12 months and the
zone setting overrides this file. The committed 63072000 was therefore
never what visitors received; lower it to the 31536000 actually served so
the file is honest about production.

The header test already asserts a one-year floor, so it covers this value
unchanged. Records the zone-wide enablement and the decision not to submit
the apex to hstspreload.org in the scan report.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 30, 2026 01:34
@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Grok Grok Build Review — no issues

Review complete. No issues found — the changes look solid.

This pull request correctly reconciles the committed HSTS max-age with the value Cloudflare’s zone setting actually serves. The reduction from 63072000 to 31536000 is exact (365 days), satisfies the existing one-year floor in src/security-headers.test.ts, and is documented with an accurate operator rationale in both public/_headers and docs/securityscan.md. No correctness, security, or maintainability defects are present in the diff.

Reviewed commit 2035e8e · workflow run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the repository’s committed HSTS policy with what production actually serves now that zone-wide HSTS is enabled in Cloudflare, and documents the operational/security rationale in the security scan report.

Changes:

  • Update public/_headers HSTS max-age from 2 years (63072000) to 1 year (31536000) to match Cloudflare’s zone-wide setting.
  • Add an explanatory comment in _headers describing why a longer committed value would be overridden anyway.
  • Expand docs/securityscan.md to record the follow-up decision: zone-wide HSTS enabled and HSTS preloading deliberately declined, while keeping the preload token to match the zone setting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
public/_headers Lowers committed HSTS max-age to match the Cloudflare edge value and documents the override rationale inline.
docs/securityscan.md Records the follow-up outcome for the HSTS finding (zone-wide enablement, max-age alignment, and preload decision).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@FlyOverCoderKY
FlyOverCoderKY merged commit 7e16e21 into main Jul 30, 2026
3 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the claude/hsts-max-age-reconcile branch July 30, 2026 01:39
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