openedx / openedx/openedx-platform
Add Content-Security-Policy setting for CMS
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.2k
- Forks
- 4.4k
- Avg merge
- 6d 18h
- Merged PRs (30d)
- 42
Description
There currently is not a way to set a Content-Security-Policy (CSP) header for LMS or CMS, but this is a powerful security measure that deployers can take. 2U is starting to experiment with this, and the CMS is a good place to start, since it is lower traffic.
Acceptance criteria:
- New Django settings to set a
Content-Security-Policyheader on CMS, orContent-Security-Policy-Report-Only, or both at the same time - New Django setting to set a
Reporting-Endpointsheader on CMS to support CSP Level 3 - Ability to set these for the LMS as well at the same time, with different values
- Optionally: Ability to do a percentage rollout, maybe with Waffle
Presumably this would involve using a Django middleware. Possible ways to do this:
- CSP-specific settings and middleware in edx-platform (bad, because would have to reimplement in each IDA)
- Find a library that allows setting arbitrary headers
- Make a middleware in edx-django-utils or similar that allows setting CSP and related headers
- Find a CSP-specific library (e.g. https://github.com/mozilla/django-csp although that one doesn’t allow both CSP and CSP-RO at the same time)
Alternatively, give up and just do it at the CDN level, but this approach would not help the community as much.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Django settings and middleware approach described for edx-platform, then compare the proposed edx-django-utils and django-csp options. Done means CMS and LMS can independently configure CSP, CSP-Report-Only, and Reporting-Endpoints headers, with both policy modes supported together; percentage rollout is optional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100