forked from eclipse-edc/DataDashboard
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(docker): add security headers to NGINX
Set the following headers: - Content-Security-Policy - Cross-Origin-Embedder-Policy - Cross-Origin-Opener-Policy - Cross-Origin-Resource-Policy - Origin-Agent-Cluster - Referrer-Policy - X-Content-Type-Options - X-Download-Options - X-Frame-Options - X-XSS-Protection Specifically, the combination of Cross-Origin-Opener-Policy and Referrer-Policy takes the role of setting `rel="noreferrer noopener"` on external links, which was removed in a prior commit replacing the HTML sanitizer used for Markdown rendering. * Generate hashes of JS files during the build process * Template hashes into CSP * Include headers in NGINX configuration
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Documentation of individual directives: | ||
# - default-src: fallback if a more specific directive is not given; 'self' allows resources from the same origin | ||
# - base-uri: restricts the URLs that can be used in a document's <base> element; 'self' allows resources from the same origin | ||
# - script-src: controls <script> tags and inline event handlers | ||
# - 'strict-dynamic' allows propagating trust from a script protected by a hash or nonce to further scripts it loads | ||
# - ${SCRIPT_SRC_EXTRA} should contain the hashes of all scripts present in the initial HTML | ||
# - style-src: controls <style> tags and inline styles | ||
# - 'unsafe-inline' is required for Angular | ||
# - img-src: controls <img> tags | ||
# - https: allows images from any HTTPS source; required to correctly render embedded images in Markdown | ||
# - frame-src: controls <frame> and <iframe> tags; 'none' disallows them | ||
# - object-src: controls legacy <object> and <embed> tags | ||
# - worker-src: controls web workers and service workers | ||
# - form-action: controls <form> tags; disallow all native form submissions, as this is a single-page application | ||
# - frame-ancestors: controls the ancestors of a document that can embed it in an iframe; 'none' disallows embedding | ||
# - require-trusted-types-for and trusted-types: enforces explicit sanitization when assigning to innerHTML and the like | ||
# - upgrade-insecure-requests: forces the browser to use HTTPS for all URL fetches, even if specified as plain HTTP | ||
add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; script-src 'self' 'strict-dynamic' ${SCRIPT_SRC_EXTRA}; style-src 'self' 'unsafe-inline'; img-src 'self' https:; frame-src 'none'; object-src 'none'; worker-src 'none'; form-action 'none'; frame-ancestors 'none'; require-trusted-types-for 'script'; trusted-types angular angular#bundler; upgrade-insecure-requests;" always; | ||
# Prevent loading of cross-origin resources unless explicitly permitted by the target origin | ||
# Non-CORS requests are permitted, but have their credentials, e.g., cookies, stripped | ||
# Less strict than require-corp, but allows loading images from servers that do not support CORP, which may happen with Markdown | ||
add_header Cross-Origin-Embedder-Policy "credentialless" always; | ||
# Ensure browsing context isolation from new windows/tabs on different origins created by this origin | ||
add_header Cross-Origin-Opener-Policy "same-origin" always; | ||
# Ensure other origins cannot access resources on this origin | ||
add_header Cross-Origin-Resource-Policy "same-origin" always; | ||
# Ensure browsing context isolation from different origins on the same site | ||
add_header Origin-Agent-Cluster "?1" always; | ||
# Disable Referer [sic] header entirely | ||
add_header Referrer-Policy "no-referrer" always; | ||
# Disable MIME type sniffing | ||
add_header X-Content-Type-Options "nosniff" always; | ||
# Prevent downloads being interpreted as HTML by legacy browsers | ||
add_header X-Download-Options "noopen" always; | ||
# Prevent embedding in iframes; legacy counterpart to CSP frame-ancestors directive | ||
add_header X-Frame-Options "DENY" always; | ||
# Disable XSS "protection" that only makes things worse | ||
add_header X-XSS-Protection "0" always; |