Menu

How to inventory every origin a Moodle page actually loads before you write a CSP
📰

How to inventory every origin a Moodle page actually loads before you write a CSP

DEV Community: php·Luuk Verhoeven·1 day ago
#wOMSk6Aq
#devto#dev#policy#self#report
Reading 0:00
15s threshold

A generic Content-Security-Policy copied from a hardening blog will break a Moodle™ course page. H5P, TinyMCE, LTI tools, MathJax, CDN fonts and a YouTube embed all load origins that a "scripts from self only" policy never lists. The browser then fails silently: a grey video box, a quiz that never starts, a login button that does nothing.

Write the policy from what the page actually loads. Here is a method that takes an afternoon on a staging site, not a rewrite of the application.

See the headers you already send

curl -sI https://lms.example.org/login/index.php | grep -iE 'content-security-policy|x-frame-options|strict-transport|x-content-type|referrer-policy|permissions-policy'

Enter fullscreen mode

Exit fullscreen mode

An empty grep is common. Moodle does not ship a production CSP.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.