0xDocs 0x.limo

Docs / Security

Content-Security-Policy

Each hosted version gets its own Content-Security-Policy. Declare outside hosts with "csp" in 0x.config.json, learn the enforce and report-only modes, and read your violation reports.

Every page and script of a hosted site is served with a Content-Security-Policy built for that version. The policy allows everything your game loads from its own origin, the 0x platform, and the inline <script> and <style> elements that shipped in your HTML. It blocks everything else unless you declare it when you publish.

Live since 2026-10-17

Versions published from 2026-10-17 on are enforced by default. Versions published before that are report-only: they report what the policy would block, but nothing is blocked.

#Declaring what your game needs: "csp"

Add "csp" to 0x.config.json. 0x publish (CLI 0.1.4 or later) sends it with the version:

json
{
  "id": "my-game",
  "name": "My game",
  "csp": {
    "connect": ["https://api.mygame.example", "wss://rt.mygame.example"],
    "img": ["https://*.cdn.mygame.example"],
    "font": ["https://fonts.gstatic.com"],
    "permissions": ["microphone"],
    "eval": false,
    "inline_styles": true
  }
}
keyadds tovalue
connectconnect-srcfetch, XHR, WebSocket, EventSource. https:// or wss:// origins.
imgimg-srcImages.
mediamedia-srcAudio and video.
fontfont-srcFonts.
scriptscript-srcScripts from other hosts.
frameframe-srcPages you put in an <iframe>.
permissionsPermissions-PolicyAny of camera, microphone, geolocation, usb, serial, hid, payment. See Permissions-Policy.
evalscript-src 'unsafe-eval'true allows eval() and new Function().
inline_stylesstyle-src 'unsafe-inline'true allows <style> elements created at runtime.

