phpmyadmin / phpmyadmin/website

CSP improvements

Open
#29 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement hardening
Dominant language
Python
Stars
55
Forks
103
PR merge metrics
No merged PRs in 30d

Description

  1. CSP Improvements (for WebSite)

https://www.phpmyadmin.net/ return the following CSP header:
content-security-policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://www.google-analytics.com/; img-src 'self' https://www.google-analytics.com/ https://www.paypalobjects.com/; style-src 'self' 'unsafe-inline'; child-src 'none'; object-src 'none'

2.1) Change Google Analytics loading

The usage of current Google Analytics code require unsafe-inline in script-src

fix: (by applying any of the below, the unsafe-inline can be removed from script-src)
move the inline code into external file
https://stackoverflow.com/questions/30939809/google-analytics-js-and-content-security-policy
or generate a hash for inline script:
https://www.w3.org/TR/2015/CR-CSP2-20150721/#script-src-hash-usage

2.2) Dynamic CSP usage

The https://www.paypalobjects.com/ in img-src is needed only in some pages, such as:

    https://github.com/phpmyadmin/website/blob/master/pmaweb/templates/donate.html#L31
    https://github.com/phpmyadmin/website/blob/master/pmaweb/templates/sponsors.html#L126

2.3) More Strict CSP Policy

The usage of action attribute is used in the below pages (to https://www.paypal.com/)
https://github.com/phpmyadmin/website/blob/92720e9120eee45b6872b535bb0c85c342e7772c/pmaweb/templates/donate.html#L22
https://github.com/phpmyadmin/website/blob/0da92e1c0fb1f00cfe9edad922b52dc22573fb74/pmaweb/templates/sponsors.html#L113
thus use form-action directive to white-list action locations
https://developer.mozilla.org/en/docs/Web/Security/CSP/CSP_policy_directives#form-action

  1. Missing CSP Policy

visiting:
https://www.phpmyadmin.net/fff/
result:

no CSP Policy sent, also the page load javascript from https://linkhelp.clients.google.com/ (need to add to script-src directive)
https://github.com/phpmyadmin/website/blob/master/pmaweb/templates/404.html#L23

Contributor guide

No contributing guide indexed for this repository

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 with the current CSP response and the templates named in the issue: pmaweb/templates/donate.html, sponsors.html, and 404.html. Trace how the website generator sets headers, then verify that inline analytics, PayPal form and image usage, and the 404 page work under a stricter policy without unsafe-inline where possible.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
security, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.