agentleFS
jpoehneltjpoehnelt/skills/cloudflare-edge-hardening/SKILL.md

cloudflare-edge-hardening

Skill23 starsChanged 7 days agoMITView on GitHub

Harden Cloudflare Workers, SvelteKit edge routes, WAF and Browser Integrity Check rules, security headers, CSP, CSRF exemptions, SSRF guards, and telemetry scrubbing. Use when adding or modifying public routes, static assets, webhooks, outbound fetches, auth callbacks, or Cloudflare WAF and header config.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every public route sits behind four layers: zone WAF and Browser Integrity Check (BIC), static asset _headers, Worker or framework …

    line 8
  2. Very specific:

    Before adding a route, static machine file (/llms.txt, /robots.txt, /schemas/*), or content-negotiated endpoint, declare five properties in …

    line 14
  3. Very specific:

    Capped ingress: use the repo's shared streaming byte-capped body helper on every POST, PUT, and PATCH, including routes with trailing …

    line 24
  4. Very specific:

    SSRF-safe egress: use the repo's shared SSRF fetch helper (redirect: "manual", per-hop DNS and CIDR re-validation, trailing-dot …

    line 25
  5. Distinctive:

    Privacy scrubbing: never log raw parse errors, request URLs with query strings, or auth headers to error trackers.

    line 26
  6. Very specific:

    Strict CSP: avoid unsafe-inline and inline style= attributes in app shells.

    line 28
  7. Very specific:

    Run sgpack security rules, the repo's security lint pack, and edge-router tests covering the full Worker entrypoint, not an isolated …

    line 32

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Cloudflare edge hardening

Every public route sits behind four layers: zone WAF and Browser Integrity Check (BIC), static asset _headers, Worker or framework middleware, and outbound or telemetry boundaries. Changing one layer without the others causes 1010 agent outages, missing headers on Worker responses, or silent security regressions.

Repo facts (from AGENTS.md): the route manifest or router entrypoint, WAF and BIC config, static _headers and server hook paths, the repo's shared edge security helpers (capped body reader, SSRF fetch, security-header hook, telemetry scrubber, analytics wrapper), sgpack security rules, and the security lint and edge-router test commands.

Classify every route once

Before adding a route, static machine file (/llms.txt, /robots.txt, /schemas/*), or content-negotiated endpoint, declare five properties in the repo's single route table (or verify all surfaces in one change):

  1. Audience: browser page, non-browser API or AI agent, webhook receiver, or OAuth callback.
  2. WAF and BIC: non-browser clients fail Cloudflare BIC (error 1010) unless exempted. Match exact path prefixes and parse Accept media-type quality values strictly so text/markdown;q=0 never bypasses browser rules.
  3. Methods and 405: list allowed HTTP methods explicitly and return JSON 405 with an Allow header for unsupported methods rather than falling through to an HTML 404.
  4. Headers on every response path: static _headers does not cover Worker-generated JSON, auth redirects, or framework 404 or 500 responses. Emit HSTS, CSP, X-Content-Type-Options, and Referrer-Policy in server hooks too. Check that Referrer-Policy preserves Origin on same-origin POSTs so CSRF checks do not see Origin: null.
  5. Auth and CSRF: authenticate before reading bodies on protected routes (effect-boundary-validation); add explicit narrow exemptions for external OAuth callbacks and signed webhooks.

Harden ingress, egress, and telemetry

  • Capped ingress: use the repo's shared streaming byte-capped body helper on every POST, PUT, and PATCH, including routes with trailing slashes or missing Content-Length. Never buffer unbounded bodies in Workers or Durable Objects.
  • SSRF-safe egress: use the repo's shared SSRF fetch helper (redirect: "manual", per-hop DNS and CIDR re-validation, trailing-dot normalization, outer timeout) rather than raw fetch or hand-rolled IP bitmasks. Keep registration-time and delivery-time URL checks identical.
  • Privacy scrubbing: never log raw parse errors, request URLs with query strings, or auth headers to error trackers. Pin a regression test asserting sensitive fields are scrubbed so later SDK refactors cannot silently drop the scrubber.
  • Third-party analytics: strip private route paths and referrers before sending events, and suspend tracking on excluded or authenticated admin routes.
  • Strict CSP: avoid unsafe-inline and inline style= attributes in app shells; verify built pages and 404 pages against the live CSP header. Follow alchemy-infra for zone and Worker bindings.

Verify

  • Run sgpack security rules, the repo's security lint pack, and edge-router tests covering the full Worker entrypoint, not an isolated handler.
  • Probe a wrong HTTP method (expect 405 with Allow), an oversized body without Content-Length (expect 413), a non-browser User-Agent on agent routes, and a Worker 404 or redirect for required security headers.
  • Confirm telemetry scrubber and analytics exclusion tests assert on actual emitted payloads.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.