|
1 | | -# Secure Headers  |
| 1 | +# Secure Headers [](https://github.com/github/secure_headers/actions/workflows/build.yml) |
2 | 2 |
|
3 | | -**main branch represents 6.x line**. See the [upgrading to 4.x doc](docs/upgrading-to-4-0.md), [upgrading to 5.x doc](docs/upgrading-to-5-0.md), or [upgrading to 6.x doc](docs/upgrading-to-6-0.md) for instructions on how to upgrade. Bug fixes should go in the 5.x branch for now. |
| 3 | +**main branch represents 7.x line**. See the [upgrading to 4.x doc](docs/upgrading-to-4-0.md), [upgrading to 5.x doc](docs/upgrading-to-5-0.md), [upgrading to 6.x doc](docs/upgrading-to-6-0.md) or [upgrading to 7.x doc](docs/upgrading-to-7-0.md) for instructions on how to upgrade. Bug fixes should go in the `6.x` branch for now. |
4 | 4 |
|
5 | 5 | The gem will automatically apply several headers that are related to security. This includes: |
6 | | -- Content Security Policy (CSP) - Helps detect/prevent XSS, mixed-content, and other classes of attack. [CSP 2 Specification](http://www.w3.org/TR/CSP2/) |
| 6 | +- Content Security Policy (CSP) - Helps detect/prevent XSS, mixed-content, and other classes of attack. [CSP 2 Specification](https://www.w3.org/TR/CSP2/) |
7 | 7 | - https://csp.withgoogle.com |
8 | 8 | - https://csp.withgoogle.com/docs/strict-csp.html |
9 | 9 | - https://csp-evaluator.withgoogle.com |
10 | 10 | - HTTP Strict Transport Security (HSTS) - Ensures the browser never visits the http version of a website. Protects from SSLStrip/Firesheep attacks. [HSTS Specification](https://tools.ietf.org/html/rfc6797) |
11 | 11 | - X-Frame-Options (XFO) - Prevents your content from being framed and potentially clickjacked. [X-Frame-Options Specification](https://tools.ietf.org/html/rfc7034) |
12 | 12 | - X-XSS-Protection - [Cross site scripting heuristic filter for IE/Chrome](https://msdn.microsoft.com/en-us/library/dd565647\(v=vs.85\).aspx) |
13 | 13 | - X-Content-Type-Options - [Prevent content type sniffing](https://msdn.microsoft.com/library/gg622941\(v=vs.85\).aspx) |
14 | | -- X-Download-Options - [Prevent file downloads opening](https://msdn.microsoft.com/library/jj542450(v=vs.85).aspx) |
15 | | -- X-Permitted-Cross-Domain-Policies - [Restrict Adobe Flash Player's access to data](https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html) |
16 | | -- Referrer-Policy - [Referrer Policy draft](https://w3c.github.io/webappsec-referrer-policy/) |
17 | | -- Expect-CT - Only use certificates that are present in the certificate transparency logs. [Expect-CT draft specification](https://datatracker.ietf.org/doc/draft-stark-expect-ct/). |
18 | | -- Clear-Site-Data - Clearing browser data for origin. [Clear-Site-Data specification](https://w3c.github.io/webappsec-clear-site-data/). |
| 14 | +- x-download-options - [Prevent file downloads opening](https://msdn.microsoft.com/library/jj542450(v=vs.85).aspx) |
| 15 | +- x-permitted-cross-domain-policies - [Restrict Adobe Flash Player's access to data](https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html) |
| 16 | +- referrer-policy - [Referrer Policy draft](https://w3c.github.io/webappsec-referrer-policy/) |
| 17 | +- expect-ct - Only use certificates that are present in the certificate transparency logs. [expect-ct draft specification](https://datatracker.ietf.org/doc/draft-stark-expect-ct/). |
| 18 | +- clear-site-data - Clearing browser data for origin. [clear-site-data specification](https://w3c.github.io/webappsec-clear-site-data/). |
19 | 19 |
|
20 | 20 | It can also mark all http cookies with the Secure, HttpOnly and SameSite attributes. This is on default but can be turned off by using `config.cookies = SecureHeaders::OPT_OUT`. |
21 | 21 |
|
@@ -62,7 +62,6 @@ SecureHeaders::Configuration.default do |config| |
62 | 62 | # directive values: these values will directly translate into source directives |
63 | 63 | default_src: %w('none'), |
64 | 64 | base_uri: %w('self'), |
65 | | - block_all_mixed_content: true, # see http://www.w3.org/TR/mixed-content/ |
66 | 65 | child_src: %w('self'), # if child-src isn't supported, the value for frame-src will be set. |
67 | 66 | connect_src: %w(wss:), |
68 | 67 | font_src: %w('self' data:), |
@@ -92,18 +91,21 @@ SecureHeaders::Configuration.default do |config| |
92 | 91 | end |
93 | 92 | ``` |
94 | 93 |
|
| 94 | +### Deprecated Configuration Values |
| 95 | +* `block_all_mixed_content` - this value is deprecated in favor of `upgrade_insecure_requests`. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content for more information. |
| 96 | + |
95 | 97 | ## Default values |
96 | 98 |
|
97 | 99 | All headers except for PublicKeyPins and ClearSiteData have a default value. The default set of headers is: |
98 | 100 |
|
99 | 101 | ``` |
100 | | -Content-Security-Policy: default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline' |
101 | | -Strict-Transport-Security: max-age=631138519 |
102 | | -X-Content-Type-Options: nosniff |
103 | | -X-Download-Options: noopen |
104 | | -X-Frame-Options: sameorigin |
105 | | -X-Permitted-Cross-Domain-Policies: none |
106 | | -X-Xss-Protection: 1; mode=block |
| 102 | +content-security-policy: default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline' |
| 103 | +strict-transport-security: max-age=631138519 |
| 104 | +x-content-type-options: nosniff |
| 105 | +x-download-options: noopen |
| 106 | +x-frame-options: sameorigin |
| 107 | +x-permitted-cross-domain-policies: none |
| 108 | +x-xss-protection: 0 |
107 | 109 | ``` |
108 | 110 |
|
109 | 111 | ## API configurations |
|
0 commit comments