Skip to content

Security Headers

Every release ships a recommended set of security headers, switched off. They are optional: the tool works without them. Switching them on limits what a malicious measurement file, phone book entry or third-party index could do in your visitors’ browsers, and stops other sites from framing yours.

They are off by default because a policy that fits the stock tool can break a customized one. Read What your customizations need before switching them on.

HeaderValueWhat it does
Content-Security-PolicyWritten for each release, see belowOnly scripts that belong to the tool may run
X-Content-Type-OptionsnosniffA data file is never run as a script
Referrer-Policystrict-origin-when-cross-originOther sites learn your address, not which device a visitor was looking at
Permissions-Policyhid, serial and bluetooth for your site only; camera and so on offHardware EQ keeps working; an embedded frame cannot reach a visitor’s USB devices

The Content-Security-Policy lists a hash for every inline script on the page. The app’s own start-up script changes with each release, so the policy is generated by the release build rather than written here.

Apache (Pre-built Release, CDN Deployment)

Section titled “Apache (Pre-built Release, CDN Deployment)”

The release’s .htaccess ends with a commented block:

# <IfModule mod_headers.c>
# Header set X-Content-Type-Options "nosniff"
# Header set Referrer-Policy "strict-origin-when-cross-origin"
# Header set Permissions-Policy "…"
# Header set Content-Security-Policy "…"
# </IfModule>

Remove the # in front of those six lines and upload the file. Then open the site with the browser console open: anything the policy blocks is reported there as an error naming the directive.

On a Pre-built Release, take the Content-Security-Policy line from the new release’s .htaccess every time you update, and re-apply your own additions. The old line does not know the new start-up script, and the page would stay blank. A CDN Deployment does not have this problem, because its index.html does not change between releases.

GitHub Pages, squig.link and other hosts without headers

Section titled “GitHub Pages, squig.link and other hosts without headers”

GitHub Pages cannot send custom headers, and squig.link is not an Apache host: it does not read .htaccess. On both, the policy goes in the page. The index.html of a CDN Deployment and of the GitHub Pages template carries it as a commented <meta> tag near the top of <head>:

<!-- <meta http-equiv="Content-Security-Policy" content="…" /> -->

Remove the <!-- and --> around it. Leave it where it is: it only governs what comes after it. A <meta> policy cannot stop other sites from framing yours, and the other three headers cannot be set this way at all.

The index.html of a Pre-built Release has no such tag, because its policy is in .htaccess. On one of these hosts, add the tag yourself, straight after <meta charset="utf-8" />: copy the value of the Content-Security-Policy line out of the release’s .htaccess and leave out frame-ancestors 'self', which a <meta> policy may not contain. Like the header, it has to be replaced with every release.

Copy the four values out of the release’s .htaccess into your server’s own header configuration.

The shipped policy covers the stock tool. Add to it for anything of your own:

If you…Add
host on squig.link (its analytics are on unless switched off)https://www.googletagmanager.com to script-src
list a Tag Manager container (GTM-…) of your ownthe origins of the tags it loads; a Custom HTML tag cannot run under this policy
are behind Cloudflare with its Web Analytics switched onhttps://static.cloudflareinsights.com to script-src
set RANKING.CONFIG_URLthat file’s origin to script-src
added an inline <script> to index.html, or edited oneits hash to script-src (the console error prints the hash to add)
added an external <script src> or stylesheetits origin to script-src or style-src
use a web font other than the defaultits origin to style-src and font-src
mirror the CDN assets under your own CDN_MODE.BASEthat origin to script-src, style-src and worker-src
load images over plain http:http: to img-src
connect to a network device (WiiM, Luxsin) from an HTTP sitehttp: to connect-src

Two things in your content stop working under any policy without 'unsafe-inline', and are worth fixing rather than allowing: inline event handlers (onclick="…") in an HTML TOPBAR.TITLE or DESCRIPTION, and javascript: links.

worker-src deserves the emphasis above. AutoEQ runs in a worker, and the browser checks the files a worker loads against worker-src, not script-src. If the origin is missing there, AutoEQ returns no result and the console shows no policy error.

Requests to data hosts are limited by scheme only (connect-src 'self' https: wss:), because the phone book, the cross-site index, the ranking sheet and the uniPEQ link server are all addresses you can configure.

Trusted Types makes the browser refuse plain text at the places that can run code, such as innerHTML, so a bug that lets a string reach one of them fails instead of running. Chrome and Edge enforce it, as do recent versions of Safari and Firefox; a browser without it ignores the directive.

It is not part of the shipped policy. To switch it on, add this to the end of the Content-Security-Policy value:

; require-trusted-types-for 'script'

The tool’s own code is written for it and the release tests run with it enforced, but those tests do not reach every feature. A place that was missed fails with a TrustedHTML or TrustedScriptURL error in the console, and that one feature stops working. Try it on your site before leaving it on, and please report what you find. A script of your own that assigns innerHTML, or adds a <script> tag from code, needs its own Trusted Types policy.

On a CDN Deployment it also stops the loader’s import map, as the policy itself already does.

  • Styles are allowed inline (style-src 'unsafe-inline'). The interface sets styles on elements directly, which no hash can cover.
  • On a CDN Deployment the policy blocks the import map the loader uses to hash-check lazily loaded files, and the console reports that once per visit. Stylesheets and the files loaded at start-up are still checked. See What a CDN deployment trusts.