Skip to content
Early bird + Black Friday · 73% off

Get ZeroDirs for $179 $49

Claim $49 deal

Security

Three exposed surfaces: /admin/, the URL step 1 of /submit/ fetches, and a form anyone can post to. The admins are the accounts named in admin.emails; TOKEN_SECRET, set with pnpm cf:secrets, signs every status and checkout link.

  1. Put the signing secret in from .env.prod. The script rejects a placeholder, a whsec_ value in the wrong key, or a secret under 32 characters.

    Terminal
    pnpm cf:secrets TOKEN_SECRET
  2. Put Cloudflare Access in front of /admin/: Zero Trust → Access controls → Applications → Create new application → Self-hosted, your domain with the path admin, one policy: Allow, include your email address.

    In a private window, https://<your domain>/admin/ shows Cloudflare’s sign-in first.

  3. Turn the workers.dev route off. pnpm cf:setup writes workers_dev: false beside the custom domain; check wrangler.jsonc, then deploy.

    Terminal
    pnpm deploy

    https://<worker>.<subdomain>.workers.dev/admin/ answers nothing of yours.

  4. Wrong passwords are counted per address — ten in fifteen minutes lock it — not per source. For a limit per source: your zone → Security → WAF → Rate limiting rules → Create rule: path equal to /login/, method POST, a threshold no person reaches in 10 seconds, action Block. Deploy.

    Posting past the threshold shows Cloudflare’s block page instead of the form.

  • An admin is an account whose address is in admin.emails and proven: a Google sign-in, or a password-reset link that was opened. Signing up with a password proves nothing — anyone can sign up with your address — so until then /admin/ answers “Prove this address first”.
  • One session for everybody: the HttpOnly zd_session cookie names a row in sessions; zd_user is a hint the page’s script reads (name, address, avatar, m for an admin) and the server never trusts. TOKEN_SECRET signs status and checkout links, not sessions.
  • A direct POST /_actions/admin.approve/ without an admin’s session is a 401, Sign in as an admin first.
  • A zone-level policy covers your domain, not <worker>.<subdomain>.workers.dev: leave that route on and anyone who guesses the subdomain walks past it.
  • /admin/ reports TOKEN_SECRET is still the value from .env.example… while it is in use. Never put a secret in vars in wrangler.jsonc or above the # === Runtime secrets === line.
  • http: and https: only; no credentials in the URL; no port other than 80 or 443. Every IP literal is rejected, public ones included, down to 2130706433, 0x7f000001 and 0177.0.0.1.
  • Blocked hostnames localhost, ip6-localhost, ip6-loopback, broadcasthost; blocked suffixes .localhost, .local, .internal, .intranet, .lan, .home, .home.arpa, .corp, .private, .test, .example, .invalid, .onion; any hostname without a dot.
  • At most 3 redirect hops, checked again on every Location; one 5-second budget, text/html only, read until </head> and never past 256 KB, cached for a day.
  • Logos are sniffed, the declared type ignored: PNG, JPEG and WebP by magic bytes, SVG refused when it contains <script, ICO decoded to PNG. limits.logoMaxBytes caps size under a hard 1 MiB ceiling.
Control Default What happens
Honeypot features.honeypot: true a hidden company field on both steps and the newsletter form; filled, it answers the same 303 to /submit/?sent=1 as a real submission and writes nothing
Per-address limit limits.submissionsPerEmailPerDay: 3, rolling 24 hours That address has submitted 3 times in the last 24 hours, which is the limit. Please try again tomorrow.
One live listing per host always a pending or approved row blocks a resubmission; a rejected one does not
Cross-site posts Astro’s origin check, SameSite=Lax 403. /out/<id>/ checks Ping-From instead: 403 Ping-From is not this site.
Where You should see
The guard curl -sI https://<your domain>/admin/ 302, location: /login/?next=%2Fadmin%2F, cache-control: no-store, x-robots-tag: noindex
A deep admin path curl -sI https://<your domain>/admin/listings/ the same 302 with next=%2Fadmin%2Flistings%2F
A direct action curl -s -o /dev/null -w '%{http_code}' -H 'Origin: https://<your domain>' --data 'id=x' https://<your domain>/_actions/admin.approve/ 401
Somebody else’s account /admin/, signed in as an address not in admin.emails 403 at /admin/login/, “Not an admin”
The fetcher step 1 of /submit/ with http://127.0.0.1/ That address is not a public website. under the field; step 2 never renders

admin.emails, features.honeypot, limits.submissionsPerEmailPerDay and limits.logoMaxBytes (default 512 KiB) — admin, features, limits.

  • Directorysrc/
    • middleware.ts the guard, the redirect, the headers
    • Directoryserver/
      • admin-auth.ts the two checks: listed, and proven
      • audit.ts login_fail rows, hashed address
      • meta-fetcher.ts checkUrl() and the limits
      • media.ts sniffImage() and the size caps
      • submit.ts honeypot, duplicate check, per-address limit
    • actions/admin.ts requireAdmin(), the 401
  • scripts/put-secrets.ts pnpm cf:secrets
  • wrangler.jsonc workers_dev: false beside the route
  • AGENTS.md the claude.md hazard
  • tests/e2e/admin.spec.ts the guard, against the built Worker