openedx / openedx/openedx-platform

Add Content-Security-Policy setting for CMS

Open
#31,890 7 comments 0 reactions 0 assignees View on GitHub

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-Policy header on CMS, or Content-Security-Policy-Report-Only, or both at the same time
  • New Django setting to set a Reporting-Endpoints header 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.