Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial CSP configuration #1731

Merged
merged 2 commits into from
Sep 29, 2021
Merged

Add initial CSP configuration #1731

merged 2 commits into from
Sep 29, 2021

Conversation

chigby
Copy link
Contributor

@chigby chigby commented Aug 19, 2021

Refs #1238

This set of changes configures the CSP based on my initial clicking around the website locally, looking for problems. Inevitably, there will be things I have missed (due to lack of exhaustive searching and differences between my environment and production). Because of this, I have set the CSP middleware to send "report-only" headers, meaning the actual functioning of the site will not be affected yet. It will report violations to a URI that we configure to receive that information, which we can then use to determine when we are ready to activate the CSP for real.

I've set the CSP_REPORT_URI to send it to Sentry.io's service for receiving these reports in the Heroku settings.

This change should be safe to deploy as it should not change what resources the browser loads at all, only reports them if they would violate the set of directives I've initially added.

Copy link
Contributor

@nmorduch nmorduch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do as Sentry recommends:

We recommend setting this up to only run on a percentage of requests, as otherwise you may find that you've quickly exhausted your quota.

This set of changes configures the CSP based on my initial clicking
around the website locally, looking for problems.  Inevitably, there
will be things I have missed (due to lack of exhaustive searching and
differences between my environment and production).  Because of this,
I have set the CSP middleware to send "report-only" headers, meaning
the actual functioning of the site will not be affected yet.  It will
report violations to a URI that we configure to receive that
information, which we can then use to determine when we are ready to
activate the CSP for real.

I've set the CSP_REPORT_URI to send it to Sentry.io's service for
receiving these reports in the Heroku settings.
This will prevent us from using up our Sentry.IO quota once this goes
live in production.
@chigby
Copy link
Contributor Author

chigby commented Sep 23, 2021

Added a throttling of the CSP reporting to 5%, meaning only 5% of requests will see the report-uri directive, and the rest will not be reported at all.

@chigby chigby requested a review from nmorduch September 29, 2021 14:21
@nmorduch nmorduch merged commit 8cf139d into main Sep 29, 2021
@nmorduch nmorduch deleted the 1238-csp branch September 29, 2021 14:48
@nmorduch nmorduch linked an issue Sep 29, 2021 that may be closed by this pull request
@nmorduch nmorduch linked an issue Sep 29, 2021 that may be closed by this pull request
@nmorduch nmorduch mentioned this pull request Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[2h👀📦] Set Security Headers
2 participants