Files
poli0981andClaude Opus 5.5 0240abfd02 docs: the Worker's rate limits count per server, as measured
Measured on production after v4.5.1 deployed (2026-10-27, SIN): over one
keep-alive connection each budget held exactly - /api/no-such-route
121 x 404 then 429 with Retry-After, no-store and CORS; /api/human-check
19 then 429 - while requests on fresh connections, which Cloudflare
spreads over many servers, were never refused (175 human checks in 70 s
against a budget of 20). A probe Worker in a remote preview confirmed the
binding itself enforces (limit 5: 6 allowed, then refused).

So the layer stops browsers and connection-reusing scripts; a client that
reconnects for every request is the WAF rule's, which counted exactly
(250). The docs, CLAUDE.md, the module comment, wrangler.jsonc and the
unpublished v4.5.1 entry said "per location, approximate"; they now say
what was measured. The section 3b check used xargs (fresh connections) and
would have shown no 429 - it now sends everything over one connection.
No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:10:29 +07:00

47 KiB
Raw Permalink Blame History

Security setup

What is already enforced in code, and what you still have to switch on in the Cloudflare dashboard. Every item ends with a command you can run to check it, because a security setting you believe is on and is not is worse than one you know is off.

Companion docs: ADMIN.md for Access and the GitHub App, DEPLOYMENT.md for the Worker itself.


1. Response headers — done in code

Three places now, and none inherits from the others:

File Covers
web/build/sveltekit-config.ts (csp) the Content-Security-Policy on every app page
web/static/_headers every other security header on static assets
web/worker/lib/http.ts everything the Worker generates (/api/*, /img/*)

Add a header that must hold everywhere and you must add it in each.

Why the CSP moved out of _headers (2026-09-12)

SvelteKit emits exactly one inline <script> per page — the hydration bootstrap — and offers no way to avoid it. Under the old header policy's script-src 'self' the browser blocked it, so every page rendered its prerendered HTML and then sat there completely inert. Measured in a real browser, on every route:

Executing inline script violates the following Content Security Policy
directive 'script-src 'self''

The csp option with mode: "hash" makes SvelteKit compute that script's sha256 at build time and emit the whole policy as a <meta> tag that already trusts it.

The header CSP had to go, not just relax. Browsers enforce the INTERSECTION of a header policy and a meta policy, so leaving script-src 'self' in _headers would have kept blocking the script no matter what the meta allowed.

One directive is lost in the move: frame-ancestors is ignored in a meta CSP. X-Frame-Options: DENY stays in _headers and is now load-bearing rather than belt-and-braces.

Note web/public/ is web/static/ since the SvelteKit migration.

The CSP

default-src 'self';
script-src 'self' https://static.cloudflareinsights.com https://challenges.cloudflare.com;
style-src 'self' 'unsafe-inline';
img-src 'self' data: https://media.free-steam-games.win https://shared.akamai.steamstatic.com https://shared.fastly.steamstatic.com https://cdn.akamai.steamstatic.com;
font-src 'self'; connect-src 'self' https://cloudflareinsights.com;
frame-src 'self' https://challenges.cloudflare.com;
worker-src 'self'; manifest-src 'self'; media-src 'none'; object-src 'none';
base-uri 'none'; form-action 'none'

No frame-ancestors: it is ignored in a meta CSP, and this policy is emitted as one. X-Frame-Options: DENY in web/static/_headers is what stops framing (see the subsection above).

Verified by loading the built app under it and walking /games, four chart pages, /about, /health and /activity.

/activity was missing from that walk until 2026-09-12, and it was the one page with a violation: it rendered commit avatars straight from avatars.githubusercontent.com, which appears in none of this repo's four CSPs, so every avatar on the page was blocked. A route added after a CSP walk does not inherit its result — re-walk, or the claim rots.

Two directives are the way they are for measured reasons, not by preference:

  • style-src needs 'unsafe-inline'. Bits UI positions popovers and dialogs with inline style attributes, the virtualised table places its rows that way, and ECharts sizes its canvas the same way. This is the acceptable half of the trade: the app renders no user-supplied HTML, and script-src stays strict, which is the directive that actually stops code execution.
  • script-src carries two external hosts and one hash, and no 'unsafe-inline'. The hosts are the Web Analytics beacon (section 9) and Turnstile's api.js for the human check (section 12); the hash is SvelteKit's own per-page bootstrap. index.html also contains an inline <script type="application/ld+json">, but that is a data block which is never executed, so script-src does not govern it.
  • frame-src exists only for the Turnstile widget, which is an iframe from challenges.cloudflare.com. Without the directive, frames fall back to default-src 'self' and the widget is refused.

connect-src allows 'self' and the analytics beacon's reporting host, and nothing else. It notably does not allow https://api.github.com, which it used to for one page. Both reasons are gone:

  • The Activity page now reads /api/activity, a Worker route that fetches the commit list server-side, narrows it to the fields the page renders (dropping the author email GitHub returns for every commit, and the message body, whose Co-Authored-By trailers carry real addresses), and rewrites avatar URLs to /img/gh/{u|in}/{id}. Edge-cached for 5 minutes, which also bounds upstream traffic to ~12 calls/hour against GitHub's anonymous budget of 60.
  • The Android release check still calls api.github.com, but only under isTauri() && isAndroid(), and the packaged apps use the separate CSP in src-tauri/tauri.conf.json — not this file.

The two cloudflareinsights.com hosts and challenges.cloudflare.com are web only, added by the same IS_TAURI ternary: the packaged apps must not phone a beacon or run the human check, and scripts/verify-dist.mjs fails the web build without them and the Tauri build with any of them.

img-src correspondingly does not list avatars.githubusercontent.com. Avatars are proxied. Widening img-src would have been the smaller diff and the wrong call: it puts a third-party host back in the page and hands every visitor's IP to GitHub, which the privacy policy says does not happen.

Why there is no CSP on API responses

They are JSON and images, not documents; a policy would govern nothing. The one HTML document the Worker does serve — the admin app's shell, for /admin and its four sibling routes — carries its own stricter CSP: default-src 'none' and a script-src of a per-response nonce and nothing else (worker/routes/admin-spa.ts). worker/routes/admin-spa.test.ts checks the nonce is fresh per response and that script-src never gains 'unsafe-inline'.

Why Cross-Origin-Resource-Policy is static-only

The Tauri desktop and Android builds run on tauri://localhost or http://tauri.localhost and fetch /api/data/* and /img/* from this origin cross-site (API_ORIGIN in src/lib/site.ts). same-site on those responses would blank every image and stop the catalogue loading in the packaged apps. Static assets are only ever loaded by this site, so they can carry it.

Check:

curl -sI https://free-steam-games.win/ | grep -i "content-security-policy"
curl -sI https://free-steam-games.win/api/data/data/index.json | grep -iE "permissions-policy|cross-origin"

The second must print a Permissions-Policy and no Cross-Origin-Resource-Policy.


2. HSTS — already on, and stronger than you may realise

The zone currently sends:

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

It is set by the Cloudflare zone (SSL/TLS → Edge Certificates → HTTP Strict Transport Security), not in web/static/_headers or the Worker — on purpose. The zone setting stamps every response, static and Worker-generated alike, and any subdomain created later. Setting it in code as well would mean keeping two files in step and risking a second Strict-Transport-Security header, of which browsers honour only the first. Verified live on /, /api/data/* and /assets/*: all three carry the value above.

That is the maximum setting. Two consequences worth a deliberate decision:

  • includeSubDomains for a year. Every future subdomain must be HTTPS from the moment it exists. A browser that has seen this header will refuse plain HTTP to anything.free-steam-games.win for a year, and there is no way to shorten that for someone who already received it.
  • preload is an invitation. The domain is not on the preload list today — verified: hstspreload.org/api/v2/status?domain=free-steam-games.win returns "status": "unknown". But the list accepts submissions from anybody for any domain whose header contains preload and which meets the criteria. Leaving the directive in place means a third party can put you on it, and removal then takes months and a browser-vendor process.

Decided 2026-09-12: submit for preloading

Of the two options this section used to leave open — submit it yourself, or remove the preload directive so nobody else can — the maintainer chose to submit. Rationale: the directive is already in the header, so the invitation is already open to third parties; submitting deliberately is strictly better than leaving it for someone else to do on a schedule you do not control.

Eligibility was verified before the decision, and there are no blockers:

curl -s "https://hstspreload.org/api/v2/preloadable?domain=free-steam-games.win"

returned {"errors": [], "warnings": []} — a clean pass. Port 80 also 301s to HTTPS, which is one of the criteria. So all four requirements hold: valid certificate, HTTP → HTTPS redirect, max-age of at least 31536000 with includeSubDomains and preload, and every subdomain HTTPS-only.

This step is the maintainer's to perform, and it is not reversible on any useful timescale. Submission at https://hstspreload.org bakes HTTPS-only for free-steam-games.win and every subdomain into shipped browser binaries. Removal requires a separate request plus the months it takes for browser releases to roll over. Do not submit until you are certain no subdomain will ever need plain HTTP.

Check the header, then the list status:

curl -sI https://free-steam-games.win/ | grep -i strict-transport
curl -s "https://hstspreload.org/api/v2/status?domain=free-steam-games.win"

"status": "unknown" means not submitted. After a successful submission it becomes "pending", and "preloaded" once it ships in a browser release.


3. Rate limiting — two layers, the WAF rule first

Two limits, in this order:

  1. The zone's WAF rate-limiting rule (3a) refuses a burst at the edge, before the Worker runs: a flood it catches costs no Worker invocation, no subrequest and no R2 read. It is also the only limit on the prerendered pages, which never reach the Worker.
  2. The Worker's limits (3b, web/worker/lib/rate-limit.ts) give each surface the Worker serves its own budget over 60 seconds. They stop a client that keeps its connection open and paces itself just under the WAF's 10-second threshold, and they keep holding if the WAF rule is edited or deleted - the same reason BLOCKED_COUNTRIES sits beside the country rule (section 4). They count per server, not per data centre (3b), so a client that reconnects for every request is the WAF rule's to stop.

Neither replaces the other. The WAF rule alone cannot tell a human check from an image, and the Worker alone has already been invoked, and billed, by the time it says no.

3a. The WAF rule — one rule, and it blocks

The Free plan allows exactly one rate-limiting rule, and fixes most of it: counting by IP only, a 10-second period, a 10-second mitigation timeout, expression fields limited to the URI path and verified-bot status, and cached requests count too (no cache exclusion). A refused request gets HTTP 429 with Cloudflare's error 1015 page. So the decision is not how many rules but what the single rule covers.

Recommended (since 2026-10-27): the whole zone except the hashed bundles. Security → Security rules → Rate limiting rules → the existing rule → Edit (the Free plan cannot add a second one):

Field Value
Rule name site-wide
Expression not starts_with(http.request.uri.path, "/_app/immutable/") and not cf.client.bot
Characteristics IP
Period 10 seconds
Requests 250
Action Block
Duration 10 seconds

Why this scope: every page, the API, the image proxy, the icons and the service worker count, on every hostname of the zone - the rule has no hostname field, so media.free-steam-games.win counts too. /_app/immutable/* is left out because a cold first visit fetches about 115 of those files at once (the home page alone preloads 53), the browser then keeps them for a year, and the asset server serves them at no cost. not cf.client.bot keeps verified search crawlers, which read the 10,000 prerendered game pages, out of the count.

Why 250 per 10 seconds, counted from the build rather than a template: right after consent and the human check, a first visit sends the page and its icons (about 6 requests), the service worker's precache of 56 non-hashed URLs (41 pages, 8 __data.json, 6 images and the manifest), the catalogue (about 16: index.json, 14 shards, the removed-games list), /api/activity, /api/human-check and the dashboard's thumbnails - 110 to 130 requests within a few seconds. 150 left no room for a second person behind the same address (a shared office, or a mobile carrier's CGNAT); 250 does. A script faster than 25 requests a second is blocked for 10 seconds, again and again; one slower than that meets the Worker's per-minute budgets on the paths that cost money.

Block is tolerable because the timeout is fixed at 10 seconds: a false positive costs a real visitor ten seconds of missing thumbnails, not a lockout.

The narrower rule it replaces is still a valid choice if pages should not count at all - the Worker limits cover /api/* either way:

Field Value
Rule name public-proxies
Expression (starts_with(http.request.uri.path, "/img/") or starts_with(http.request.uri.path, "/api/data/")) and not cf.client.bot
Requests 150 per 10 seconds, IP, Block for 10 seconds

Check (blocks your own IP for 10 seconds, which is the point; a static file, so no Worker invocation is spent):

for i in $(seq 1 400); do printf 'url = "https://free-steam-games.win/robots.txt"\noutput = "/dev/null"\n'; done | curl -s --parallel --parallel-max 50 -w '%{http_code}\n' -K - | sort | uniq -c

Expected: about 250 × 200, then 429s (measured 2026-10-27: 250 and 150). It has to be ONE curl --parallel, which reuses its connections: a loop or xargs of separate curls pays a TLS handshake per request, stays near 20 requests a second from a home connection and never reaches the limit (measured: 300 × 200). On Windows curl.exe, write NUL for /dev/null. With public-proxies instead, a static file is never counted: use /api/data/data/index.json and expect about 150. Watch Security → Events for a week before changing the threshold.

3b. The Worker limits — one budget per surface

ratelimits bindings in web/wrangler.jsonc, checked by web/worker/lib/rate-limit.ts after the country block and before every route, the admin surface's Access check included:

Binding Paths Requests per IP per minute
RL_DATA /api/data/* 240
RL_IMG /img/* 600
RL_API /api/activity, /api/updates/desktop, any other public /api/* 120
RL_HUMAN /api/human-check 20
RL_ADMIN /admin, /admin/*, /api/ingest/* 300
  • Key: the client's IPv4 address, or its IPv6 /64 (one subscriber usually holds a whole /64).

  • What it counts, measured 2026-10-27 in Singapore (SIN), not what the docs imply. Cloudflare's documentation says counts are per location and eventually consistent. In practice each count lives on the server running the Worker and reaches the rest of the data centre too slowly to matter within a minute:

    • over ONE keep-alive connection the limit held exactly: /api/no-such-route 121 × 404 then 429, /api/human-check 19 × 405 then 429;
    • with a new connection per request, which Cloudflare spreads over many servers, it refused nothing: 175 human checks in 70 seconds, budget 20.

    So this layer limits a browser (HTTP/2 carries a whole page on one connection) and any script that reuses its connection, which is most of them. A client that reconnects for every request pays a TLS handshake each time and is stopped by the WAF rule, which counted exactly (3a). Either way these are ceilings for abuse, never quotas. Each sits well above what a person, the apps or the discovery workflow sends: a cold catalogue load is about 16 data requests, a person sends one human check a day, discovery a few ingest calls a run. A strict per-data-centre count would need a Durable Object on every request - not worth it while the WAF rule exists.

  • Refusal: HTTP 429, {"error":"too many requests"}, Retry-After: 60, Cache-Control: no-store. /api/data/* and the public API also carry Access-Control-Allow-Origin: *, so the packaged apps see the 429 instead of a CORS failure; the human check and the admin surface carry none (they are same-origin by design).

  • Clients: a 429 on a pack makes the site and the apps try the plain shard once, then report a failed load; the human check lets the reader through (it refuses only on Cloudflare's verdict); discovery stops its run with the status.

  • Fails open: no binding, no CF-Connecting-IP, or a limiter that throws lets the request through. The WAF rule is the boundary; this must never be why the catalogue does not load.

  • Not logged: Workers Logs already records every invocation with its status - filter on 429. A console line per refusal would double the log volume of exactly the floods this is for. The bindings do not appear in the dashboard.

  • Changing a limit is a pull request to web/wrangler.jsonc (it deploys with the Worker). Keep every period at 60, which is what Retry-After promises (rate-limit.test.ts checks), and keep each namespace_id unique within the Cloudflare account: two bindings with one ID share their counters, across Workers too.

Check (after a deploy; spends 130 cheap invocations). One curl with the list on stdin and no --parallel sends every request over the same connection, which is what this layer counts:

for i in $(seq 1 130); do printf 'url = "https://free-steam-games.win/api/no-such-route"\noutput = "/dev/null"\n'; done | curl -s -w '%{http_code}\n' -K - | sort | uniq -c

Expected: about 120 × 404, then 429 for the rest of that minute (measured 2026-10-27: 121 and 19; on Windows curl.exe, write NUL for /dev/null). A loop or xargs of separate curls connects anew each time and may see no 429 at all - that is the per-server counting above, not a broken limit.


4. Bots and countries — one switch left off, two rules live

It sounds like a free win and here it is not. Cloudflare's own documentation says two things that decide it:

  • it "may challenge API or mobile app traffic", and
  • "you cannot bypass or skip Bot Fight Mode using WAF custom rules or Page Rules".

This site's most important non-browser clients are exactly that traffic:

  • The desktop and Android apps fetch /api/data/* with plain fetch(). A challenge answers with an HTML page no app can solve, so the apps would stop loading the catalogue — the same symptom the CORS fix just repaired.
  • The discovery workflow calls /api/ingest/* from GitHub Actions, a datacenter IP running a script client — the textbook thing it challenges.

Only an IP Access rule takes precedence over it, and GitHub's runner ranges are far too broad to allowlist sensibly. The rate-limit rule above already covers the abuse that actually costs money here.

The human check that IS safe here — human-check-pages, active

What Bot Fight Mode cannot be — scoped — a WAF custom rule can. Custom rules are a separate quota from the single rate-limiting rule above (the Free plan allows five; two are used), and a Managed Challenge from one of them can be aimed at page loads only.

Live since 2026-09-20, order 1, and its challenge-solve rate has stayed at 0% — ordinary visitors are not seeing it, which is the intent. Security → WAF → Custom rules is the source of truth for the exact expression; this is what it was created from:

Field Value
Rule name human-check-pages
Expression not starts_with(http.request.uri.path, "/api/") and not starts_with(http.request.uri.path, "/img/") and not starts_with(http.request.uri.path, "/_app/") and not starts_with(http.request.uri.path, "/.well-known/") and not cf.client.bot and cf.threat_score > 14
Action Managed Challenge

Every exclusion is load-bearing, and each one is a thing that breaks without it:

  • /api/ — the packaged apps' catalogue fetch and the GitHub Actions ingest call. An HTML challenge page is not something either can solve; this is the exact failure Bot Fight Mode would cause, reintroduced by hand.
  • /img/ — artwork, requested by the apps cross-origin.
  • /_app/ — hashed bundles. Challenging a module request breaks hydration on a page that already passed the check.
  • /.well-known/ — security.txt exists to be read by scanners.
  • not cf.client.bot — verified crawlers. Challenge Googlebot and the site leaves the index.

cf.threat_score narrows it further, so an ordinary visitor never sees the interstitial. Drop that condition to challenge every page load, and expect complaints. Watch Security → Events for a week either way.

Measured after it went live — a plain curl with no browser User-Agent still gets 200 on /, /games, /legal/tos, /.well-known/security.txt, /sitemap.xml and /robots.txt, and a real browser loads a game page, the service worker and the analytics beacon with no interruption. A script client is not automatically challenged, because the threat score is what decides.

docs/PRIVACY_POLICY.md describes this check to visitors; it is a third party interrupting their page load, so it belongs there.

Blocking countries — blocked-countries, active

Second custom rule, live since 2026-09-20, order 2, and the actual boundary for the country restriction:

Field Value
Rule name blocked-countries
Expression ip.geoip.country in {"CN" "RU" "AR"}
Action Block

"CN" is mainland China only — Hong Kong, Macau and Taiwan are HK, MO and TW and are not matched.

This rule, not the Worker, is what blocks the site. BLOCKED_COUNTRIES in web/wrangler.jsonc makes the Worker refuse the same countries (worker/lib/geo.ts), but the Worker only ever sees the four assets.run_worker_first prefixes — the prerendered HTML is served by the static-asset server without invoking it. Someone in a blocked country would read every page and only find the catalogue missing. Keep both: the var is reviewable in Git and holds if the rule is ever deleted or mis-scoped, and the rule is what actually covers the site.

Know what this costs before turning it on:

  • Yandex indexing ends. Its crawler is in RU, and ip.geoip.country is evaluated before cf.client.bot matters to a Block action.
  • The desktop and Android apps stop working in those countries, updater feed included — they fetch the same /api/* paths.
  • VPNs evade it trivially. This is a posture, not a security control.
  • Tor exits report as T1, which is not a country code and is not matched; worker/lib/geo.ts also refuses to treat XX (unknown) as one, so adding it to the var cannot accidentally block everyone the edge failed to place.

Check — and read this before trying, because the obvious check does not work. Sending -H 'CF-IPCountry: CN' to production proves nothing: worker/lib/geo.ts reads request.cf.country first, which comes from the real client IP and cannot be spoofed, and Cloudflare overwrites that header on ingress anyway. The header fallback exists only for environments that have no request.cf at all.

So there are two honest checks:

  • The WAF rule: from a real address in one of those countries, or from Security → Events, which is where a Block shows up.

  • The Worker's own refusal, locally: wrangler dev supplies its own request.cf (measured: country: "SG"), so temporarily add that country to BLOCKED_COUNTRIES, restart, and watch every Worker route refuse:

    for p in /api/activity /api/data/data/index.json /img/t/730/header.jpg /admin /; do
      printf '%-28s %s\n' "$p" "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8790$p)"
    done
    

    Expected: 403 four times — and / still 200, because a static asset never invokes the Worker. That last line is the whole reason the WAF rule cannot be skipped. Put the real list back afterwards.

Managed rules (Security → WAF → Managed rules): leave on whatever your plan provides. This site has no form posts, one small JSON POST (/api/human-check, section 12) and no SQL, so false positives are unlikely — but if the apps, discovery or the human check start failing after a ruleset change, check Security → Events first.

This rule and the Turnstile check in section 12 are different things. This one is Cloudflare's own interstitial, at the edge, for page loads whose threat score is high. Section 12 is a widget in the web app that every browser passes once a day after accepting the terms.


5. Cloudflare Images spend

The account is on Images Paid (since 2026-10-02): the first 5,000 unique transformations a month are included, then $0.50 per 1,000. Cloudflare has no spend cap, so the cap is ours. The agreed budget is $15/month.

  • Only the cron transforms. web/worker/lib/img-mint.ts mints AVIF copies of the catalogue's header art into the R2 bucket f2p-media, most-played games first; /img/* only reads them (web/worker/routes/img.ts). No request
    • an unknown appid, a forged ?t=, a HEAD - can create a transformation.
  • IMG_TRANSFORM_MONTHLY_CAP (web/wrangler.jsonc, 20,000 = at most $7.50) is enforced by a counter in D1 admin_state, key img_transforms:YYYY-MM. Every attempt is counted before it runs, and a missing table or cap means nothing is minted.
  • Kill switch: IMG_TRANSFORM, changed in wrangler.jsonc by a PR. There is no keep_vars, so a dashboard edit is undone by the next deploy - fine for an emergency stop, not as the real setting.
  • The whole catalogue is ~11k transformations once (~5,600 sources x 2 widths, ≈ $3 above the free 5,000); after that only new games and changed art (a new Steam ?t=) cost anything. The quality is part of the key (web/shared/img-keys.ts), so changing one variant's quality re-mints that variant only (~5,600 transformations, ≈ $3).
  • /cdn-cgi/image/ must not work on this zone. The Images binding takes bytes and never uses that URL. With zone Transformations ON, even Sources = "This zone only" accepts same-zone images - including /img/*, which proxies ANY Steam appid - so anyone could request /cdn-cgi/image/width=<1..2000>,quality=<…>/img/d2/<appid>/header.jpg and have each new option set billed as a new transformation, outside IMG_TRANSFORM_MONTHLY_CAP (measured 2026-10-02: /cdn-cgi/image/width=77/img/d2/440/header.jpg answered 200, cf-resized: internal=ok). The zone itself is always an allowed source; Sources cannot exclude it.
    • In code: web/worker/routes/img.ts refuses (403) any request whose Via header names image-resizing - the resizer fetches sources with Via: 1.1 image-resizing-proxy - so /img/* can never be a source.
    • In the dashboard: zone Transformations are OFF (Images → Transformations → free-steam-games.win, since 2026-10-02). Measured: every /cdn-cgi/image/... request now answers 404, and the cron kept minting with them off (10:30Z tick: 40 sources) - the Images binding does not need them. Keep it that way. If they are ever turned back on, the static files (icons, og.png) become transformable with arbitrary options again; keep Sources at the zone only and never add another origin (least of all Steam's hosts).

Notifications → Add → Cloudflare Images: alert at 5,000 (billing starts) and 20,000 unique transformations. The D1 counter (SELECT * FROM admin_state WHERE key LIKE 'img_transforms:%') and the img-mint lines in Workers Logs say what the cron has done.

The media host — media.free-steam-games.win

The web app loads the minted AVIF straight from the bucket's custom domain (MEDIA_ORIGIN, web/src/lib/site.ts), so a repeat view is a cache hit at Cloudflare that runs no Worker and reads nothing from R2. /img/* cannot do that whatever its headers say: a Worker always runs BEFORE the cache, so s-maxage there only ever saved the Steam fetch. Every such <img> falls back to /img/* on an error - a key not minted yet answers 404, and a browser without AVIF cannot decode it - and the packaged apps use /img/* only.

  1. R2 → f2p-media → Settings → Custom Domains → Connect Domain → media.free-steam-games.win. Cloudflare creates the proxied DNS record itself; the status goes from Initializing to Active in a minute or two. Leave the r2.dev subdomain disabled.
  2. Caching → Tiered Cache → Smart Tiered Cache, on since 2026-10-03: a miss in one data centre is filled from an upper tier before R2 is asked. The Origin Configuration table there asks for cloud region hints; leave them unset - its rows are Steam's and GitHub's CDNs, which the Worker fetches, not origins in one cloud region.
  3. No Cache Rule is needed. .avif is one of Cloudflare's default cached extensions, and every object carries the mint's Cache-Control: public, max-age=31536000, immutable. A key that is not minted yet answers 404, and the page falls back to /img/* until it is. Add a rule only if the check below shows cf-cache-status: DYNAMIC.
  4. Recommended — WAF custom rule media-host-paths, action Block: http.host eq "media.free-steam-games.win" and not (starts_with(http.request.uri.path, "/img/v2/") and ends_with(http.request.uri.path, ".avif")). The WHOLE bucket is public on this host - the mint's progress marker (meta/img-mint-v1.json) and the superseded img/v1/ objects included - and a junk path can cost an R2 read. This leaves exactly the art. It is the third of the five custom rules the Free plan allows.

Already covered, nothing to add:

  • human-check-pages excludes every path starting /img/, on any host, and every key starts img/v2/ - the art is never challenged, as ToS §9 promises for /img/*.
  • blocked-countries covers the whole zone, this host included.
  • Hotlink Protection: every <img> sends no Referer (section 10).

Check, after connecting:

curl -sI https://media.free-steam-games.win/img/v2/460q80/730/header@1749053861.avif

Expected: 200, content-type: image/avif, cache-control: public, max-age=31536000, immutable, and on a repeat cf-cache-status: HIT. With the rule from step 4, curl -sI https://media.free-steam-games.win/meta/img-mint-v1.json answers 403.


6. Repository hardening

  • Branch protection. The GitHub App can write to main, and so can the pipeline. Add a ruleset on main that blocks force pushes and deletions (Settings → Rules → Rulesets). The Worker never force-pushes — createCommitOnBranch cannot — so this costs nothing and closes a hole.

  • Delete the retired secret. The Telegram ingest path is gone:

    gh secret delete TELEGRAM_BOT_TOKEN
    

    Then revoke the token itself with Telegram's @BotFather — deleting the repository secret does not invalidate it.

Check what is left:

gh secret list

Expected: STEAM_API_KEY, the three CF_ACCESS_*/WORKER_BASE_URL discovery secrets, the four ANDROID_* signing secrets, TAURI_SIGNING_*, and the Discord webhooks. Anything else is a leftover.


7. What is already true, and why

Not everything needs switching on. For the record:

  • /admin (the SPA and its API at /admin/api/*, one application) and /api/ingest/* are Access-gated, with AUDs scoped per route so the unattended discovery token cannot reach the admin surface that holds the repository-write credential.
  • workers_dev is false. A zone Access policy does not cover *.workers.dev, so leaving that hostname live would be a way around Access into the Worker holding that credential.
  • The Worker can only write two paths — scripts/temp_info.jsonl and data/overrides/<appid>.json — enforced by an anchored allowlist in worker/lib/git-commit.ts. It cannot touch data/ shards.
  • The discovery pipeline runs with permissions: contents: read and a CI step that fails if a discovery script references a dataset-writing helper.
  • audit_log records the acting Access identity and the target, and deliberately no IP, User-Agent or country — matching what PRIVACY_POLICY.md promises. The country block in section 4 reads request.cf.country per request and stores nothing: no row, no log, no counter.
  • Commits made from /admin say "by admin", not the reviewer's Access address, and data/overrides/*.json records "set_by": "admin" for the same reason — those files are public forever. Who did what stays in D1 (shared/admin-api.ts, ADMIN_ATTRIBUTION).

8. security.txt — and the one date that will rot

web/static/.well-known/security.txt (RFC 9116) points researchers at GitHub's private vulnerability reporting first and security@poli0981.dev second, as two Contact: fields in that order.

It is a plain static file. /.well-known/* is not in wrangler.jsonc's run_worker_first, so it never invokes the Worker, and Cloudflare's asset server infers text/plain from the extension. It has to exist as a real file: not_found_handling is "single-page-application", so before it was added a request for it returned dist/index.html with HTTP 200 — scanners got a web page and no error.

Recurring task: renew Expires before 2027-09-01. RFC 9116 requires the field and scanners treat an expired file as no file at all. Bump the date and redeploy; there is nothing else to do.

Check:

curl -s https://free-steam-games.win/.well-known/security.txt

Must return the field list as text/plain, not the SPA shell.


9. Web Analytics — the JS snippet, never the automatic setup

Automatic injection was on from before 2026-09-12 and never collected a single page view. Every load logged two CSP violations instead:

Loading the script 'https://static.cloudflareinsights.com/beacon.min.js/...'
violates the following Content Security Policy directive: "script-src 'self'"
Executing inline script violates ... 'script-src 'self''

The tag was not in the repository — curl of the deployed HTML showed none. Cloudflare injects the beacon plus an inline loader into HTML responses at the edge, after the origin response and therefore after our CSP.

That mode can never work here, and this is the part worth remembering. The site's CSP runs in mode: "hash" (SvelteKit hashes its own bootstrap script), and CSP3 says a script-src carrying a hash or nonce ignores 'unsafe-inline'. There is no policy that admits an inline script we cannot hash, and we cannot hash one the edge writes after we have built the page. The only fix available is not to use that mode.

What is configured now:

  1. Analytics & Logs → Web Analytics → Manage site → "Enable with JS Snippet installation" — selected 2026-09-20. This is what stops the edge injection, and it is the ONLY mode this site can use. Do not switch it back to either "Enable" option: both inject the inline loader, and the CSP will refuse it exactly as before.
  2. Copy the site token into CF_BEACON_TOKEN in web/src/lib/analytics.ts. It is not a secret — Cloudflare's own snippet publishes it in the page — and an empty value simply disables analytics, which is what a fork gets.
  3. The app appends the beacon itself, from the $effect in routes/+layout.svelte that waits on consent.accepted and on the human check (section 12), so nothing loads before the reader accepts the terms, and never under Tauri.
  4. build/sveltekit-config.ts allows https://static.cloudflareinsights.com in script-src and https://cloudflareinsights.com in connect-src, web flavour only. scripts/verify-dist.mjs fails the build if either is missing from the web build or present in the Tauri build.

docs/PRIVACY_POLICY.md was rewritten for this: it used to say the site had no analytics and contacted no third party, which is what made the "just allowlist it" option unacceptable before.

Check (in a browser console, not curl — the injection was browser-conditional and the app's own load is consent-conditional):

open https://free-steam-games.win/, accept the terms, and confirm a single request to static.cloudflareinsights.com with no CSP error. Before accepting there must be none at all.

Measured on the live site, 2026-09-20: before consent, no beacon request and an empty console; after consent, beacon.min.js → 200 and the RUM POSTs to cloudflareinsights.com/cdn-cgi/rum → 204, with one script[data-cf-beacon] tag in the document and no violation of any kind. That is the first page view this site has ever recorded.


Found 2026-09-12 while running the SvelteKit dev server, which proxies /img/* to production: every image came back 403, body error code: 1011 — Cloudflare's Hotlink Protection (Scrape Shield). It covers .gif, .ico, .jpg, .jpeg and .png only, so the extension-less /img/gh/* avatars were never affected, and it runs at the edge before the Worker, so nothing in worker/ can answer it.

It keys on Referer, and lets a request with no Referer through. Measured against the live zone, before the rule below existed:

Referer sent /img/*
none 200
https://free-steam-games.win/ 200
http://localhost:5173/ 403
tauri://localhost/ 403
http://tauri.localhost/ 403

/api/data/* is unaffected — the rule only covers images.

It broke the packaged apps, 2026-09-23. This section used to say the apps survived only because their webview sent no Referer, and warned that a webview update could change that. It had: Security → Events showed desktop 2.0.0 on WebView2 sending Referer: http://tauri.localhost/ and being blocked, and game pages showed a broken image. Android's System WebView sends the same origin.

The fix is in the page, not the zone. Every <img> in the app carries referrerpolicy="no-referrer", so no build sends a Referer for artwork at all: the apps, tauri dev and npm run dev arrive as "none", and the web — whose image requests are same-origin anyway — loses nothing. src/lib/images.test.ts fails on an <img> without the attribute.

Hotlink Protection stays on: it still refuses other sites that embed /img/* and send their own Referer. That is a courtesy, not access control — a Referer is set by the client, and any page that asks for none passes, as ours now does. What actually restricts /img/* is the anchored PATH_RE and the two-host SOURCE_HOSTS allowlist in worker/routes/img.ts.

Builds released before the fix (desktop and Android 2.0.0) need a Configuration Rule, live since 2026-09-23 (measured with the check below). Rules → Configuration Rules is the source of truth; this is what it must express:

Field Value
Rule name tauri-images-hotlink-off
Expression starts_with(http.request.uri.path, "/img/") and (starts_with(http.referer, "http://tauri.localhost/") or starts_with(http.referer, "https://tauri.localhost/") or starts_with(http.referer, "tauri://localhost/"))
Setting Hotlink Protection → Off

No web page can make a browser send a Referer beginning with http://tauri.localhost/, so the rule opens nothing to other sites. localhost:5173 is deliberately left out: the code fix covers dev. Configuration Rules are their own Free-plan quota (ten), apart from the WAF budget in "Still open". Keep the rule while 2.0.0 installs exist — a sideloaded APK may never update — and it is harmless after that.

Check:

url='https://free-steam-games.win/img/t/730/header.jpg?t=1749053861'
curl -s -o /dev/null -w 'none %{http_code}\n' "$url"
for r in http://tauri.localhost/ https://tauri.localhost/ tauri://localhost/ http://localhost:5173/ https://example.com/; do
  printf '%-26s %s\n' "$r" "$(curl -s -o /dev/null -w '%{http_code}' -H "Referer: $r" "$url")"
done

Expected, and measured on 2026-09-23: 200, then 200 three times (the rule), then 403 twice (protection still on).


11. Continuous script monitoring adds a report-only CSP to some responses

Found 2026-09-17 in the browser console on the live site, on roughly one page load in thirty:

[Report Only] Refused to ... because it violates the following Content Security
Policy directive ... report-uri /cdn-cgi/script_monitor/report

It is not in the repository. Cloudflare's Continuous script monitoring (Page Shield) samples responses at the edge and adds a Content-Security-Policy-Report-Only header whose reports go to /cdn-cgi/script_monitor/report. Report-only means it blocks nothing, so the site works; the cost is console noise, and that the reports send page and script URLs from visitors' browsers to Cloudflare, which docs/PRIVACY_POLICY.md does not mention.

It also adds nothing this site needs: every script is first-party, the app's own CSP already refuses anything else, and the admin shell's nonce policy is stricter still.

Recommended: turn it OFF (dashboard → Security → Settings → Continuous script monitoring). Dashboard action, so it is the maintainer's to do. If it is ever wanted on, say so in the privacy policy first.

Check (repeat a few times; the header is sampled):

for i in 1 2 3 4 5 6 7 8; do curl -sI https://free-steam-games.win/ | grep -ci "content-security-policy-report-only"; done

Every line must print 0.


12. The human check — Cloudflare Turnstile in the web app

What it is. After accepting the terms, each browser on the website passes a Turnstile widget, at most once every 24 hours, before the app loads its data (src/lib/common/HumanCheck.svelte; the rules are in src/lib/human-check.ts). The widget's token goes to the Worker at POST /api/human-check (worker/routes/human-check.ts), which confirms it with siteverify using the secret and checks the action (enter) and the hostname. The packaged apps never run it, and /legal/* and /error/* are never covered by it (src/lib/gates.ts).

What it is not — say so to anyone who asks. It is a door for people using the web app, not a wall around the site. The pages are prerendered and served without the Worker, and docs/ToS.md §9 promises that /api/data/*, /img/* and the apps are never human-checked, so nothing on the server requires a pass: a script that reads the HTML or the API never meets it, and a browser that edits f2p:human_check skips it. The rate limit in section 3 and the WAF rules in section 4 remain the boundary. Do not "fix" that by making the data or image routes require a pass — it breaks the ToS and the packaged apps.

It refuses only on a verdict: siteverify said no (the route's 403), or the widget reported a failed challenge. Anything that is the site's own fault lets the reader through for that page load and stores nothing — the route answering 503 (no secret) or 502 (siteverify unreachable), or a widget configuration error such as a hostname the widget does not allow. So does being offline, which keeps the installed web app usable without a network.

Widget settings (Cloudflare dashboard → Turnstile → the widget):

Setting Value Why
Hostnames free-steam-games.win Every other hostname gets Cloudflare's test key from the page, so localhost never needs to be listed.
Widget mode Managed Usually passes without a click.
Pre-clearance No It would set a cf_clearance cookie the privacy policy does not describe, and nothing here reads it.

The site key is public and lives in TURNSTILE_SITEKEY (src/lib/human-check.ts). Emptying it disables the check, which is what a fork gets.

Serving the site on another hostname (today www. only redirects to the apex): the page falls back to the test key there, and the Worker answers that key's fixed token with 503 and test widget against a production secret in Workers Logs, so visitors are let through rather than refused. To check them there too, add the hostname to the widget and to siteKeyFor().

The secret is the Worker secret TURNSTILE_SECRET:

npx wrangler secret put TURNSTILE_SECRET

Deploy order never matters: without it the route answers 503, every visitor is let through, and Workers Logs show human-check: TURNSTILE_SECRET is not set. To rotate it, roll the secret in the Turnstile dashboard and secret put the new value; a check in flight during those seconds fails once and passes on Retry.

CSP. Web flavour only: challenges.cloudflare.com in script-src and frame-src (section 1). The widget's frame inherits the Permissions-Policy from _headers and may log a harmless message from inside challenges.cloudflare.com; that is not a violation of this site's policy.

Rate limit. Each POST costs one siteverify subrequest, so the route has its own Worker budget, RL_HUMAN: 20 per IP per minute (section 3b), where a person sends one a day. A refused check lets the reader through like any other answer that is not a verdict. The site-wide WAF rule (section 3a) counts it too; the narrower public-proxies rule does not.

Local testing. npm run dev skips the check: its /api proxy points at production, which refuses a localhost token. npm run preview proxies the same way and cannot pass either. Use wrangler dev with web/.dev.vars (copy web/.dev.vars.example, which holds Cloudflare's always-pass TEST secret); the page renders the matching test widget on every hostname but production. The 2x… and 3x… test secrets listed in that file show the refusal path.

Check (after a deploy):

curl -s -X POST https://free-steam-games.win/api/human-check \
  -H 'Origin: https://free-steam-games.win' -H 'Content-Type: application/json' \
  -d '{"token":"not-a-real-token"}'

Expected: HTTP 403 with "codes":["invalid-input-response"] — the secret is set and siteverify answered. A 503 means the secret is missing. Then, in a fresh browser profile: no request to challenges.cloudflare.com before accepting the terms; after accepting, the widget, one POST /api/human-check answered 200, and f2p:human_check in localStorage about 24 hours ahead.


Still open

Nothing from this list, as of 2026-09-23. audit_log and commit_jobs are pruned daily after ADMIN_RETENTION_DAYS (180), which docs/PRIVACY_POLICY.md states.

The Free-plan rule budget is now the constraint to watch: the one rate limiting rule is used (section 3a), and four of the five custom rules are (as of 2026-10-27: human-check-pages, blocked-countries, media-host-paths, and Cloudflare's AI Crawl Control rule). A fifth custom rule is affordable; a second rate-limiting rule is not, without upgrading - which is why per-surface limits live in the Worker (section 3b), where they cost no rule. Configuration Rules are a separate quota: one of ten is used (section 10).