Transform Learning with a Powerful Enterprise LMS

Learn more
Performance & Security

Content Security Policy for LMS Sites With SCORM and Embedded Video

What SCORM, xAPI, H5P and embedded video need from a content security policy, a starting policy for Moodle, and a report-only rollout that does not break courses.

Learn more about this topic with AI

Gemini opens with the prompt copied - paste it into the chat to start.

Illustration of a content security policy shielding an LMS course page with a SCORM player and an embedded video

Making a content security policy LMS-ready means three jobs that a normal website policy does not have: let SCORM packages talk to the LMS window that launched them, let course pages frame video from YouTube, Vimeo or your own media host, and stop anyone else framing your login and course pages. In practice that means serving SCORM content from your own origin and allowing 'self' for scripts and frames, listing each video host in frame-src, setting frame-ancestors 'self', and starting in report-only mode, because a strict policy applied blindly will break courses that worked yesterday.

This guide shows how to build a content security policy for LMS sites step by step: what SCORM, xAPI, H5P and embedded video each need, a starting policy for Moodle and for WordPress LMS plugins, how to roll it out with violation reports, and how to read the failures. It is written for developers and administrators who already know what an HTTP response header is.

Checked against the MDN Content Security Policy reference and the Moodle 5.3 source code (October 2026). Directive behaviour is stable across current browsers, but test every policy against your own course catalogue.

Why an LMS is harder than most sites

CSP works by listing where each type of resource may come from. A marketing site has a short list. An LMS has several sources that a policy author does not control:

  • Packaged content. SCORM and HTML5 packages exported from authoring tools carry their own HTML and JavaScript, often with inline scripts. They run as documents on your site.
  • The platform's own scripts. Moodle core pages contain inline script blocks; the SCORM launcher mod/scorm/loadSCO.php is one. Moodle's SCORM runtime files (scorm_12.js, scorm_13.js and aicc.js) call eval().
  • Frames in both directions. The LMS frames content (SCORM players, H5P, video, LTI tools), and sometimes another platform frames the LMS, for example when it is published as an LTI tool.
  • Plugins. WordPress LMS sites in particular load scripts from many plugins and third-party services, each with its own requirements.

So the goal is not the strictest possible policy. It is a policy that blocks the attacks that matter on an LMS, mainly clickjacking of login and assessment pages and scripts injected from unknown origins, without breaking learning content.

How SCORM content and CSP interact

A SCORM package reports progress by finding a JavaScript object in a parent window: API for SCORM 1.2 and API_1484_11 for SCORM 2004. The content walks up its chain of parent frames, then checks the window that opened it. Moodle's launcher uses this algorithm before it redirects to the package's launch file.

That search only works when the content and the LMS share an origin. Under the browser's same-origin policy, a document from another scheme, host or port gets very limited access to window.parent and cannot read an object attached to it. This is why the first rule matters more than any directive:

  • Serve SCORM packages from the LMS origin. Moodle does this by default: uploaded packages are served from pluginfile.php on the same site. WordPress SCORM plugins usually extract packages under the uploads folder of the same site. If you move packages to a CDN on another hostname, tracking breaks regardless of CSP. Our SCORM player for WordPress guide covers the WordPress side.
  • Allow same-origin frames. The player frames the package, so frame-src (or child-src or default-src, which it falls back to) must include 'self'.
  • Allow the package to be framed by its own site. If the package document receives a frame-ancestors directive, it must include 'self'.

