|
@@ -193,7 +193,7 @@ protected void configure(HttpSecurity http) throws Exception {
|
|
|
}
|
|
|
----
|
|
|
|
|
|
-If you actually want to cache specific responses, your application can selectively invoke http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletResponse.html#setHeader(java.lang.String,java.lang.String)[HttpServletResponse.setHeader(String,String)] to override the header set by Spring Security.
|
|
|
+If you actually want to cache specific responses, your application can selectively invoke https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletResponse.html#setHeader(java.lang.String,java.lang.String)[HttpServletResponse.setHeader(String,String)] to override the header set by Spring Security.
|
|
|
This is useful to ensure things like CSS, JavaScript, and images are properly cached.
|
|
|
|
|
|
When using Spring Web MVC, this is typically done within your configuration.
|
|
@@ -218,7 +218,7 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
|
|
|
|
|
[[headers-content-type-options]]
|
|
|
==== Content Type Options
|
|
|
-Historically browsers, including Internet Explorer, would try to guess the content type of a request using http://en.wikipedia.org/wiki/Content_sniffing[content sniffing].
|
|
|
+Historically browsers, including Internet Explorer, would try to guess the content type of a request using https://en.wikipedia.org/wiki/Content_sniffing[content sniffing].
|
|
|
This allowed browsers to improve the user experience by guessing the content type on resources that had not specified the content type.
|
|
|
For example, if a browser encountered a JavaScript file that did not have the content type specified, it would be able to guess the content type and then execute it.
|
|
|
|
|
@@ -276,16 +276,16 @@ protected void configure(HttpSecurity http) throws Exception {
|
|
|
|
|
|
[[headers-hsts]]
|
|
|
==== HTTP Strict Transport Security (HSTS)
|
|
|
-When you type in your bank's website, do you enter mybank.example.com or do you enter https://mybank.example.com[]? If you omit the https protocol, you are potentially vulnerable to http://en.wikipedia.org/wiki/Man-in-the-middle_attack[Man in the Middle attacks].
|
|
|
+When you type in your bank's website, do you enter mybank.example.com or do you enter https://mybank.example.com[]? If you omit the https protocol, you are potentially vulnerable to https://en.wikipedia.org/wiki/Man-in-the-middle_attack[Man in the Middle attacks].
|
|
|
Even if the website performs a redirect to https://mybank.example.com a malicious user could intercept the initial HTTP request and manipulate the response (i.e. redirect to https://mibank.example.com and steal their credentials).
|
|
|
|
|
|
-Many users omit the https protocol and this is why http://tools.ietf.org/html/rfc6797[HTTP Strict Transport Security (HSTS)] was created.
|
|
|
-Once mybank.example.com is added as a http://tools.ietf.org/html/rfc6797#section-5.1[HSTS host], a browser can know ahead of time that any request to mybank.example.com should be interpreted as https://mybank.example.com.
|
|
|
+Many users omit the https protocol and this is why https://tools.ietf.org/html/rfc6797[HTTP Strict Transport Security (HSTS)] was created.
|
|
|
+Once mybank.example.com is added as a https://tools.ietf.org/html/rfc6797#section-5.1[HSTS host], a browser can know ahead of time that any request to mybank.example.com should be interpreted as https://mybank.example.com.
|
|
|
This greatly reduces the possibility of a Man in the Middle attack occurring.
|
|
|
|
|
|
[NOTE]
|
|
|
====
|
|
|
-In accordance with http://tools.ietf.org/html/rfc6797#section-7.2[RFC6797], the HSTS header is only injected into HTTPS responses.
|
|
|
+In accordance with https://tools.ietf.org/html/rfc6797#section-7.2[RFC6797], the HSTS header is only injected into HTTPS responses.
|
|
|
In order for the browser to acknowledge the header, the browser must first trust the CA that signed the SSL certificate used to make the connection (not just the SSL certificate).
|
|
|
====
|
|
|
|
|
@@ -363,7 +363,7 @@ For example, the following would instruct the user-agent to only report pin vali
|
|
|
|
|
|
[source]
|
|
|
----
|
|
|
-Public-Key-Pins-Report-Only: max-age=5184000 ; pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=" ; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=" ; report-uri="http://example.net/pkp-report" ; includeSubDomains
|
|
|
+Public-Key-Pins-Report-Only: max-age=5184000 ; pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=" ; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=" ; report-uri="https://example.net/pkp-report" ; includeSubDomains
|
|
|
----
|
|
|
|
|
|
A https://tools.ietf.org/html/rfc7469#section-3[*_pin validation failure report_*] is a standard JSON structure that can be captured either by the web application's own API or by a publicly hosted HPKP reporting service, such as, https://report-uri.io/[*_REPORT-URI_*].
|
|
@@ -381,7 +381,7 @@ You can customize HPKP headers with the <<nsa-hpkp,<hpkp>>> element as shown bel
|
|
|
<headers>
|
|
|
<hpkp
|
|
|
include-subdomains="true"
|
|
|
- report-uri="http://example.net/pkp-report">
|
|
|
+ report-uri="https://example.net/pkp-report">
|
|
|
<pins>
|
|
|
<pin algorithm="sha256">d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=</pin>
|
|
|
<pin algorithm="sha256">E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=</pin>
|
|
@@ -406,7 +406,7 @@ WebSecurityConfigurerAdapter {
|
|
|
.headers()
|
|
|
.httpPublicKeyPinning()
|
|
|
.includeSubdomains(true)
|
|
|
- .reportUri("http://example.net/pkp-report")
|
|
|
+ .reportUri("https://example.net/pkp-report")
|
|
|
.addSha256Pins("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=", "E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
|
|
|
}
|
|
|
}
|
|
@@ -415,9 +415,9 @@ WebSecurityConfigurerAdapter {
|
|
|
[[headers-frame-options]]
|
|
|
==== X-Frame-Options
|
|
|
Allowing your website to be added to a frame can be a security issue.
|
|
|
-For example, using clever CSS styling users could be tricked into clicking on something that they were not intending (http://www.youtube.com/watch?v=3mk0RySeNsU[video demo]).
|
|
|
+For example, using clever CSS styling users could be tricked into clicking on something that they were not intending (https://www.youtube.com/watch?v=3mk0RySeNsU[video demo]).
|
|
|
For example, a user that is logged into their bank might click a button that grants access to other users.
|
|
|
-This sort of attack is known as http://en.wikipedia.org/wiki/Clickjacking[Clickjacking].
|
|
|
+This sort of attack is known as https://en.wikipedia.org/wiki/Clickjacking[Clickjacking].
|
|
|
|
|
|
[NOTE]
|
|
|
====
|
|
@@ -479,7 +479,7 @@ This is by no means foolproof, but does assist in XSS protection.
|
|
|
|
|
|
The filtering is typically enabled by default, so adding the header typically just ensures it is enabled and instructs the browser what to do when a XSS attack is detected.
|
|
|
For example, the filter might try to change the content in the least invasive way to still render everything.
|
|
|
-At times, this type of replacement can become a http://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities/[XSS vulnerability in itself].
|
|
|
+At times, this type of replacement can become a https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities/[XSS vulnerability in itself].
|
|
|
Instead, it is best to block the content rather than attempt to fix it.
|
|
|
To do this we can add the following header:
|
|
|
|
|
@@ -660,7 +660,7 @@ protected void configure(HttpSecurity http) throws Exception {
|
|
|
Applying Content Security Policy to a web application is often a non-trivial undertaking.
|
|
|
The following resources may provide further assistance in developing effective security policies for your site.
|
|
|
|
|
|
-http://www.html5rocks.com/en/tutorials/security/content-security-policy/[An Introduction to Content Security Policy]
|
|
|
+https://www.html5rocks.com/en/tutorials/security/content-security-policy/[An Introduction to Content Security Policy]
|
|
|
|
|
|
https://developer.mozilla.org/en-US/docs/Web/Security/CSP[CSP Guide - Mozilla Developer Network]
|
|
|
|
|
@@ -832,7 +832,7 @@ This is easily supported by setting the <<nsa-frame-options-policy,policy>> attr
|
|
|
</headers>
|
|
|
</http>
|
|
|
<!-- Requires the c-namespace.
|
|
|
-See http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-c-namespace
|
|
|
+See https://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-c-namespace
|
|
|
-->
|
|
|
<beans:bean id="frameOptionsWriter"
|
|
|
class="org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter"
|