this blog article by a Dropbox engineer on testing CSPs and handling reports helpful. You may also want to use a service like report-uri.com to help debug your CSP.
Also note that the frame-ancestors might have to be modified. For more details, see On using the host application in an iframe.
As another mitigation technique, you can explicitly disallow some features in case an attacker is able to inject code. The prepared statement should disallow most functions that can be used to spy on users (microphone, camera, geolocation) or trick them into doing something (payment, usb, fullscreen, vr). If you, for some reason, do require one of your SAML SSO page templates to use one of these functionalities, such as maybe geolocation-based IdP selection, you'll have to modify this header.
This is a privacy feature. The referrer (or 'referer') header is sent to a server when you visit a website and were previously on another website. The target site can use that header to see where you came from. The value we chose strict-origin will cause the referrer header to not be sent when a user visits a site on a different server. Disabling it should not cause any harm, but it can also not be completely ruled out that some IdPs don't require it. It may also mess with analytics a bit, but that should be uncritical in this use case.
Use this with caution! If this header is delivered to a browser via an HTTPS connection, this browser will now always visit this website only via HTTPS and never via HTTP any more. Use this header only if absolutely know that your application will never have to be accessed via HTTP via that address. Note that you can still access it via HTTP via another address if needed.
If the application is embedded in another website via frame or iframe, then the Content-Security-Policy and X-Frame-Options must be modified. Typical scenarios include:
Running the application in an intranet portal
Using Jira Service Desk issue collectors
Using Confluence as a knowledge base in Jira Service Desk
If any of these cases apply and you're having trouble embedding the application, then you might have to modify the aforementioned frame-related headers. Check your browser console errors regarding embedding to determine the cause for the issues.
For example, if you want to embed the application on https://intranet.example.com, then you need to modify the following headers:
Header name | Header value |
---|---|
Content-Security-Policy | frame-ancestors 'self' https://intranet.example.com; |
X-Frame-Options | allow-from https://intranet.example.com |
For more informations on this, check Atlassian's documentation.
These headers are usually set by either the host application or a reverse proxy / load balancer. Here are some instructions on how to set the headers in a couple of popular reverse proxies / load balancers. If yours isn't in the list, consult your software's or service's documentation on how to achieve this.
For each header you want to overwrite, add the following statements, adapted to the headers you want to set, to the appropriate server block:
- location /plugins/servlet/samlsso {
- add_header "Content-Security-Policy" "default-src 'self' 'unsafe-inline' 'unsafe-eval'; frame-ancestors 'self'; img-src 'self' data: https://www.gravatar.com;";
- add_header "Feature-Policy" "camera 'none'; fullscreen 'none'; geolocation 'none'; microphone 'none'; payment 'none'; speaker 'none'; usb 'none'; vibrate 'none'; vr 'none';";
- add_header "Referrer-Policy" "strict-origin";
- }
For more information, check out the NGINX documentation for add_header.
Note that this configuration may leave you with multiple versions of the headers, for example the CSP header. You can have nginx replace the existing headers by using the ngx_headers_more module and its more_set_headers directive.
Make sure mod_headers is enabled. Then add the following statements, adapted to the headers you want to set, to the appropriate Proxy block in the appropriate Virtual Host config:
- <Proxy "http://your-backend/plugins/servlet/samlsso">
- Header set "Content-Security-Policy" "default-src 'self' 'unsafe-inline' 'unsafe-eval'; frame-ancestors 'self'; img-src 'self' data: https://www.gravatar.com;"
- Header set "Feature-Policy" "camera 'none'; fullscreen 'none'; geolocation 'none'; microphone 'none'; payment 'none'; speaker 'none'; usb 'none'; vibrate 'none'; vr 'none';"
- Header set "Referrer-Policy" "strict-origin"
- </Proxy>
For more information, check out the Apache httpd documentation for Header set.
You can use the HTTP Response Headers GUI in IIS Manager or add the following to your web.config:
- <system.webServer>
- <httpProtocol> <customHeaders> <add name="Content-Security-Policy" value="..." /> </customHeaders>
- </httpProtocol>
- </system.webServer>
For more information, check out the Microsoft IIS documentation for customHeaders.
Here are a couple of links from which we drew information while compiling this document:
Mozilla Developer Network documentation on the headers:
Reverse Proxy header configuration:
Tools:
Scan and evaluate your installation's security headers: https://securityheaders.com/
Collect your CSP reports: https://report-uri.com/ (Includes a free tier)
Other helpful resources:
Scott Helme's blog: https://scotthelme.co.uk/hardening-your-http-response-headers/ also contains resources about how to set these headers
Dropbox blog post on testing CSP: https://blogs.dropbox.com/tech/2015/09/on-csp-reporting-and-filtering/
Blog post on caveats in add_header in NGINX: https://www.peterbe.com/plog/be-very-careful-with-your-add_header-in-nginx