The harder question is what script-src to apply to the package documents themselves. A server-wide header also reaches every HTML file inside every package, and authoring tool output commonly relies on inline scripts. Do not assume a package is clean; your violation reports will show which ones need 'unsafe-inline' or 'unsafe-eval'. A practical approach is a separate, looser policy for the package path (for example Moodle's /pluginfile.php/ URLs for mod_scorm/content) and a stricter one for the rest of the site.

xAPI and cmi5 content work differently. They send statements over HTTPS to a learning record store, so they need the LRS origin in connect-src, and they do not depend on the parent-window search.

Embedded video and other frames

frame-src controls where iframes on your pages may load from. If it is absent the browser uses child-src, then default-src. List each host you embed:

SourceDirective and valueNotes
YouTubeframe-src https://www.youtube.com https://www.youtube-nocookie.comPrivacy-enhanced mode uses the youtube-nocookie.com host for the embed URL
Vimeoframe-src https://player.vimeo.comAdd script-src https://player.vimeo.com if you use the Vimeo player.js API to track viewing
Self-hosted videomedia-src 'self' plus your media hostnamePlayers built on Media Source Extensions, such as HLS players, attach media through blob: URLs, so add blob:
H5P in Moodleframe-src 'self'Moodle frames H5P from its own /h5p/embed.php
LTI toolsframe-src with each tool's originTools launched in an iframe fail silently if their origin is missing

The embedded player then loads its own scripts inside its own frame. That is governed by the video host's policy, not yours, so you do not need to list YouTube's script domains unless your own page loads the YouTube or Vimeo JavaScript API.

Framing your LMS: frame-ancestors

frame-ancestors decides which sites may embed your pages. It protects login, quiz and payment pages from clickjacking, and three details trip people up:

  • It does not fall back to default-src. A policy of default-src 'none' still lets anyone frame the page; you must set frame-ancestors explicitly.
  • It is ignored in a <meta> tag, so it must be sent as an HTTP header.
  • It checks every ancestor, so a page nested two levels deep fails if any parent is not allowed.

Moodle already sends X-Frame-Options: sameorigin unless the Allow frame embedding setting (Site administration > Security > HTTP security) is enabled, and it skips the header for the Moodle app. Moodle's own help text recommends enabling that setting when you use the Publish as LTI tool enrolment method. If you do, add frame-ancestors 'self' plus the origins of the platforms that launch your tools, rather than leaving framing open to every site.

A starting policy for Moodle

This is a report-only starting point for a Moodle site with YouTube and Vimeo embeds and an external LRS. Moodle 5.3 does not send a content security policy for normal pages, so you add one at the web server. Because Moodle prints inline scripts and its SCORM runtime uses eval(), script-src needs both 'unsafe-inline' and 'unsafe-eval'; the value of this policy is in the source allowlists and frame-ancestors, not in blocking inline script.

Reporting-Endpoints: csp="https://lms.example.com/csp-report"
Content-Security-Policy-Report-Only:
  default-src 'self';
  script-src 'self' 'unsafe-inline' 'unsafe-eval';
  style-src 'self' 'unsafe-inline';
  img-src 'self' data: blob:;
  font-src 'self' data:;
  media-src 'self' blob:;
  frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com https://player.vimeo.com;
  connect-src 'self' https://lrs.example.com;
  frame-ancestors 'self';
  object-src 'none';
  base-uri 'self';
  form-action 'self';
  report-uri /csp-report;
  report-to csp

The header is shown on several lines for readability; send it as one line. Replace the example hostnames, and add the origins of every LTI tool, analytics script, single sign-on provider (in form-action, if login forms post to it) and theme font host you use. Moodle core already sends its own stricter policy for files served inline from Folder activities, so you will see that header on those responses.

For WordPress LMS sites the shape is the same, but the source list depends on your plugins. Payment gateways, page builders and chat widgets each add origins to script-src, frame-src and connect-src. Build the list from reports, not from guesses.

This policy and the server examples below were not run on a live site; test on staging first.

Rolling it out without breaking courses

  1. Start in report-only mode. Content-Security-Policy-Report-Only reports violations without blocking anything. Like frame-ancestors, it cannot be delivered in a <meta> tag.
  2. Collect reports. report-to is the current mechanism and sends reports to an endpoint named in the Reporting-Endpoints header. report-uri is deprecated, but MDN still shows both together because report-to does not have full cross-browser support.
  3. Exercise every content type. Launch one course of each kind: SCORM 1.2 and 2004 from each authoring tool you use, H5P, every video host, every LTI tool, quiz review, certificate download and checkout. Reports only cover pages people actually open.
  4. Fix or allow. For each violation, decide whether the source is legitimate. Add legitimate origins; remove or replace the rest.
  5. Enforce. Switch the header name to Content-Security-Policy, keep reporting on, and watch for new violations after each plugin or content update.

Set the header at the web server so it covers every response. In nginx, remember that a location block with its own add_header stops inheriting headers from the server block, so a header set only at server level can silently disappear from some paths. Use the always parameter so error responses carry it too.

Reading violations: symptoms and fixes

SymptomLikely directiveFix
SCORM course opens but progress is not savedUsually not CSP: package on another originServe the package from the LMS origin
SCORM player shows a blank frameframe-src or the package's frame-ancestorsAllow 'self' in both
Course content loads but buttons do nothingscript-src on the package pathUse a looser policy for package URLs
Video area is empty or shows a browser errorframe-srcAdd the video host's embed domain
Self-hosted video does not playmedia-srcAdd the media host and blob:
xAPI or cmi5 statements never reach the LRSconnect-srcAdd the LRS origin
LMS cannot be launched inside another platformframe-ancestors or X-Frame-OptionsAllow that platform's origin explicitly

Mistakes we see most often

  • Copying a strict nonce-based policy. A 'strict-dynamic' policy with nonces is the strongest option on a site you control end to end, but LMS core and packaged content print inline scripts without nonces. Adopting it on an LMS means patching the platform and every package.
  • Putting the policy in a meta tag. frame-ancestors and report-only mode do not work there.
  • Allowing whole schemes. https: in script-src allows any HTTPS host and removes most of the benefit.
  • Forgetting maintenance. A new plugin, LTI tool or video host adds sources; review the policy as part of every release, alongside the other items in our LMS security checklist.

For the wider picture of hardening and speeding up a learning platform, see our LMS security and performance guide.

How we can help

We design and roll out security headers for Moodle and WordPress LMS sites, including per-path policies for SCORM content, report collection and the fixes that follow. See our LMS security and LMS performance optimization services, or send us your current headers for a review.

Frequently asked questions

Does a content security policy break SCORM?

It can. The player frames the package and the package looks for the SCORM API in a parent window, so frame-src and the package's frame-ancestors must allow 'self', and package documents often need inline scripts. Packages served from another origin fail regardless, because of the same-origin policy.

Which CSP directive allows YouTube and Vimeo embeds?

frame-src. Add https://www.youtube.com and https://www.youtube-nocookie.com for YouTube and https://player.vimeo.com for Vimeo. If frame-src is absent, browsers fall back to child-src and then default-src.

Does Moodle set a Content-Security-Policy header?

Not for normal pages in Moodle 5.3. It sends X-Frame-Options: sameorigin unless Allow frame embedding is enabled, and a strict policy only on files served inline from Folder activities. Add your own policy at the web server.

Can I set frame-ancestors in a meta tag?

No. MDN states that frame-ancestors is not supported in the meta element, and neither is the report-only header, so both must be sent as HTTP response headers.

Free 30-minute consultation

Not sure where to start? Talk to an LMS engineer.

Tell us what platform you run and what you need. You’ll get honest, practical advice - even if the answer is that you don’t need us.

Sources & references

  1. Content-Security-Policy: frame-ancestors directive - MDN Web Docs
  2. Content-Security-Policy-Report-Only header - MDN Web Docs
  3. Same-origin policy - MDN Web Docs
  4. API discovery algorithms - Rustici Software
  5. Embed videos and playlists - YouTube Help
  6. Vimeo Player SDK (player.js) - Vimeo
Add as a preferred source on Google

Add All-in-One LMS as a preferred source to see more of our articles in Google’s Top Stories.

Learn more about this topic with AI

Gemini opens with the prompt copied - paste it into the chat to start.

Keep reading

Before you go - get a free LMS audit

Tell us which LMS you use and what is not working. An engineer replies within one business day.

Choose which optional cookies we may use. You can change this at any time from "Cookie preferences" in the footer. Cookie policy · Privacy policy