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.
-
Put the signing secret in from
.env.prod. The script rejects a placeholder, awhsec_value in the wrong key, or a secret under 32 characters.Terminal pnpm cf:secrets TOKEN_SECRET -
Put Cloudflare Access in front of
/admin/: Zero Trust → Access controls → Applications → Create new application → Self-hosted, your domain with the pathadmin, one policy: Allow, include your email address.In a private window,
https://<your domain>/admin/shows Cloudflare’s sign-in first. -
Turn the
workers.devroute off.pnpm cf:setupwritesworkers_dev: falsebeside the custom domain; checkwrangler.jsonc, then deploy.Terminal pnpm deployhttps://<worker>.<subdomain>.workers.dev/admin/answers nothing of yours. -
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/, methodPOST, a threshold no person reaches in 10 seconds, action Block. Deploy.Posting past the threshold shows Cloudflare’s block page instead of the form.
Admin authentication
Section titled “Admin authentication”- An admin is an account whose address is in
admin.emailsand 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_sessioncookie names a row insessions;zd_useris a hint the page’s script reads (name, address, avatar,mfor an admin) and the server never trusts.TOKEN_SECRETsigns 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/reportsTOKEN_SECRET is still the value from .env.example…while it is in use. Never put a secret invarsinwrangler.jsoncor above the# === Runtime secrets ===line.
The metadata fetcher
Section titled “The metadata fetcher”http:andhttps:only; no credentials in the URL; no port other than 80 or 443. Every IP literal is rejected, public ones included, down to2130706433,0x7f000001and0177.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/htmlonly, 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.logoMaxBytescaps size under a hard 1 MiB ceiling.
Abuse controls on the form
Section titled “Abuse controls on the form”| 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. |
Verify
Section titled “Verify”| 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 |
Configuration
Section titled “Configuration”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_failrows, 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: falsebeside the route - AGENTS.md the
claude.mdhazard - tests/e2e/admin.spec.ts the guard, against the built Worker