Commit 39f927a
authored
Add additional security headers to nginx config (#1906)
Related tiny-pilot/tinypilot-pro#1593
This PR addresses the following precautionary web security
considerations from
tiny-pilot/tinypilot-pro#1591 (comment):
- [`Content-Security-Policy` (CSP)
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP)
not set (i.e., prevent XSS)
- [`X-Frame-Options`
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options)
not set (i.e., prevent clickjacking)
- <s>[`Set-Cookie`
header](https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/Cookies#secure)
without secure flag</s>
- Only applicable to HTTPS connections
- [`Cross-Origin-Resource-Policy` (CORP)
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cross-Origin_Resource_Policy)
not set (i.e., prevent
[Spectre](https://en.wikipedia.org/wiki/Spectre_(security_vulnerability))
vulnerability)
- <s>[`Cross-Origin-Embedder-Policy` (COEP)
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cross-Origin-Embedder-Policy)
not set</s>
- Only applicable to HTTPS connections
- <s>[`Cross-Origin-Opener-Policy` (COOP)
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cross-Origin-Opener-Policy)
not set</s>
- Only applicable to HTTPS connections
- <s>[`Permissions-Policy`
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Permissions-Policy)
not set</s>
- Only applicable to HTTPS connections
- [`Server`
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Server)
reveals Nginx version info
- <s>[`Strict-Transport-Security` (HSTS)
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security)
not set</s>
- Only applicable to HTTPS connections
- [`X-Content-Type-Options`
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Content-Type-Options)
not set (i.e., prevent MIME type sniffing)
Notes:
1. We've added a Content Security Policy that allows inline JavaScript
and CSS via the `unsafe-inline` flag. However, [the docs warn against
this](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP#inline_javascript)
by saying that allowing inline JavaScript defeats much of the purpose of
CSP.
Our use of "inline JavaScript" is a result of not using a JavaScript
build pipeline for the sake of keeping frontend development as simple as
possible.
Even with the use of `unsafe-inline`, I still think our CSP is adding
value via the [`default-src`
directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/default-src)
by restricting all resources to the same origin (i.e., `self`).
1. Our new Content Security Policy restricts the use of `data:` URLs. So
I've converted our inline dot cursor image into a static image file.
1. This PR defines Nginx request headers and response headers into
separate config files (located at `/etc/nginx/snippets/`). This allows
us to easily redefine headers (via the `include` directive) when an
Nginx config block needs to add additional headers.
1. This PR removes an unused legacy Nginx config file (i.e.,
`debian-pkg/usr/share/tinypilot/nginx.conf`).
<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1906"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>1 parent 964a43e commit 39f927a
File tree
7 files changed
+48
-58
lines changed- app/static
- css
- img
- debian-pkg
- debian
7 files changed
+48
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
Loading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
152 | 160 | | |
153 | 161 | | |
154 | 162 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 18 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | | - | |
26 | | - | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
| |||
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
0 commit comments