Commit 7973cd9
authored
Deduplicate HTTP security headers between nginx and Flask-Talisman (#169)
nginx and Superset's own Flask-Talisman middleware both independently
added Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options,
X-XSS-Protection, and Referrer-Policy to every response. nginx's add_header
doesn't replace upstream headers, it appends, so responses carried
duplicates with different values - per spec/browser handling this silently
dropped nginx's preload flag on HSTS (RFC 6797: only the first STS header
is processed), risked invalidating X-Frame-Options entirely on some
browsers when comma-joined, and silently downgraded Referrer-Policy to
nginx's weaker legacy default (UAs take the last policy across combined
headers). Only nginx's HSTS line carried `always`, so its other four
headers vanished on non-2xx/3xx responses (404, 500), relying entirely on
Talisman as an unconditional fallback.
Use proxy_hide_header to strip Talisman's upstream copies and let nginx's
own add_header lines (all now with `always`) be the sole source of these
five headers. Corrects Referrer-Policy to strict-origin-when-cross-origin.
Left Talisman's CSP and all other config untouched - reconfiguring
Talisman instead would have required replicating Superset's internal
default CSP dict verbatim to safely override TALISMAN_CONFIG.
Add a functional test (status_headers) that curls both a normal path and
a nonexistent one, asserting each header appears exactly once with the
expected value on both.1 parent 20e3dc7 commit 7973cd9
3 files changed
Lines changed: 50 additions & 4 deletions
File tree
- services/superset
- tests/testsuite/roles/testing/files
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
297 | 333 | | |
298 | 334 | | |
299 | 335 | | |
| |||
0 commit comments