Skip to content

Document best practice security headers option always with redirect (defense in depth) #23

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

Open
janwillemstegink opened this issue Mar 8, 2025 · 8 comments

Comments

@janwillemstegink
Copy link

janwillemstegink commented Mar 8, 2025

https://en.internet.nl/site/www.workingornot.org/3182705/#

Image

https://en.internet.nl/site/workingornot.org/3182706/

Image

.htaccess content:

SetEnv no-gzip 1
Header always set Strict-Transport-Security "max-age=63072000"
Header set X-Content-Type-Options nosniff
Header set X-Xss-Protection "1; mode=block"
Header set Referrer-Policy same-origin
Header set X-Frame-Options SAMEORIGIN
Header set Content-Security-Policy "default-src 'none'; base-uri 'none'; frame-src 'self'; connect-src 'self'; form-action 'self'; font-src 'self' data: https://fonts.googleapis.com https://fonts.gstatic.com; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; style-src 'unsafe-inline' 'self' data:; style-src-elem 'self' 'unsafe-inline' data: https://fonts.googleapis.com;"
Header set Permissions-Policy geolocation=()

Options +Indexes

<If "! (%{HTTP_HOST} =~ /^www.workingornot.org$/)">
Redirect 302 / https://www.workingornot.org/

ErrorDocument 404 /404.html

Redirect 302 /.well-known/security.txt https://janwillemstegink.nl/.well-known/security.txt

With escaping of dots visible in an image:

Image

@WKobes
Copy link

WKobes commented Mar 11, 2025

@janwillemstegink
Copy link
Author

An defense-in-depth measure is no problem for me.

  1. The question remains how to test and warn effectively.
  2. Tuning testing (per security header type) may be a challenge for internet.nl.
  3. The red colors on securityheaders.com, without following the redirect, also raises questions:
    https://securityheaders.com/?q=https%3A%2F%2Fworkingornot.org%2F

Image

@janwillemstegink
Copy link
Author

janwillemstegink commented Mar 11, 2025

For me it now works in index.php as can be seen with https://internet.nl/site/workingornot.org/3186198/#

Image

@janwillemstegink
Copy link
Author

  • Maybe a new kind of redirect could be done right after httpd;
  • Apache could do it with a new redirect option in .htaccess;
  • Scott Helme, behind securityheaders.com, will have his thoughts.

@janwillemstegink
Copy link
Author

Indeed 'always' works:

Header always set Strict-Transport-Security "max-age=63072000"
Header always set X-Content-Type-Options nosniff
Header always set X-Xss-Protection "1; mode=block"
Header always set Referrer-Policy same-origin
Header always set X-Frame-Options SAMEORIGIN
Header always set Content-Security-Policy "default-src 'none'; base-uri 'none'; frame-src 'self'; connect-src 'self'; form-action 'self'; font-src 'self' data: https://fonts.googleapis.com https://fonts.gstatic.com; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; style-src 'unsafe-inline' 'self' data:; style-src-elem 'self' 'unsafe-inline' data: https://fonts.googleapis.com;"
Header always set Permissions-Policy geolocation=()

@bwbroersma
Copy link
Collaborator

Maybe move this ticket to internetstandards/toolbox-wiki/?

@janwillemstegink
Copy link
Author

janwillemstegink commented Mar 15, 2025

https://securityheaders.com/?q=https%3A%2F%2Fwww.securityheaders.com%2F

Knowledge transfer should work after an issue like: Document please required stabilization having 'always' in security headers.
Visually comparing http headers colors becomes possible if internet.nl implements two columns: Without www and with www

The tool securityheaders.com

  • may move to www.securityheaders.com
  • may show a score for each of four columns: IPv4 without www - IPv6 without www - IPv4 with www - IPv6 with www
  • may comment on documentation by internet.nl

Image

@janwillemstegink
Copy link
Author

For securityheaders.com modeling was necessary.
My newest tool to view security headers is operational:
https://securityheaders.hostingtool.org/

@bwbroersma bwbroersma transferred this issue from internetstandards/Internet.nl Mar 26, 2025
@bwbroersma bwbroersma changed the title Consider gray out of security headers that will not work due to redirect. Document best practice security headers option always with redirect (defense in depth) Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants