Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP Strict-Transport-Security header to unknown URLs #62

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

MahmudH
Copy link
Contributor

@MahmudH MahmudH commented Feb 1, 2024

  • This sets the HSTS header to the domain within VCL
  • Enables consistency throughout the CDN.

Trello: https://trello.com/c/0TgCOgbX/3397-3-configure-fastly-to-always-append-an-hsts-header

sengi
sengi previously approved these changes Feb 5, 2024
Copy link
Contributor

@sengi sengi left a comment

Choose a reason for hiding this comment

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

The idea SGTM, but I have a couple of practical concerns about merging this as-is:

  • do we plan to remove the HSTS stuff from apps? (I think we'll need to, otherwise we're duplicating the config for this important header, which just seems unnecessarily risky.)
  • why the super short max-age?

modules/www/www.vcl.tftpl Outdated Show resolved Hide resolved
@@ -452,6 +452,11 @@ sub vcl_miss {
}

sub vcl_deliver {
# Add the HSTS header with a max-age of 5 mins to URLs that don't exist
if (!(resp.http.Strict-Transport-Security)) {
set resp.http.Strict-Transport-Security = "max-age=300"; includeSubDomains; preload
Copy link
Contributor

Choose a reason for hiding this comment

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

HSTS with max-age=300 doesn't seem useful to me — what's the rationale here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see from the notes on the internal-only Trello card that you plan to set this to 300 and then increase it later, but that doesn't make any sense to me given that we're already serving HSTS headers with an appropriately-long max-age (strict-transport-security: max-age=31536000; preload).

@sengi sengi self-requested a review February 5, 2024 10:39
@sengi sengi dismissed their stale review February 5, 2024 10:40

didn't mean to approve there, sorry — comments kinda need addressing before merge

@MahmudH MahmudH force-pushed the add-hsts-to-unknown-url branch from 0584a72 to 8f2acaf Compare February 19, 2024 12:35
@sengi
Copy link
Contributor

sengi commented Feb 20, 2024

tl;dr:

  • HSTS affects a whole domain, not individual pages/paths.
  • We currently have a slight inconsistency in how we're serving the HSTS header, for example we're not serving it on some 404 responses.
  • We don't want to be serving conflicting or inconsistent HSTS headers (for any given domain).
  • We should therefore configure the HSTS header at CDN so that it's trivial to see that it's correct.
  • The value needs to be the same as the one we're currently serving, so we don't break stuff or make the inconsistency worse.

@MahmudH MahmudH force-pushed the add-hsts-to-unknown-url branch from 8f2acaf to f530131 Compare February 20, 2024 18:56
modules/www/www.vcl.tftpl Outdated Show resolved Hide resolved
- This sets the HSTS header to the domain within VCL
- Enables consistency throughout the CDN.
@MahmudH MahmudH force-pushed the add-hsts-to-unknown-url branch from f530131 to d843f88 Compare February 21, 2024 16:57
@MahmudH MahmudH merged commit 88e5231 into main Feb 22, 2024
4 checks passed
@MahmudH MahmudH deleted the add-hsts-to-unknown-url branch February 22, 2024 10:20
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