question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting security.headers.hsts=none alone causes the HSTS headers to still appear

See original GitHub issue

When setting security.headers.hsts=none (and only that security.header.* setting) in application.properties SpringBootWebSecurityConfiguration.configureHeaders causes the HstsHeaderWriter to not be added to the HeaderWriter. This seems fine except that by default in Spring Boot, it appears that this is the only header that is enabled by default. Turning off this header leaves no HeaderWriters left.

That means that later on HeadersConfigurer.getHeaderWriters() detects that there are no headers configured and therefore adds the default set of HeaderWriters, which includes contentTypeOptions, xssProtection, cacheControl, frameOptions and HSTS.

It seems wrong to me that if I explicitly turn off HSTS that I still get HSTS headers. Even if there were more headers turned on by default in Spring Boot, if I explicitly turn them all off, I don’t want HeaderConfigurer to come along later and add them back in.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bbrouwercommented, Jan 9, 2017

I do not see this problem anymore with Spring Security 4

0reactions
snicollcommented, Jan 8, 2017

@bbrouwer @rwinch can we please have some feedback on this issue please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common issues with HSTS - Really Simple SSL
The HSTS header should be set only once. This is usually caused by a second HSTS header, added by either your hosting provider...
Read more >
HTTP Strict Transport Security - The HTTPS-Only Standard
A domain instructs browsers that it has enabled HSTS by returning an HTTP header over an HTTPS connection. In its simplest form, the...
Read more >
Strict-Transport-Security - HTTP - MDN Web Docs
The HTTP Strict-Transport-Security response header (often abbreviated as HSTS) informs browsers that the site should only be accessed using ...
Read more >
How To Fix the “HSTS Missing From HTTPS Server” Error (in 5 ...
Set up an HTTP to HTTPS redirect. Add the HSTS header. Submit your site to the HSTS preload list. Verify your strict-transport-security header....
Read more >
HSTS (Strict Transport Security) Now Available - Imperva
Servers communicate HSTS to a browser as a HTTP response header field, named Strict-Transport-Security. The header comprises three directives; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found