Origin rules, checked when you publish:

  • https:// only (wss:// too for connect); no path, query, user or IP address;
  • a host name with a domain (example.com or deeper). A port is allowed (wss://rt.example.com:8443);
  • a wildcard only as the whole first label: https://*.cdn.example.com;
  • at most 20 origins per kind and 64 in all; the whole declaration at most 8 KB.

A bad declaration refuses the upload with 422 and a list of problems, for example:

text
0x publish: upload refused:
  csp.img: "http://cdn.example.com": https:// origins only
  csp: unknown key "scripts" (connect, img, media, font, script, frame, permissions, eval, inline_styles)

The upload page (https://api.0x.limo/hosting/) has the same fields under Security policy. With the API, send csp in POST /v1/hosting/sites/<site>/versions.

A declaration belongs to one version. Publishing a new version without "csp" gives that version an empty declaration.

#The policy

For an enforced version, the policy looks like this, with your declared origins added to each directive:

text
default-src 'self';
script-src 'self' 'wasm-unsafe-eval' <inline script hashes> https://static.cloudflareinsights.com [script] ['unsafe-eval'];
style-src 'self' <inline style hashes | 'unsafe-inline'>;
style-src-elem 'self' <inline style hashes | 'unsafe-inline'>;
style-src-attr 'unsafe-inline';
connect-src 'self' https://api.0x.limo https://play.0x.limo wss://api.0x.limo wss://play.0x.limo https://cloudflareinsights.com [connect];
img-src 'self' data: blob: [img];
media-src 'self' data: blob: [media];
font-src 'self' data: blob: [font];
worker-src 'self' blob:;
frame-src 'self' [frame];
object-src 'none'; base-uri 'none'; form-action 'self';
frame-ancestors 'self' https:;
report-uri /x1/csp; report-to csp

Notes:

  • Inline code by hash. When you publish, 0x hashes every inline <script> and <style> in your HTML files (SHA-256 of the text as the browser sees it, with CR LF read as LF; HTML comments are skipped; a <script src> has no inline code). Those exact blocks run without 'unsafe-inline'. If you change an inline block, publish a new version.
  • More than 64 inline blocks keep a version report-only, because the header would get too large. The publish output prints a warning. Move inline code into files.
  • style="..." attributes are allowed (style-src-attr 'unsafe-inline'). <style> elements made at runtime are not, unless you declare "inline_styles": true. Many UI libraries create them, so check your reports.
  • WebAssembly is always allowed ('wasm-unsafe-eval'). eval and new Function are not, unless declared. Some engines and template libraries need them.
  • Cloudflare Web Analytics. Cloudflare injects its analytics beacon into HTML it proxies, so static.cloudflareinsights.com and cloudflareinsights.com are allowed on every site. Your game didn't add them.
  • Frame ancestors are 'self' https:, because 0x.limo/embed/<id> lets any site embed your game.
  • WebRTC (peers, TURN) is not governed by CSP.

#Modes

modeheaderseffect
enforceContent-Security-Policy (the policy), Content-Security-Policy-Report-Only (a stricter copy), Permissions-PolicyViolations are blocked and reported.
report-onlyContent-Security-Policy-Report-Only (the policy)Nothing is blocked. Reports show exactly what enforcing would break.
offnoneNo policy headers.

A version's own mode is enforce if it was published on or after 2026-10-17, otherwise report-only. 0x's reviewers can switch a whole site (to enforce, report-only or off). They can also approve, flag or reject parts of a declaration, or block a host. You see the result, the served declaration, next to what you published (see Your site's policy).

The stricter report-only copy that comes with an enforced version also reports style="..." attributes and frame ancestors other than the store and X. That is information for 0x about future tightening. It never blocks anything.

#Preview enforcement

Open any page of a report-only version with ?x1-csp=enforce to get it enforced, for example https://<site>-play.0x.limo/sites/<site>/3/?x1-csp=enforce. A preview can only tighten the policy. Use it to check an old version before 0x switches it.

#When headers change

0x asks for a version's headers on every page and script request and caches them for 30 seconds, so a switch applies within about a minute:

  • Pages (/, *.html) are Cache-Control: no-cache, so returning players get the current headers.
  • Other files are immutable for a year. A script a browser cached before a switch keeps the headers it was fetched with.
  • Files served by the swarm service worker carry no CSP of their own. The page's policy still governs the page.
  • If 0x can't compute a version's policy, the page gets a report-only baseline instead: it keeps loading, and nothing is enforced.

#Violation reports

Browsers post violations to /x1/csp on your site's own origin (report-uri and the Reporting API's report-to). 0x adds them up per version, directive, blocked origin and source file:

  • Kept: the count, first and last seen, the line and column of the last one, and the disposition (enforce = blocked, report = would be blocked).
  • Not kept: blocked URLs are reduced to their origin, and source files lose their query and fragment. The referrer, sample, user agent and the reporter's address are never stored.
  • Up to 300 distinct rows per version; past that, reports fold into (directive, other). Rows not seen for 90 days are deleted.

Read them on https://api.0x.limo/dev/submit (Site policy reports), or with the API using a publish token or an access token:

bash
# every site of yours, the last 30 days
curl -s -H "Authorization: Bearer $ZEROX_TOKEN" https://api.0x.limo/v1/hosting/csp-reports

# one site, one version, the last 7 days
curl -s -H "Authorization: Bearer $ZEROX_TOKEN" \
  "https://api.0x.limo/v1/hosting/sites/my-game/csp-reports?version=3&days=7"
json
{
  "items": [
    {"site": "my-game", "version": 3, "directive": "connect-src", "blocked": "https://api.mygame.example",
     "source_file": "https://my-game-play.0x.limo/sites/my-game/3/main.js", "count": 41, "line": 120, "col": 9,
     "disposition": "enforce", "first_seen": 1792250000, "last_seen": 1792259000}
  ],
  "totals": [{"site": "my-game", "version": 3, "reports": 41, "rows": 1, "first_seen": 1792250000, "last_seen": 1792259000}],
  "days": 30
}

blocked is an origin, or a keyword the browser sent: inline (an inline script or style without a matching hash), eval, wasm-eval or data.

#Reading a report

directiveblockedusually meansfix
connect-srchttps://api.example.comfetch/WebSocket to your backenddeclare it under connect
script-src-elemhttps://cdn.example.coma <script src> from a CDNvendor it into your site, or declare it under script
script-src-eleminlinean inline script that changed after publish, or was added at runtimemove it into a file
script-srcevaleval or new Functionremove it, or declare "eval": true
style-src-eleminlinea <style> created at runtime (UI libraries do this)declare "inline_styles": true
img-src / font-src / media-srcan originassets from another hostserve them from your site (they then go on the swarm), or declare them
frame-srcan originan embedded video or pagedeclare it under frame
frame-ancestorsan originfrom the stricter report-only copy: your game embedded on another sitenothing: it is informational

#Your site's policy

GET /v1/hosting/sites/<site>/policy (your sites only) returns the policy of each of your site's latest 20 versions: the mode and where it comes from (version, site or global), the declaration as published (declared) and as served (effective_declared), the review of it, the number of inline hashes, warnings, and the exact headers.

bash
curl -s -H "Authorization: Bearer $ZEROX_TOKEN" https://api.0x.limo/v1/hosting/sites/my-game/policy

Anyone can read a published version's headers, because they are the same headers every visitor gets:

bashtested
curl -s -o /dev/null -w '%{http_code}\n' https://api.0x.limo/v1/hosting/policy/hellengine/10

That route answers with headers only: X-X1-Csp-Mode, X-X1-Csp, X-X1-Csp-Ro and X-X1-Pp. Use curl -sD- -o /dev/null to see them.

0x publish also prints the mode, what you declared and how many inline blocks were hashed:

text
0x publish: security policy enforced; declared connect: https://api.mygame.example; 1 inline scripts and 2 <style> elements allowed by hash