Open the console

Embedding an Onboarding Checklist Under a Strict Content Security Policy

What a host app's CSP header blocks when you drop in a checklist widget, and the directives you actually need to get past it.

Embedding an Onboarding Checklist Under a Strict Content Security Policy

A checklist widget that works perfectly in your own staging environment can simply stop rendering the moment it's embedded in a customer's app that runs a strict Content Security Policy. There's no stack trace that points at the widget. The browser just silently refuses to load the script, the stylesheet, or the API call the widget depends on, and logs a one-line warning to the console that nobody but the customer's own engineer is likely to see — and they have no reason to go looking for it on your behalf.

This isn't a bug in the widget. CSP is doing exactly what it's designed to do: refusing to execute or fetch anything the host page didn't explicitly allow. The fix is to know which directives a checklist widget actually needs and to document them, rather than discovering the list one blocked request at a time inside a customer's support ticket.

What CSP is actually enforcing

A Content Security Policy is a response header the host page sends that tells the browser which origins are allowed to supply scripts, styles, images, fonts, and fetch/XHR targets. It's additive and restrictive by default: anything not explicitly listed is denied, full stop, with no partial degradation. A widget that loads its JS from a CDN, its styles inline, and calls your API from the browser is touching three or four of these categories at once, and a customer's security team writing a tight policy for their own app has no reason to have anticipated any of them.

The directives a checklist widget actually touches

Strip the problem down to what the widget does on the page, and the directive list is short and specific rather than "allow everything":

  • script-src — wherever the widget's JS bundle is served from (your CDN origin)
  • connect-src — your API origin, for fetching steps and posting completions
  • style-src — your CDN origin again if styles ship as a separate file, or 'unsafe-inline' if the widget injects inline style tags, which is worth avoiding precisely because it's the one exception security teams push back on hardest
  • img-src — wherever step icons or a user's avatar are hosted, if the widget renders either
  • frame-src — only if the widget renders anything in an iframe, which a step-list embed usually shouldn't need to

That's the whole surface. A widget that doesn't need an iframe and doesn't inject inline styles can be embedded under a policy that only touches two directives, which is a much easier ask of a customer's security review than "open this up broadly."

Give the customer something they can paste, not a troubleshooting session

The failure mode to design against is a customer's engineer finding this out by trial and error, one blocked request at a time, in their own browser console, with no idea which of your three or four origins is the one still missing. The fix is cheap: publish the exact CSP fragment a host needs to add, with your real origins filled in, next to the embed snippet in the docs.

Content-Security-Policy:
  script-src 'self' https://cdn.example.com;
  connect-src 'self' https://api.example.com;
  style-src 'self' https://cdn.example.com;
  img-src 'self' https://cdn.example.com data:;

Keep that 'self' in front of each line — the point of a documented fragment is to extend the host's existing policy, not replace it, and a customer's security reviewer should be able to see at a glance that you're asking for exactly four origins, nothing broader.

Avoid the things that force a looser policy than you need

The most common way a widget forces a customer into a laxer CSP than they want is inline anything: an inline script tag for a tiny init call, or inline styles for quick theming. Both require 'unsafe-inline', which defeats a meaningful share of what CSP is protecting against and is the first thing a careful reviewer will flag. Move the init logic into the external bundle and accept data attributes on the script tag instead — the same data-account-token pattern already used for embedding on a customer's own domain — and the inline-script requirement disappears entirely.

Where this intersects with a nonce-based policy

Some host apps use a nonce instead of listing origins for script-src, generating a fresh random token per page load and only allowing script tags carrying it. A widget loaded via a static external script tag doesn't need the nonce at all — nonces apply to inline scripts, and an external file is already covered by script-src origin matching. This is worth saying explicitly in your docs, because it's the question that comes up most often from customers who've only ever seen nonce-based CSP and assume everything needs one.

Testing this before a customer's security review catches it

Don't wait for a customer's CSP to surface a missing directive. Set a strict policy on your own test page — deny by default, allow only the origins above — and load the real embed against it before shipping a change to the widget's asset origins. A new CDN domain, a moved API endpoint, or a newly added analytics call that silently starts hitting a different origin will all show up as a console warning on that test page in seconds, instead of as a blocked widget in a customer's production app weeks later.

What to measure

How often this actually bites a real customer isn't something to guess at from a support inbox, because a silently blocked widget usually doesn't generate a ticket at all — the user just sees nothing and the account logs a lower completion rate without an obvious cause. The number worth instrumenting once step-completion analytics exist per account, covered in piping checklist events into your analytics, is completion rate for accounts behind a known CSP-enforcing host versus the rest of your accounts. A gap there is the signal that the documented CSP fragment isn't reaching the people who need it, not a reason to assume the widget itself is broken.

Check the docs for the current list of asset origins before writing a CSP fragment for a customer's security review.

Try it on your app