← Blog · 19 November 2026 · Lire en français

Audio player behind a Content-Security-Policy: a checklist for the security reviewer

Before an audio player goes on a site with a strict CSP, someone has to sign off on what it loads. Here is the exact inventory of our embed script, the directives it needs, the nonce case, and the symptom each missing directive produces.

On most publisher and public-sector sites, adding a third-party widget is not a marketing decision. It goes through whoever owns the Content-Security-Policy header, and that person asks one question: what exactly will this load, and from where? A vague answer ("our CDN and a few partners") is how policies end up full of wildcards.

This page is the answer we would want to receive. It is written from the script we actually serve, so you can check every line of it in your browser's network panel.

Inventory: what the embed script does

The integration is one tag: <script src="https://wedispatch.fr/player.js" data-article="…" defer></script>, or the data-site="…" variant placed once in an article template. The WordPress plugin outputs the same tag, so a hardened WordPress site follows the same rules.

Once loaded, the script performs three kinds of request, and no others:

1. It creates an iframe pointing at https://wedispatch.fr/embed/<id>. The whole player lives inside it: controls, transcript, and the audio file itself, which is played inside the frame under our origin.
2. In automatic mode only (data-site), it calls https://wedispatch.fr/api/resolve to find out whether an audio exists for the current page URL. With data-article, this call never happens.
3. If you gate audio for subscribers (data-token-url), it fetches a token from the path you configured, on your own origin. The flow is described in audio for subscriber-only articles.

It loads no further script, no web font, no remote image. It talks to its frame through postMessage, which CSP does not govern.

The directives, as a checklist

Starting from a policy that only allows 'self':

  • script-src: add https://wedispatch.fr.
  • frame-src: add https://wedispatch.fr. If your policy has no frame-src, browsers fall back to child-src, then default-src; edit whichever one is actually in force.
  • connect-src: add https://wedispatch.fr only if you use data-site.
  • media-src: nothing to add. Playback happens inside the frame, where our own policy applies, not yours.

A minimal working header therefore reads:

Content-Security-Policy: default-src 'self'; script-src 'self' https://wedispatch.fr; frame-src 'self' https://wedispatch.fr; connect-src 'self' https://wedispatch.fr

Nonce-based policies

If your policy uses per-request nonces, usually with 'strict-dynamic', modern browsers ignore host allowlists in script-src. Adding our domain there achieves nothing. Put your page's nonce on the tag instead: <script nonce="…" src="https://wedispatch.fr/player.js" …>. Your templates already do this for your own scripts. frame-src and connect-src remain host lists either way.

Symptoms, so you can diagnose without guessing

Each missing directive fails in a recognisable way:

  • script-src blocks: nothing at all appears, and the console reports a refused script.
  • frame-src blocks: a sketch of the player appears where it should be, then fades out after five seconds because the frame never reports its height.
  • connect-src blocks, in data-site mode: nothing appears. The script never learns that an audio exists, and it is built to insert nothing rather than an empty frame.
  • style-src without 'unsafe-inline': the only cosmetic case. While loading, the script draws a placeholder (a dot, a line, an animated sheen) using inline style attributes and a small injected stylesheet, which a strict policy refuses. The placeholder box still shows; its inner drawing does not. The player itself then loads normally, because its size and position are set through the DOM style API, which CSP does not block.

A sensible rollout is to ship the change under Content-Security-Policy-Report-Only first, browse a few article pages, and only then enforce. For non-CSP reasons a player may be missing (blockers, caching, canonical URL mismatches), see text to speech not working: what to check.

The other side of the frame

An iframe only renders if the framed site allows it. Ours refuses framing (X-Frame-Options: DENY) everywhere except one path, written as an explicit exception in our configuration: /embed, the player itself. You can verify this by comparing the response headers of any page on our site with those of an /embed URL. Being framable is a deliberate, narrow decision, not a default we forgot to tighten.

Listening events that the player forwards to your analytics travel through your own page's existing data layer, so they need no extra directive either; see tracking audio listens in GA4 or Matomo.

When no third-party script or frame is acceptable

Some policies forbid any cross-origin script or frame, full stop. That is a legitimate position, and there is a route for it: a server-side block with no iframe, rendered by your own platform with your own markup. In that setup the audio file plays directly in your page, so media-src is the one directive to extend, with the file address the block hands you, and for that reason alone.

Whatever the route, the principle for the reviewer is the same: allow what is needed by name, write down why next to the header, and refuse anything that arrives as a wildcard.

Give your articles a voice with WeDispatch

This blog is itself voiced by WeDispatch. Curious how it sounds on your content?

Book a demo

Read next